-
Notifications
You must be signed in to change notification settings - Fork 0
/
cinesheet.sql
68 lines (46 loc) · 1.23 KB
/
cinesheet.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
CREATE DATABASE CINESHEET;
USE CINESHEET;
CREATE TABLE USERS (
user_id INT PRIMARY KEY,
name VARCHAR(50),
password_hash VARCHAR(50),
email VARCHAR(50),
mobile_no INT,
profile_picture VARCHAR(255)
);
CREATE TABLE MOVIES (
movie_id INT PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(50),
rating DECIMAL(3,1),
runtime TIME,
language CHAR(20)
);
CREATE TABLE GENRES (
genre_id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(50)
);
CREATE TABLE PLATFORM (
platform_id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(50)
);
CREATE TABLE FAVOURITES (
favourite_id INT PRIMARY KEY AUTO_INCREMENT,
user_id INT,
movie_id INT,
FOREIGN KEY (user_id) REFERENCES USERS(user_id),
FOREIGN KEY (movie_id) REFERENCES MOVIES(movie_id)
);
CREATE TABLE MOVIES_GENRES (
movie_id INT,
genre_id INT,
PRIMARY KEY (movie_id, genre_id),
FOREIGN KEY (movie_id) REFERENCES MOVIES(movie_id),
FOREIGN KEY (genre_id) REFERENCES GENRES(genre_id)
);
CREATE TABLE MOVIES_PLATFORMS (
movie_id INT,
platform_id INT,
PRIMARY KEY (movie_id, platform_id),
FOREIGN KEY (movie_id) REFERENCES MOVIES(movie_id),
FOREIGN KEY (platform_id) REFERENCES PLATFORM(platform_id)
);