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
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 SQL relationships....i really need help

Author  Topic 

HopelesslyFaithful
Starting Member

1 Post

Posted - 2014-04-16 : 19:04:40
So i have a project for school that i need to make an SQL server. I created the note pad file for all the tables and i think i have all the keys i need but i can't figure out how i am supposed to build the relationships. Supposedly you can use the same PK for two tables but i thought that wasn't possible so i am really confused from top to bottom. So the project I have to take someone's DB design from visio and create it in SQL server 2008 from the virtual thing at school. I provided a link to my Dropbox folder with all the files. I really appreciate any help i can get.

https://www.dropbox.com/sh/y7t21cjav5wx6o7/Vfos1JHHxi

Thanks HF

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2014-04-17 : 11:18:02
>>i can't figure out how i am supposed to build the relationships

a "relationship" is typically one table with a Primary Key constraint (or unique constraint) which is referenced by another table in a Foreign Key constraint.

for complete syntax, remarks, and examples see these topics in Books Online:
Alter Table
Table Constraints

That would apply to one-to-one and one-to-many relationships
For many-to-many you typically need three tables - two entity tables and a "relationship" table. For instance you may have person_table, phone_table, and person_phone_table which would support one phoneNumber for several people and one person with several phoneNumbers.

Good luck

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -