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 2000 Forums
 SQL Server Development (2000)
 Data Entry

Author  Topic 

nisha
Starting Member

2 Posts

Posted - 2004-09-23 : 06:38:24
Hi all,
I'm new to database development so this might sound like a silly question! If i insert data in a few of the tables in my database and not the others even though they all have referential integrity to one main table, what will happen to the tables that are not filled out?

Thanks,

nisha

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2004-09-23 : 06:44:27
if you have insert in one table referencing to a main table then you might get referential integrity violation, or if you're inserting to a table that is being referenced then the other tables not filled up will not be "automatically" inserted with the new value.

you can only have update and delete cascade, if you chose these options when establishing the relationship between the tables.

try it out on a test database and see what happens, play around with the options so you'll understand better.
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2004-09-23 : 07:58:08
this is to answer your other posts on cascade...

let's say you have table 1 with primary key + 3 fields, referenced by table 2 with primary key (foreign on table 1) + 10 fields, and each fields would have different data type definitions.

if there was a cascade insert, how will sql know what data to insert on the other fields?

as a work around, you can create a trigger on table1 if you don't want to "manually" do this in your application level.
just an idea...
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2004-09-23 : 09:23:07
show us your create table statements, including the FK constraint as you declared it. then give a few insert statements to populate your two tables with data.

then show us an UPDATE statement that fails to properly cascade the change.

Does this make sense that if you give us this information, we'll be able to help you much more easily?

- Jeff
Go to Top of Page
   

- Advertisement -