Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DROP TABLE IF EXISTS pets CASCADE;
- DROP TABLE IF EXISTS owners CASCADE;
- DROP TABLE IF EXISTS pets_owners;
- CREATE TABLE pets (
- id serial PRIMARY KEY,
- name varchar(255),
- age integer,
- kind text
- );
- CREATE TABLE owners (
- id serial PRIMARY KEY,
- name text,
- is_alergic boolean
- );
- CREATE TABLE pets_owners (
- id serial PRIMARY KEY,
- pet_id integer NOT NULL REFERENCES pets ON DELETE CASCADE,
- owner_id integer NOT NULL REFERENCES owners ON DELETE CASCADE,
- role text
- );
- INSERT INTO pets (name, age, kind)
- VALUES ('Chucky', 102, 'Goat');
- INSERT INTO owners (name, is_alergic)
- VALUES ('Glen', true);
- INSERT INTO pets_owners (pet_id, owner_id, role)
- VALUES (1, 1, 'Father')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement