use mytools;
DROP TABLE IF EXISTS parent_tbl;
DROP TABLE IF EXISTS child_tbl;
-- drop parent_tbl again: why?
DROP TABLE IF EXISTS parent_tbl;

CREATE TABLE parent_tbl(
  cust_id INT PRIMARY KEY, 
  cust_name VARCHAR(30)
);

CREATE TABLE child_tbl(
    child_id INT PRIMARY KEY, 
    cust_id INT, 
    FOREIGN KEY (cust_id) REFERENCES parent_tbl(cust_id)
    ON DELETE SET NULL 
    ON UPDATE SET NULL 
);

INSERT INTO parent_tbl VALUES (100,'John Smith');
INSERT INTO parent_tbl VALUES (200,'Jane Jones');

INSERT INTO child_tbl VALUES (1200, 100);
INSERT INTO child_tbl VALUES (1300, 100);
INSERT INTO child_tbl VALUES (2500, 200);
INSERT INTO child_tbl VALUES (2600, 200);

