Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How do I set up User comments

Author  Topic 

SidewaysFish
Starting Member

6 Posts

Posted - 2007-09-16 : 13:02:00
I am trying to plan out a database that will have users and comments on those users. How should I structure this? Should each comment be attached to the user it describes or should each user have a list of the comments that describe it?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-16 : 13:28:05
Here is a start
http://www.datamodel.org/NormalizationRules.html



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

SidewaysFish
Starting Member

6 Posts

Posted - 2007-09-16 : 15:04:09
Thanks Peso.
So each User is going to have a list of comments.
What does this look like in sql structure? Is there a way to embed a list, array, or another table within a table? There must be a 'usual' way to do this, right?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-16 : 15:33:06
One table with users.
One table with comments which includes a foreign key to users table.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

SidewaysFish
Starting Member

6 Posts

Posted - 2007-09-16 : 15:51:53
Ok, I get it. So to load a User's page, I would do something like (just learning sql):
SELECT * FROM Comments WHERE UserID = mID
?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-16 : 15:53:46
Yes, that's the general idea.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -