Skip to content

This project was my 3rd Homework for the course CMPE 321 (Introduction to Database Systems) at Bogazici University.

License

Notifications You must be signed in to change notification settings

volcaniqueo/Complete_Database_Application

Repository files navigation

Cmpe321-Project3

MovieDB System
This tutorial assumes you are in a MacOS environment. Similar procedure applies to Linux/Windows with equivalent commands.

Install postgresql@14 and run default server

First, one should install and start postgresql in the local environment
Install postgresql@14 with command:
$ brew install postgresql@14
Insert this line to your .zshrc file:
"export PATH="/usr/local/opt/postgresql@14/bin:$PATH"

Make sure the server is started by running:
$ brew services start postgresql@14
Then open the database with:
$ sudo psql -U postgres postgres

If user postgres does not exist, run:
$ /usr/local/opt/postgresql@14/bin/createuser -s postgres
Then open the database.

Then execute \conninfo. The result should be:
"You are connected to database "postgres" as user "postgres" via socket in "/tmp" at port "5432"."

Create new database and tables for the app

WE NOW ASSUME THAT SERVER IS CONNECTED TO THE PORT "5432", IF NOT MODIFY "port=5432" VARIABLE.
(All possible files to be modified for this case are the same as in the case you want to change the password.)
(The procedures for changing the password are explained below.)

We use psycopg module in order to connect to postgresql database.
Please check if module is already installed, if not run:
$ pip3 install psycopg

If postgresql was installed previously and password for the user "postgres" was set by the user, open db.py file and make these changes:
At lines 4 and 15, modify password=<user_password> in the psycopg.connect() function.
Default is as followed:
conn = psycopg.connect(host="localhost", port=5432, user="postgres", password="")
conn = psycopg.connect(host="localhost", port=5432, user="postgres", password="", dbname="moviedb")

Also make sure that postgre.sql file is in the same directory with the db.py file

Finally, to create a new database called "MovieDB" and create the tables, triggers for our schema; run:
$ python3 db.py

Import the data to the database

This part assumes that our data would be in the same format as in the Project1.
If postgresql was installed previously and password for the user "postgres" was set by the user, open read_data.py file and make these changes:
At line 10 modify password=<your_password>
Default is as followed:
conn = psycopg.connect(host="127.0.0.1", port="5432", dbname="moviedb", user="postgres", password="")

Now, in order to import to database run:
$ python3 read_data.py

Run the Django application

If postgresql was installed previously and password for the user "postgres" was set by the user, go to the directory "movie_site/movie_site" with the command:
$ cd movie_site/movie_site
Open the settings.py file and modify the password of default database in the DATABASE variable, at line 83.
Default is as followed:
DATABASES = { "default": { "ENGINE": "django.db.backends.postgresql", "NAME": "moviedb", "USER": "postgres", "PASSWORD": "", "HOST": "127.0.0.1", "PORT": "5432", } }
(If you modified the password in the "movie_site/movie_site/settings.py" file just go to the outer directory with $ cd ../..)

In order to run the server go to the directory "movie_site/" by command:
$ cd movie_site
And run the command:
$ python3 manage.py runserver

To see the app, open the browser and go to "http://127.0.0.1:8000/movie_app" and enjoy.

Additional Notes

Storage of the Time in the Database:

Due to a bug in the read_data.py file, time1 column in the occupience_info relation stored as follows: "time 00:00:00" (e.g. 2023-03-15 00:00:00) Since we handled this in backend, this DOES NOT AFFECT UI. Users can still write input and view output as (e.g. 2023-03-15) whenever needed.

About View Operations in UI:

For view operations of database manager and director user types, we put all operations into one page for these user types. In the dropdown table (select tag) there exists also string R<operation_number> which refers to requirement <operation_number> from project description. Since two views of audience user type are in separate pages we didn't specify the operation number because the names are explicit enough. Lastly, all other operations are also in separate pages with explicit naming conventions.

About ORM (Object Relational Modeling):

A better implementation would include the ORM feature of Django, but we are NOT permitted to use it, according to the project description.

About

This project was my 3rd Homework for the course CMPE 321 (Introduction to Database Systems) at Bogazici University.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published