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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 SQL relationships....i really need help
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

1 Posts

Posted - 04/16/2014 :  19:04:40  Show Profile  Reply with Quote
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.

Thanks HF

Flowing Fount of Yak Knowledge

6065 Posts

Posted - 04/17/2014 :  11:18:02  Show Profile  Reply with Quote
>>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
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000