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
 General SQL Server Forums
 New to SQL Server Programming
 many to many relationship
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

AJ217
Starting Member

3 Posts

Posted - 05/05/2014 :  13:25:27  Show Profile  Reply with Quote
Hi, why do we need a junction table in a many to many relationship? Why can't everything be in just 2 tables?

Lamprey
Flowing Fount of Yak Knowledge

4614 Posts

Posted - 05/05/2014 :  13:40:14  Show Profile  Reply with Quote
How would you model a many-to-many with two tables?
Go to Top of Page

AJ217
Starting Member

3 Posts

Posted - 05/05/2014 :  13:53:07  Show Profile  Reply with Quote
if i was describing lets say classes and students where each student can be in more than one class and each class can have multiple students. Or how about just using Table A by itself. I'm sorry, I'm new to SQL.

Table A
ID Student Class
1 Bob math
2 Tim math
3 Linda english
4 Linda science

Table B
ID Class
10 math
11 science
12 english
Go to Top of Page

Lamprey
Flowing Fount of Yak Knowledge

4614 Posts

Posted - 05/05/2014 :  14:10:08  Show Profile  Reply with Quote
You can certainly model a one to many with one table, but I wouldn't do it for a number of reasons. The point is that, in general, normalization is a good thing. If you don't use a junction table, then your leaving you data less normalized. If you are not familiar with normalization, then you should look it up! That is one of the fundamental foundations of relational theory. :)
Go to Top of Page

AJ217
Starting Member

3 Posts

Posted - 05/05/2014 :  15:16:52  Show Profile  Reply with Quote
Ok yeah I'll have to look up normalization with respect to relational theory. Thank you so much.
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