0% found this document useful (0 votes)
35 views2 pages

HI5033-Tutorial 6

The document discusses developing ER diagrams and translating them to SQL statements. It describes a scenario of a DVD rental business and tasks to create tables for movies, videos, rentals, memberships and prices with attributes, ER diagram, data types and SQL statements.

Uploaded by

deyepiw524
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views2 pages

HI5033-Tutorial 6

The document discusses developing ER diagrams and translating them to SQL statements. It describes a scenario of a DVD rental business and tasks to create tables for movies, videos, rentals, memberships and prices with attributes, ER diagram, data types and SQL statements.

Uploaded by

deyepiw524
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

HI5033 Database Systems - Tutorial 6

In this tutorial we will get some further experience in developing ER diagrams, and then translate
these to SQL DDL Statements.

Consider the following brief scenario

EliteVideo is a startup company providing concierge DVD kiosk service in upscale


neighbourhoods. EliteVideo can own several copies (VIDEO) of each movie (MOVIE). For
example, a kiosk may have 10 copies of the movie Twist in the Wind. In the database, Twist in the
Wind would be one MOVIE, and each copy would be a VIDEO. A rental transaction (RENTAL)
involves one or more videos being rented to a member (MEMBERSHIP). A video can be rented
many times over its lifetime; therefore, there is an M:N relationship between RENTAL and VIDEO.
(DETAILRENTAL) is the bridge table to resolve this relationship. The pricing structure is such that
there are a number of price categories, such as 'Overnight', '2 Day Rental', '3 Day Rental', 'Weekly'
etc. The cost of renting each MOVIE will fall into one of these (PRICE) categories.

Task 1

List the attributes you would expect to find in each of the tables mentioned above

Task 2

Create an ER Diagram for the above Database tables

Task 3

Review the PostgreSQL Data types from the PostgreSQL Data Tupe documentation. This
can be found online at

https://www.postgresql.org/docs/9.5/datatype.html

Determine a datatype for each of the attribute fields identified in Task 1

Task 4

Review the PostgreSQL documentation on Table Basics, Default Values and Constraints.
This can be located online at

1
https://www.postgresql.org/docs/9.5/ddl.html

Once you do this write the SQL DDL Statements to create the above tables we identified in
Task 1 and refined in Task 2 above. Making sure to identify all the primary and foreign keys.

Task 5

In PostgreSQL and DBeaver, create the new database (call it MovieDB, prefixed by your
Student ID number), as we did in the first tutorial, and create a new DBeaver connection to
this new database.

Create the new tables in the database by running the SQL DDL statements you created in
Task 4 as scripts in the new database. You will need to fix any errors in the SQL statements
as they appear.

You might also like