catherine0422 / MovieDatabase

Porject of the database management course
0 stars 0 forks source link

Movie database

Introduction

This is a sql project that manages a movie database.

Requirement

Installation

  1. Download the IMDB reduced dataset and extract the folder into our root path, the fold should be named as imdb-reduced.

  2. Create a file named logfile in the log folder.

For Linux User

  1. In the root path, initialize a Postgres disk area:

    initdb -D ./data -E UTF8
  2. Launch the postgreSQL server:

    pg_ctl -D ./data -l ./log/logfile start
  3. PostgreSQL create automatically a role with your user name on your operating system. We note it \$USER. Then we connect to the server using this role name.

    psql -U $USER -d postgres

For Windows User

  1. Make sure you have set the variable DATAPath with the path of the folder data (resp. LOGPath with the path of the folder log) in the PATH. Also there must be a PSQLPath pointing to C:\Program Files\PostgreSQL\12\bin if you install PostgreSQL in the default path.

  2. In the root path, initialize a Postgres disk area using PowerShell:

& "$env:PSQLPath\initdb" -D $env:DATAPath -E UTF8
  1. Launch the postgreSQL server:
& "$env:PSQLPath\pg_ctl" -D $env:DATAPath -l "$env:LOGPath\logfile" start

if it fails. Try kill the process which occupies port 5432 (cf StackOverflow) in cmd running as Administator.

netstat -ano | findstr :5432
taskkill /PID <PID> /F
  1. PostgreSQL create automatically a role with your user name on your operating system. We note it \$USER. Then we connect to the server using this role name.
psql -U $env:UserName -d postgres
  1. To delete all the tables and contents. (cf StackOverflow)
DROP SCHEMA public CASCADE;
CREATE SCHEMA public;
GRANT ALL ON SCHEMA public TO public;

Create DataBase

postgres=# \i create.sql
postgres=# \o drop_command.sql
postgres=# \i hack_drop.sql
postgres=# \o

Then remove the redundant lines in drop_command.sql.

postgres=# \o add_command.sql
postgres=# \i hack_create.sql
postgres=# \o

Then remove the redundant lines in add_command.sql.

postgres=# \i drop_command.sql

Change the path correctly in your copy_for_loop.sql, Then copy the data in csv file into database.

postgres=# \i copy_for_loop.sql

Add constraints.

postgres=# \i add_command.sql

Execute the queries.

postgres=# \i query.sql

Update the database.

postgres=# \i up.sql

To remove the change.

postgres=# \i down.sql

Web application

  1. Start the db pg_ctl start -D ./data -l ./log/logFile.txt
  2. Start the servlet.
  3. Go to the page 'http://localhost:8080/inf553-web/QueryServlet' in the browser.