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
 Tables relations

Author  Topic 

shapper
Constraint Violating Yak Guru

450 Posts

Posted - 2009-07-31 : 12:08:45
Hello,

I have 3 tables: Posts, Users and Subjects.

Each User can be related to one or more Subjects so I created the table UsersSubjects.

Each Post can be related to none or one Subject. How can I do this?
I could add PostId on Subjects table but since I am also relating Subjects with Users this does not make any sense.

Could someone tell me what would be the best way to create these relations?

Thanks,
Miguel

X002548
Not Just a Number

15586 Posts

Posted - 2009-07-31 : 13:28:12
Add SubjectId to the Post table and make it nullable

EDIT: Slick Willy (wagging finger): "I did not have relations with that table..."

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-07-31 : 14:36:12
quote:
Originally posted by X002548

Add SubjectId to the Post table and make it nullable

EDIT: Slick Willy (wagging finger): "I did not have relations with that table..."

Brett

8-)



maybe so - but I'm guessing you inhaled.

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -