I have two tables and I'm trying to create a one to many relationship (master table can have many records in the details table)
I created a column in my details table with with ID of the primary key in the master table.
The primary key ID isn't inserted as a foreign key when I insert a record. I specifed the relationship in EM.
Not sure why the primary key ID isn't inserted as a foreign key into my details table?
Any help is greatly appreciated. Thanks.
-Dman100-Explain how you are doing it?
ohhh you do realise you need to insert the value into the table -- it does not do it automatically|||Okay, my mistake, I thought it would be automatic.
Can I do this within my sql statement, using a join or insert or whatever?? to pass the primary key value from the master table into the details table as a foreign key?
Thanks for your help! I appreciate it.
-Dman100-
Showing posts with label master. Show all posts
Showing posts with label master. Show all posts
Thursday, March 29, 2012
foreign key
Hi
is it a good practice to create FK on each & every column in a table whose values are taken from master table.
should I create or not.
If I create will that be heavy i.e what about memory consumption ?
pls reply
Thanks
Shubhangi1. You can foreign keys.
or
2. You can check through code. By using Inner join table name
on parenttabel.field=childtable.field
ro
3.Before inserting a record in child table, check whether it exists in the parent table through code by using if exists or if (select count(*) from tablename where
...)=0
or
if exists(select 1 from tablename where ...)
Subscribe to:
Posts (Atom)