Specification
Specification
Authors:
Piotr Czajka
Lublin 2021
Machine Translated by Google
1. Project description
The project involves preparing a database that imitates the functionality and capabilities of the
Netflix streaming platform. Netflix has been around for many years and is popular in many countries
western countries, including Poland. For a monthly fee, the service allows you to watch any
number of films and series available on the platform. In the service, we create a user account, but
it is divided into profiles. Each profile can have its own name and profile photo, the pool of
which is defined in the database. Each profile also has its own video viewing history and
series generated based on current viewing and the list of works you want to watch.
The profile can return to watching a given production from the point at which it previously
stopped watching. Each user can also be assigned a preferred language in which the interface
should be displayed.
The user can use the platform on many devices, the types of which are listed in the dictionary
table. Each device is saved as a device type, its IP address and login region. The user can also
connect several payment methods for subscriptions -
subscription types are listed in the appropriate table. You can pay by gift card and credit
card.
Movies and series are in separate tables, with the series connected to the "Episode" table, which
lists all episodes of the series, including their titles, covers, types and access paths. Films
constitute one whole and they are also characterized by fields such as title, type or place of
production. We can sort films based on their country of origin and the actors appearing in
them. Actors can appear in many productions, so you can even search for movies or series by
their names. Movies and series also have their own age categories.
The entity relationship diagram was prepared in the Visual Paradigm environment. Selected engine
the database is PostgreSQL, and management is possible using dedicated pgAdmin 4
software. The whole thing runs on a computer with the GNU/Linux Pop!_OS 20.10 operating
system.
Machine Translated by Google
3. Description of tables
payments made
actor genre
region
cou episode
a user_
g
profile_is_w
w
a
film
a
series_w
N
actor N:1 X M: XXXXXXXXX
N
genre N: X M: XXXXXXXXX
M N
film X N: N: N: M:NXX 1:NX 1:1 XXX
M M 1
region
p
profile_
gift_card p
la
credit_ device_
user_
hotos
p
p
Field name Field type Is the field required? Is there value Description
unique?
id_user total SO SO Internal user
ID
required? Is
unique?
id_user_ total SO SO ID
Machine Translated by Google
profile user
profile
nickname character SO NO A string of
(max. 45) characters
specifying the profile name
profile_photosid total SO NO An identifier
that refers to
the profile
picture of
the profile
userid total SO NO An identifier
relating to the
user in question
profile
is_adult binary SO NO A sign
indicating whether
the profile
user is an
adult
languagesid total SO NO An identifier
relating to
the
language assigned to
profile
Film_wanted_to_watchid total NO NO An identifier
relating to
the list of
movies to watch
Series_wanted_to_watchid caÿkowity NO NO An identifier
relating to
the list of
series to watch
is it unique?
Id_session total SO SO Session ID
relating to a
given film
date time sign SO NO A
date specifying the time
start watching
required? Is
unique?
id_Movie total SO SO Video ID
the platform
required? Is
unique?
Id_credit_card total SO SO Internal
Machine Translated by Google
identyfikator
credit_card
Card_number Character (max. 16) SO SO A
string
specifying the card number
Cvc Character(max. 3) SO SO
Specifying string
CVC number
of a given card
Expiration_date Character(max. 5) SO SO A
string
specifying
the card's expiration date
Owner_name Characteristic SO SO A
(max. 255) string specifying the name
the person to whom
the card belongs
Owner_lastname Characteristic SO SO A
(max. 255) string
specifying the person's name
to which it belongs
can
required? Is
unique?
Id_payment_method integer SO SO Internal
identifier
payment_metho
d
Credit_cardid total SO SO An
integer that
assigns a given
credit
card to the
payment method
Gift_cardid total NO SO An
integer that
assigns a given
gift card
to the payment
method
required? Is
unique?
Machine Translated by Google
required? Is
unique?
Id_payment_plans total SO SO Internal
identifier
payment_plans
name Characteristic SO SO A string
(max.45) specifying
the name of the plan
price total SO SO An
integer
specifying the price
plan
required? Is
unique?
Id_gift_card total SO SO Internal
identifier
gift_card
code Character(max.15) SO SO A string
specifying the
gift
card code
Machine Translated by Google
Field Name Field Type Whether the field existsIs the value unique? Description
required?
Id_serie int4 so so Internal
ID
client
title Varchar So NO String of characters
(100) defining
title of the movie
required? unique?
id_episode int4 So So Internal
ID
episode
episode_title Varchar(100) So NO String of characters
specifying the title
episode
season int4 so so Number
determining
season until
describing
episode
path Varchar(100) So So String of characters
determining
file path
episode
number_of_episode int4 So NO Number
determining
episode number
serieid int4 So NO Number
whole
being the key
alien. Refers
to the table
series
required? Is
unique?
required? Is
unique?
Id_device_type int4 SO SO Internal
ID
device type
Device_type_name Varchar(255) SO NO Type description
devices
Machine Translated by Google
is it unique?
The database was installed on the GNU/ Linux Pop!_OS 20.10 system using the pgAdmin 4 graphical
user interface tool.
First we need to install the database engine. The fastest and most universal way is to use the
terminal. Launch the terminal and enter the command sudo apt install postgresql.
Then install the pgAdmin 4 tool. You can also enter the appropriate commands. First, we add the
repository and then run the installation. The commands look like this:
pgadmin4 main" > / etc/ apt/ sources.list.d/ pgadmin4.list && apt update'
sudo apt install pgadmin4
At this point you can go to the pgAdmin 4 tool. The application should automatically establish a
connection to the server. If not, you must manually enter the established username and
password. After a while, a notification should appear informing you about the connection.
Machine Translated by Google
From the tree on the left, select "Databases" and select "Create -> Database".
name the database "Netflix".
Then you need to expand the branch with the new database and move to the public schema.
Here, right-click and select "Query Tool". The command line will start. You need to paste the SQL
code that creates the entire database structure. After a while, all tables with relationships
should be created. You can also use the "Generate ERD" option to preview the entity relationship diagram.
Machine Translated by Google
Then you need to use the previously opened "Query Tool" to enter data into the tables.
The appropriate order of addition is given below.
Machine Translated by Google
CREATE TABLE film (id_Film int4 NOT NULL, title varchar(100) NOT NULL, how_long int4
NOT NULL, poster varchar(100) NOT NULL, production_year date NOT NULL, path_to_file
varchar(100) NOT NULL UNIQUE, age_categoryid int4 NOT NULL, about varchar(500) NOT
NULL, add_time timestamp NOT NULL, PRIMARY KEY (id_Film));
CREATE TABLE genre (id_genre int4 NOT NULL, genre_name varchar(80) NOT NULL,
PRIMARY KEY (id_genre));
CREATE TABLE genre_movie(genreid int4 NOT NULL, MovieId int4 NOT NULL, genreMovie_id
int4 NOT NULL, PRIMARY KEY(genreid, MovieId, genreMovie_id));
CREATE TABLE age_category (id_age_category int4 NOT NULL, name varchar(80) NOT NULL,
PRIMARY KEY (id_age_category));
CREATE TABLE country (id_country int4 NOT NULL, country_name varchar(80) NOT NULL,
PRIMARY KEY (id_country));
CREATE TABLE film_country (Filmid int4 NOT NULL, countryid int4 NOT NULL,
id_filmCountry int4 NOT NULL, PRIMARY KEY (Filmid, countryid, id_filmCountry));
CREATE TABLE serie (id_serie int4 NOT NULL, title varchar(100) NOT NULL, poster
varchar(100) NOT NULL, production_year int4 NOT NULL, age_category int4 NOT NULL,
season_number int4 NOT NULL, adding_date date NOT NULL, PRIMARY KEY (id_serie));
CREATE TABLE series_genre(seriesid int4 NOT NULL, genreid int4 NOT NULL, series_idGenre
int4 NOT NULL, PRIMARY KEY(seriesid, genreid, series_idGenre));
CREATE TABLE serie_productionCountry (serieid int4 NOT NULL, countryid int4 NOT NULL,
id_serie_productionCountry int4 NOT NULL, PRIMARY KEY (serieid, countryid,
id_serie_productionCountry));
CREATE TABLE episode (id_episode int4 NOT NULL, episode_title varchar(100) NOT NULL,
season int4 NOT NULL, about varchar(500) NOT NULL, path varchar(100) NOT NULL UNIQUE,
number_of_episode int4 NOT NULL, serieid int4 NOT NULL, how_long int4 NOT NULL,
PRIMARY KEY (id_episode));
CREATE TABLE actor (id_actor int4 NOT NULL, name varchar(100) NOT NULL, lastname
varchar(100) NOT NULL, photo_path varchar(100) NOT NULL UNIQUE, PRIMARY KEY
(id_actor));
CREATE TABLE actor_Movie ( actorid int4 NOT NULL , Movieid int4 NOT NULL , actor_id Movie int4
NOT NULL, PRIMARY KEY (actors, Movies, id_actorFilm));
CREATE TABLE actor_series ( actorid int4 NOT NULL , seriesid int4 NOT NULL , actor_id_Series int4
NOT NULL, PRIMARY KEY (actorid, serieid, id_actorSerie));
CREATE TABLE "user" (id_user int4 NOT NULL, nick varchar(50) NOT NULL UNIQUE,
hash_passwd varchar(255) NOT NULL, salt varchar(255) NOT NULL, "e-mail" varchar(150) NOT
NULL UNIQUE, age date NOT NULL, countryid int4 NOT NULL, phone_number varchar(12),
PRIMARY KEY (id_user));
Machine Translated by Google
CREATE TABLE credit_card (id_credit_card int4 NOT NULL, card_number varchar(16) NOT
NULL, cvc varchar(3) NOT NULL, expiration_date varchar(5) NOT NULL, owner_name
varchar(255) NOT NULL, owner_lastname varchar(255) NOT NULL, PRIMARY KEY
(id_credit_card));
CREATE TABLE user_profiles (id_user_profile int8 NOT NULL, nickname varchar(45) NOT
NULL, profile_photosid int4 NOT NULL, Uzytkownikid int4 NOT NULL, is_adult bytea NOT
NULL, Languagesid int4 NOT NULL, FIlm_Wanted_to_watchid int4, Series_wanted_to_watchid
int4, PRIMARY KEY (id_user_profile));
CREATE TABLE profile_photos (id_profile_photos int4 NOT NULL, photo varchar(100) NOT
NULL, PRIMARY KEY (id_profile_photos));
CREATE TABLE profile_is_watching (id_session int4 NOT NULL, User_profilesid int8 NOT
NULL, Episode_serieid int4, Filmid int4, "date" timestamp NOT NULL, PRIMARY KEY
(id_session));
CREATE TABLE languages (id_languages int4 NOT NULL, language varchar(50) NOT NULL,
PRIMARY KEY (id_languages));
CREATE TABLE payment_plans (id_payment_plans int4 NOT NULL, name varchar(45) NOT
NULL, price int4 NOT NULL, PRIMARY KEY (id_payment_plans));
CREATE TABLE gift_card (id_gift_card int4 NOT NULL, code varchar(15) NOT NULL,
PRIMARY KEY (id_gift_card));
CREATE TABLE payment (id_payment int4 NOT NULL, payment_date timestamp NOT NULL,
payment_methodid int4 NOT NULL, payment_plansid int4 NOT NULL, PRIMARY KEY
(id_payment));
CREATE TABLE payment_method (id_payment_method int4 NOT NULL, credit_cardid int4 NOT
NULL, gift_cardid int4, PRIMARY KEY (id_payment_method));
CREATE TABLE user_payment_method (Userid int4 NOT NULL, payment_methodid int4 NOT
NULL, id_userPaymentMethod int4 NOT NULL, PRIMARY KEY (Userid, payment_methodid,
id_userPaymentMethod));
CREATE TABLE device (id_device int4 NOT NULL, device_name varchar(255) NOT NULL,
ip_address varchar(20) NOT NULL, device_typeid int4 NOT NULL, Regionid int4 NOT NULL,
PRIMARY KEY (id_device));
CREATE TABLE device_user (Deviceid int4 NOT NULL, userid int4 NOT NULL, id_device_user
int4 NOT NULL, last_used timestamp NOT NULL, PRIMARY KEY (Deviceid, userid,
id_device_user));
CREATE TABLE Region (id_region int4 NOT NULL, name varchar(255) NOT NULL, countryid
int4 NOT NULL, PRIMARY KEY (id_region));
1. age_category
2. country
3. device_type
4. series
5. gift_card
6. languages
Machine Translated by Google
7. payment_plans
8. episode
Machine Translated by Google
INSERT INTO
public.episode(episode_title,season,about,path,number_of_episode,serieid,how_long,FIELD8)
VALUES ('Freelancer (No. 145)',1,'Liz and Red track down a murderer who fakes disasters to cover
up his murders. The Department of Justice tries hard to understand Red's
motives.','series\blacklist\blacklistS1E2.mkv',2 ,1,40,NULL);
INSERT INTO
public.episode(episode_title,season,about,path,number_of_episode,serieid,how_long,FIELD8)
VALUES ('Wuijing(No. 84)',1,'Liz and Red go incognito to neutralize an assassin
decimating the ranks of CIA agents. Tom asks Liz about the man who attacked him.','series\
blacklist\blacklistS1E3.mkv',3,1,42,NULL);
INSERT INTO
public.episode(episode_title,season,about,path,number_of_episode,serieid,how_long,FIELD8)
VALUES ('Pilot',1,'A high school chemistry teacher learns that he has terminal lung cancer. To provide
for his family, he turns to producing and distributing methamphetamine.','series\
breaking bad\sezon1\breakingbadS1E1.mkv',1,2,58,NULL);
INSERT INTO
public.episode(episode_title,season,about,path,number_of_episode,serieid,how_long,FIELD8)
VALUES ('Bird in a Cage',1,'After their first failed deal, Walt and Jesse have to get rid of two dead
bodies. Meanwhile, Skyler suspects that her husband is up to something.','series\breaking bad\season 1\
breakingbadS1E2.mkv',2,2,48,NULL);
INSERT INTO
public.episode(episode_title,season,about,path,number_of_episode,serieid,how_long,FIELD8)
VALUES ('Chapter 1',1,'When the newly elected president does not keep his promise, Frank and
Claire decide to forget about loyalty and all rules.','series\house of cards\season 1\
houseofcardsS1E1.mkv',1,3,NULL,NULL);
INSERT INTO
public.episode(episode_title,season,about,path,number_of_episode,serieid,how_long,FIELD8)
VALUES ('Chapter 2',1,'With the help of a young journalist, Zoe Barnes, Frank publicizes a case that
causes a stir in the White House. Claire makes drastic cuts to the foundation.','series\
houseofcardsS1E1\season1\houseofcardsS1E2.mkv',2,3,49,NULL);
INSERT INTO
public.episode(episode_title,season,about,path,number_of_episode,serieid,how_long,FIELD8)
VALUES ('Let's go!',2,'The new Formula 1 season opens with the Australian Grand Prix. Ten teams
are fiercely competing for a place on the podium.','series\formula1\season2\
formula1S2E1.mkv',1,4,33,NULL);
INSERT INTO
public.episode(episode_title,season,about,path,number_of_episode,serieid,how_long,FIELD8)
VALUES ('Grace',1,'A Saudi prince is probably financing terrorist activities, and an undercover agent
working in his entourage provides Carrie with evidence confirming this.','series\
homeland\sezon1\homelandS1E1.mkv',1,5,55,NULL);
INSERT INTO
public.episode(episode_title,season,about,path,number_of_episode,serieid,how_long,FIELD8)
Machine Translated by Google
VALUES ('Baby',1,'Pacey and Tamara's affair is revealed. Bessie giving birth must enlist the
help of Grandma Jen.','seriale\jezioromarzen\season 1\jezioromarzen.mkv',1,6,42,NULL);
INSERT INTO
public.episode(episode_title,season,about,path,number_of_episode,serieid,how_long,FIELD8)
VALUES ('Are they sharks?',1,'The girls find out that sea turtles get caught in fishermen's nets. Rikki
and Emma rush to help, which makes the fishermen think that they are being attacked by sharks.','series\
h2o\sezon1\h2oS1E3.mkv',3,7,25,NULL);
INSERT INTO
public.episode(episode_title,season,about,path,number_of_episode,serieid,how_long,FIELD8)
VALUES ('Pups save the blimp/Pups save the cooking competition',1,'Mayor Humdinger thinks
that the airship affects the weather, so he decides to hijack it. Adventure Bay and Misty Village compete
in a cooking show.','series\psipatrol\season1\psipatrolS1E1',1,8,23,NULL);
INSERT INTO
public.episode(episode_title,season,about,path,number_of_episode,serieid,how_long,FIELD8)
VALUES ('Episode 6',1,'Thomas prepares to remove Kimber from power, but family secrets that
come to light and an obsessed Campbell may stand in his way.','series\peakyblinders\season
1\peakyblindersS1E6', 6,9,54,NULL);
INSERT INTO
public.episode(episode_title,season,about,path,number_of_episode,serieid,how_long,FIELD8)
VALUES ('Chapter Twenty-Three: The School Jungle',1,'When students from Southside School transfer
to Riverdale High, a cultural conflict breaks out. The FBI talks to Archie.
Betty searches for her long-lost brother.','series\riverdale\season 1\
riverdaleS1E10',10,10,42,NULL);
9. region
10. profile_photos
11. Device
Machine Translated by Google
12. genre
13. Film
INSERT INTO
public.film(title,how_long,poster,production_year,path_to_file,age_categoryid,about,add_time)
VALUES ('Kingsman: The
Secret Service',130,'/posters/filmy/kingsman.jpg','2014-05-17','/filmy/kingsman2014.nfv','2','British-
American spy film' ,'2015-05-14 16:30:00');
INSERT INTO
public.film(title,how_long,poster,production_year,path_to_file,age_categoryid,about,add_time)
VALUES ('Avengers:
Endgame',182,'/posters/filmy/avengers.jpg','2019-07-26','/filmy/avengersEndgame.nfv','4','American
science fiction action film from 2019 year based on a series of comic books about a
group of superheroes','2019-06-25 19:30:00');
INSERT INTO
public.film(title,how_long,poster,production_year,path_to_file,age_categoryid,about,add_time)
VALUES ('X-Men: Dark
Phoenix',114,'/posters/filmy/phoenix.jpg','2019-08-10','/filmy/phoenix.nfv','3','American science
fiction action film based on a series of comic books about a group of superheroes','2019-08-
20 18:00:01');
INSERT INTO
public.film(title,how_long,poster,production_year,path_to_file,age_categoryid,about,add_time)
VALUES ('Star Wars: Episode II – Attack of the Clones',142,'/plakaty/filmy/atakklonow.jpg','2002-02-
10','/filmy/atakklonow.nfv','5','chronologically the second part of the Star Wars saga','2014-11-14
15:25:00');
Machine Translated by Google
INSERT INTO
public.film(title,how_long,poster,production_year,path_to_file,age_categoryid,about,add_time)
VALUES ('Star Wars: Episode I - The Phantom
Menace',136,'/plakaty/filmy/mzdrowiewidmo.jpg','1999-12-06','/filmy/
shadowmena.nfv','3','chronologically the first part of the Star Wars saga','2014-10-26 16:45:10');
INSERT INTO
public.film(title,how_long,poster,production_year,path_to_file,age_categoryid,about,add_time)
VALUES ('Niezgoda',139,'/plakaty/filmy/niezgoda.jpg','2014-05-18','/filmy/
incongruent.nfv','1','American action adventure film with elements of sociological
fantasy','2018-08-19 18:30:00');
INSERT INTO
public.film(title,how_long,poster,production_year,path_to_file,age_categoryid,about,add_time)
VALUES ('Maze Runner',113,'/plakaty/filmy/labirynt.jpg','2014-05-11','/filmy/
labirynt.nfv','4','American science fiction film directed by Wes Ball','2018-
09-23 20:05:00');
INSERT INTO
public.film(title,how_long,poster,production_year,path_to_file,age_categoryid,about,add_time)
VALUES ('Maze Runner: The Death
Cure',143,'/plakaty/filmy/labirynt_lek.jpg','2018-09-04','/filmy/labirynt_lek.nfv','2','American science fiction
film from 2018 directed by Wes Ball','2021-05-03 20:30:00');
INSERT INTO
public.film(title,how_long,poster,production_year,path_to_file,age_categoryid,about,add_time)
VALUES ('The Unbreakables',332,'/plakaty/niepowiedzalni.jpg','2010-04-22','/filmy/
indestructible.nfv','1','The Expendables is an American action thriller series','2013-05-12 15:45:00');
INSERT INTO
public.film(title,how_long,poster,production_year,path_to_file,age_categoryid,about,add_time)
VALUES ('Men in Black',98,'/plakaty/filmy/faceciwczerni.jpg','1997-09-20','/filmy/
faceciwczerni.nfv','2','Men in Black is a series of American science fiction action comedies','2012-06-
18 20:30:05');
14. serie_genre
15. genre_film
16. actor
Machine Translated by Google
17. actor_film
18. series_actor
19. user
Machine Translated by Google
20. serie_productioncountry
Machine Translated by Google
21. device_user
22. credit_card
23. film_wanted_to_watch
Machine Translated by Google
24. series_wanted_to_watch
25. payment_method
26. payment
27. user_profiles
INSERT INTO
public.user_profiles(nickname,profile_photosid,uzytkownikid,is_adult,Languagesid,FIlm_Wanted_t
o_watchid,Series_wanted_to_watchid) VALUES ('Rollermix',1,1,'\000',1,1,NULL);
INSERT INTO
public.user_profiles(nickname,profile_photosid,uzytkownikid,is_adult,Languagesid,FIlm_Wanted_t
o_watchid,Series_wanted_to_watchid) VALUES ('Durszlak',2,2,'\000',2,NULL,NULL);
INSERT INTO
public.user_profiles(nickname,profile_photosid,uzytkownikid,is_adult,Languagesid,FIlm_Wanted_t
o_watchid,Series_wanted_to_watchid) VALUES ('Krokiet',3,3,'\000',3,NULL,1);
Machine Translated by Google
INSERT INTO
public.user_profiles(nickname,profile_photosid,uzytkownikid,is_adult,Languagesid,FIlm_Wanted_t
o_watchid,Series_wanted_to_watchid) VALUES ('Ruen',3,4,'\000',1,NULL,NULL);
INSERT INTO
public.user_profiles(nickname,profile_photosid,uzytkownikid,is_adult,Languagesid,FIlm_Wanted_t
o_watchid,Series_wanted_to_watchid) VALUES ('Elwi',4,5,'\000',1,2,NULL);
INSERT INTO
public.user_profiles(nickname,profile_photosid,uzytkownikid,is_adult,Languagesid,FIlm_Wanted_t
o_watchid,Series_wanted_to_watchid) VALUES ('Vdr1984',5,6,'\000',1,NULL,NULL);
INSERT INTO
public.user_profiles(nickname,profile_photosid,uzytkownikid,is_adult,Languagesid,FIlm_Wanted_t
o_watchid,Series_wanted_to_watchid) VALUES ('Hallack',6,7,'\001',1,NULL,NULL);
INSERT INTO
public.user_profiles(nickname,profile_photosid,uzytkownikid,is_adult,Languagesid,FIlm_Wanted_t
o_watchid,Series_wanted_to_watchid) VALUES ('Multi',8,2,'\001',1,3,NULL);
INSERT INTO
public.user_profiles(nickname,profile_photosid,uzytkownikid,is_adult,Languagesid,FIlm_Wanted_t
o_watchid,Series_wanted_to_watchid) VALUES ('Skillplease',1,2,'\001',1,NULL,NULL);
INSERT INTO
public.user_profiles(nickname,profile_photosid,uzytkownikid,is_adult,Languagesid,FIlm_Wanted_t
o_watchid,Series_wanted_to_watchid) VALUES ('Prysio',2,1,'\001',1,NULL,NULL);
28. profile_is_watching
29. watching_history
30. serie_series_wanted_to_watch
31. film_film_wanted_to_watch
Machine Translated by Google
32. film_country
33. user_payment_method