SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

HopelesslyFaithful
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.

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

Thanks HF

TG
Flowing Fount of Yak Knowledge

USA
6062 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
TG
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.05 seconds. Powered By: Snitz Forums 2000