LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Mysql Foreign Key (http://www.linuxquestions.org/questions/linux-software-2/mysql-foreign-key-192785/)

munna_502 06-12-2004 05:31 PM

Mysql Foreign Key
 
Hi readers,
I am new in mysql but i have all the conceptes of SQL.I am create the relation of primary key and foreign key in tables.The join is working but when i will delete a parent record it delete the parent record.
my requirement is it will give me the error like oracle ,when we have child record then we can not delete the parent records.and also when insertin data in child it inserted the date whetever the parent is exist or not.
My sql statments are

for parent tables

CREATE TABLE student(stu_id int(10)PRIMARY KEY,
stu_name VARCHAR(20) NOT NULL,
email varchar(30));
for child table

CREATE TABLE course (course_id int PRIMARY KEY,
course_name varchar(30)NOT NULL,
stu_id int(10),
FOREIGN KEY(stu_id)
REFERENCES student(stu_id));

Please help me urgent


All times are GMT -5. The time now is 04:28 PM.