CREATE TABLE maitre (
id integer PRIMARY KEY,
bidon varchar(30)
);

CREATE TABLE details (
id integer PRIMARY KEY,
maitre_id integer REFERENCES maitre (id) ON DELETE CASCADE ON UPDATE CASCADE,
bidon varchar(30)
);

-- donnees de reference
INSERT INTO maitre (id, bidon) VALUES (1, 'Bela Lugosi''s Dead');
INSERT INTO maitre (id, bidon) VALUES (2, 'Dark entries');
INSERT INTO maitre (id, bidon) VALUES (3, 'The Passion Of Lovers');
INSERT INTO maitre (id, bidon) VALUES (4, 'She''s In Parties');
INSERT INTO maitre (id, bidon) VALUES (5, 'Ziggy Stardust');
INSERT INTO maitre (id, bidon) VALUES (6, 'Telegram Sam');
INSERT INTO maitre (id, bidon) VALUES (7, 'Kick In The Eye');
INSERT INTO maitre (id, bidon) VALUES (8, 'The Sanity Assassin');
INSERT INTO maitre (id, bidon) VALUES (9, 'Terror Couple Kill The Colonel');
INSERT INTO maitre (id, bidon) VALUES (10, 'Searching For Satori');


-- Test du COPY
--
COPY details ( id, maitre_id, bidon ) FROM STDIN;
1	1	'1'
2	2	'2'
3	3	'3'
4	4	'4'
5	5	'5'
\.

DROP TABLE details;
CREATE TABLE details (
id integer PRIMARY KEY,
maitre_id integer REFERENCES maitre (id) ON DELETE SET NULL ON UPDATE SET NULL,
bidon varchar(30)
);


COPY details ( id, maitre_id, bidon ) FROM STDIN;
1	1	'1'
2	2	'2'
3	3	'3'
4	4	'4'
5	5	'5'
\.

-- fin
