Advertisement
Void-voiD

Untitled

Mar 31st, 2021
682
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. create table if not exists "Film"
  2. (
  3.     "FilmName" varchar(50) not null,
  4.     "ReleaseDate" varchar(17),
  5.     "LengthOfFilm" varchar(7),
  6.     "MainRoles" varchar(1000),
  7.     "Logo" varchar(200),
  8.     "Genre" varchar(100),
  9.     "FilmIMDB" integer not null
  10.         constraint film_pk
  11.             primary key,
  12.     "ReleaseYear" varchar(4),
  13.     "Rated" varchar(10),
  14.     "Director" varchar(100),
  15.     "Plot" varchar(500)
  16. );
  17.  
  18. alter table "Film" owner to postgres;
  19.  
  20. create unique index if not exists film_filmname_uindex
  21.     on "Film" ("FilmName");
  22.  
  23. create unique index if not exists film_filmimdb_uindex
  24.     on "Film" ("FilmIMDB");
  25.  
  26. create table if not exists "Cinema"
  27. (
  28.     "CinemaID" serial not null
  29.         constraint cinema_pk
  30.             primary key,
  31.     "Address" varchar(300),
  32.     "PublicName" varchar(100)
  33. );
  34.  
  35. alter table "Cinema" owner to postgres;
  36.  
  37. create table if not exists "Hall"
  38. (
  39.     "HallID" serial not null
  40.         constraint hall_pk
  41.             primary key,
  42.     "RowsNumber" smallint not null,
  43.     "CinemaID" integer
  44.         constraint hall_cinema__fk
  45.             references "Cinema"
  46.                 on update cascade on delete cascade,
  47.     "HallName" varchar(20)
  48. );
  49.  
  50. alter table "Hall" owner to postgres;
  51.  
  52. create table if not exists "Row"
  53. (
  54.     "RowID" serial not null
  55.         constraint row_pk
  56.             primary key,
  57.     "SeatNumber" smallint not null,
  58.     "HallID" integer
  59.         constraint row_hall__fk
  60.             references "Hall"
  61.                 on update cascade on delete cascade,
  62.     "NumberInHall" smallint
  63. );
  64.  
  65. alter table "Row" owner to postgres;
  66.  
  67. create table if not exists "Seat"
  68. (
  69.     "SeatID" serial not null
  70.         constraint seat_pk
  71.             primary key,
  72.     "RowID" integer
  73.         constraint seat_row__fk
  74.             references "Row"
  75.                 on update cascade on delete cascade,
  76.     "SeatName" varchar(3)
  77. );
  78.  
  79. alter table "Seat" owner to postgres;
  80.  
  81. create unique index if not exists seat_seatid_uindex
  82.     on "Seat" ("SeatID");
  83.  
  84. create table if not exists "Customer"
  85. (
  86.     "Email" varchar(50) not null
  87.         constraint customer_pk
  88.             primary key,
  89.     "FirstName" varchar(50),
  90.     "LastName" varchar(50),
  91.     "LoginName" varchar(25) not null,
  92.     "PasswordHash" varchar(60) not null
  93. );
  94.  
  95. alter table "Customer" owner to postgres;
  96.  
  97. create unique index if not exists customer_loginname_uindex
  98.     on "Customer" ("LoginName");
  99.  
  100. create unique index if not exists customer_email_uindex
  101.     on "Customer" ("Email");
  102.  
  103. create table if not exists "SessionFilm"
  104. (
  105.     "SessionID" serial not null
  106.         constraint sessionfilm_pk
  107.             primary key,
  108.     "HallID" integer
  109.         constraint sessionfilm_hall__fk
  110.             references "Hall"
  111.                 on update cascade on delete cascade,
  112.     "FilmIMDB" integer
  113.         constraint sessionfilm_film__fk
  114.             references "Film"
  115.                 on update cascade on delete cascade,
  116.     "Price" smallint,
  117.     "DateAndTime" timestamp
  118. );
  119.  
  120. alter table "SessionFilm" owner to postgres;
  121.  
  122. create unique index if not exists sessionfilm_sessionid_uindex
  123.     on "SessionFilm" ("SessionID");
  124.  
  125. create table if not exists "Ticket"
  126. (
  127.     "TicketID" serial not null
  128.         constraint table_name_pk
  129.             primary key,
  130.     "SeatID" integer
  131.         constraint table_name_seat__fk
  132.             references "Seat"
  133.                 on update cascade on delete cascade,
  134.     "SessionID" integer
  135.         constraint table_name_sessionfilm__fk
  136.             references "SessionFilm"
  137.                 on update cascade on delete cascade,
  138.     "CustomerID" varchar(25)
  139.         constraint table_name_customer__fk
  140.             references "Customer"
  141.                 on update cascade on delete cascade
  142. );
  143.  
  144. alter table "Ticket" owner to postgres;
  145.  
  146. create unique index if not exists table_name_ticketid_uindex
  147.     on "Ticket" ("TicketID");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement