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.
| Author |
Topic |
|
Chopsmum
Starting Member
38 Posts |
Posted - 2006-05-30 : 11:13:42
|
| Hi guys,this is going to sound like a ridiculous question, but when you are first adding all your records, do you need to add all the foreign key data yourself so that it ties together?eg. If studentid =1 in first table, then you need to add record for student id in bridging table so that studentid= 1:teacherid=1 and add teacher id=1 if it is not autoincrementing????ThanksCm |
|
|
svicky9
Posting Yak Master
232 Posts |
Posted - 2006-05-30 : 11:27:54
|
| Foreign keys constraints enforce referential integrity.They maintain the relations in a relational database.It In this case,you can use Triggers or you can use the update cascade.Vic |
 |
|
|
Chopsmum
Starting Member
38 Posts |
Posted - 2006-05-30 : 11:49:24
|
| This is going to sound dumb, but I thought that when you added data to table 1 and table 3 with a bridging table in between that is connected via foreign keys, that those values would be inserted for you in the bridging table from those values in tables 1 and 3. Is this correct????Cm |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-05-30 : 11:57:51
|
quote: Originally posted by Chopsmum This is going to sound dumb, but I thought that when you added data to table 1 and table 3 with a bridging table in between that is connected via foreign keys, that those values would be inserted for you in the bridging table from those values in tables 1 and 3. Is this correct????Cm
No. There would be no way for SQL Server know how they are related.CODO ERGO SUM |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2006-05-30 : 12:34:27
|
quote: Originally posted by Chopsmum If studentid =1 in first table, then you need to add record for student id in bridging table so that studentid= 1:teacherid=1 and add teacher id=1 if it is not autoincrementing????
What if the student isn't taking any courses and has no teachers?Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam |
 |
|
|
|
|
|