-
Notifications
You must be signed in to change notification settings - Fork 0
/
CinemaDB query.sql
68 lines (59 loc) · 1.23 KB
/
CinemaDB query.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
--Creates Database
Create Database CinemaDB
use CinemaDB --only one DB connection at a time
go
--Jeg lavede databasen ved hjælp af LucidChart export
CREATE TABLE [Movie] (
[movieId] int identity (1,1),
[name] text,
[ageRating] int default 0,
[image] text,
[trailer] text,
[description] text,
[release] Date,
PRIMARY KEY ([movieId])
);
CREATE TABLE [Theater] (
[theaterId] int identity (1,1),
[number] text,
PRIMARY KEY ([theaterId])
);
CREATE TABLE [Show] (
[showId] int identity (1,1),
[theaterId] int,
[movieId] int,
[date] Date,
PRIMARY KEY ([showId])
);
CREATE TABLE [MovieGenre] (
[movieId] int,
[genre] text
);
CREATE INDEX [PK FK] ON [MovieGenre] ([movieId]);
CREATE TABLE [Seat] (
[seatId] int identity (1,1),
[theaterId] int,
[row] int,
[number] int,
PRIMARY KEY ([seatId])
);
CREATE TABLE [User] (
[userId] int identity (1,1),
[firstName] varchar(100),
[lastName] varchar(100),
[phone] int,
[admin] bit,
PRIMARY KEY ([userId])
);
CREATE TABLE [Ticket] (
[TicketId] int identity (1,1),
[seatId] int,
[showId] int,
[qrCode] text,
PRIMARY KEY ([TicketId])
);
CREATE TABLE [Genre] (
[genreId] int identity (1,1),
[genreName] varchar(100),
PRIMARY KEY ([genreId])
);