bird_1.sql 913 B

12345678910111213141516171819202122232425262728
  1. -- -----------------------------------------------------------------
  2. -- Создание таблиц
  3. -- Таблица семейств птиц
  4. create table family (
  5. family_id bigint generated always as identity primary key,
  6. family_name varchar(150) not null,
  7. description text
  8. );
  9. -- Таблица родов птиц
  10. create table genus (
  11. genus_id bigint generated always as identity primary key,
  12. genus_name varchar(150) not null,
  13. description text,
  14. family_id bigint not null references family(family_id)
  15. );
  16. -- Таблица видов птиц
  17. create table species (
  18. species_id bigint generated always as identity primary key,
  19. species_name varchar(150) not null,
  20. genus_id bigint not null references genus(genus_id),
  21. description text,
  22. average_length smallint not null check (average_length > 0),
  23. average_weight smallint not null check (average_weight > 0),
  24. primary_color varchar(50) not null
  25. );