DataBase: Question
hi to all
Friends,
1>I am having two tables A and B
2>In table A i am giving primary key to user ID and same user ID i am using in table B for inserting the data .
3> My question is when i delete the row in Table B it must also delete
the row in the table A.
4> or vice-versa
5>How can I use Foreign key and Primary key , plz help If u dont mind
[412 byte] By [
saamera] at [2007-11-27 1:10:47]

# 1
create table a (
id integer primary key
);
create table b (
id integer primary key,
a integer references a(id)
);
insert into a (id) values (42);
insert into a (id) values (69);
insert into b(id,b) values(1,42);
insert into b(id,b) values(2,69);
-- Acquire the PK for table A for deletion
select a from b where id = 1;
-- Delete the unwanted row in B
delete from b where id = 1;
-- Use the acquired PK to delete the appropriate row in A
delete from a where id = 42;