Advertisement
pacho_the_python

Untitled

Jun 6th, 2024
723
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.49 KB | None | 0 0
  1. CREATE TABLE animals (
  2.     id serial PRIMARY KEY ,
  3.     name VARCHAR(30) NOT NULL ,
  4.     birthdate DATE NOT NULL ,
  5.     owner_id INTEGER,
  6.     animal_type_id INTEGER NOT NULL ,
  7.  
  8.     CONSTRAINT fk_animals_owners
  9.         FOREIGN KEY (owner_id)
  10.         REFERENCES owners(id)
  11.         ON DELETE CASCADE
  12.         ON UPDATE CASCADE,
  13.  
  14.     CONSTRAINT fk_animals_animal_types
  15.         FOREIGN KEY (animal_type_id)
  16.         REFERENCES animal_types(id)
  17.         ON DELETE CASCADE
  18.         ON UPDATE CASCADE
  19. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement