首页 > > 详细

INFS2200编程辅导、辅导SQL程序讲解

INFS2200/7903 PROJECT ASSIGNMENT
Semester Two 2021
Total marks: 100 marks (25%)
Due Date: 11:59PM, 28 October 2021
What to Submit: SQL script file + short report
Where to Submit: Electronic submission via Blackboard
The goal of this project is to gain practical experience in applying several database
management concepts and techniques using the Oracle DBMS.
Your main task is to first populate your database with appropriate data, then design,
implement, and test the appropriate queries to perform the tasks explained in the next
sections.
You must work on this project individually. Academic integrity policies apply. Please
refer to 3.60.04 Student Integrity and Misconduct of the University Policy for more
information.
Roadmap: Section 1 describes the database schema for your project and it also
provides instructions on downloading the script file needed to create and populate your
database. Section 2 describes the tasks to be completed for this project. Finally,
Section 3 provides you with all the necessary submission guidelines.
Enjoy the project!
-----------------
SECTION 1. THE MOVIES DATABASE
The Database: The MOVIES database (Figure 1) captures the information regarding
movies and the actors in these movies. The database includes six tables: film, actor,
category, language, film_actor, and film_category. Film keeps track of film details.
Actor stores information about all actors in the movie industry. Category stores the
information about the different types of film categories. Language stores the different
languages in which these movies are released. Film_actor and film_category keep
track of which actors have acted in which films, and which films are classified under
which categories, respectively.
Figure 1 Database schema
The Script File: Please go to Blackboard and download the supplementary script file
for this project “prjScript.sql”.
actor_id
film_id
film_id
title
description
release_year
language_id
original_language_id
rental_duration
rental_rate
length
replacement_cost
rating
special_features
film_id
category_id
language_id
name
category_id
name
actor_id
first_name
last_name
film_category film film_actor
category language
actor
The Database Constraints: The following table lists all the constraints that should be
created on the MOVIES database.
No Constraint Name Table.Column Description
1 PK_ACTORID actor.actor_id actor_id is the primary key of
actor
2 PK_CATEGORYID category.category_id category_id is the primary key
of category
3 PK_FILMID film.film_id film_id is the primary key of film
4 PK_LANGUAGEID language.language_id language_id is the primary key
of language
5 UN_DESCRIPTION film.description Film description values are
unique
6 CK_FNAME actor.first_name Actor’s first name must not be
empty (not null)
7 CK_LNAME actor.last_name Actor’s last name must not be
empty (not null)
8 CK_CATNAME category.name Category name must not be
empty (not null)
9 CK_LANNAME language.name Language name must not be
empty (not null)
10 CK_TITLE film.title Film title must not be empty
(not null)
11 CK_RELEASEYR film.release_year film.release_year is less than or
equal to current year (Hardcode
the current year 2020)
12 CK_RATING film.rating Rating type must be one of the
following: 'G', 'PG', 'PG-13', 'R',
'NC-17'
13 CK_SPLFEATURES film.special_features Special features type must be
either empty or one of the
following: 'Trailers',
'Commentaries', 'Deleted
Scenes', 'Behind the Scenes'
14 FK_LANGUAGEID film.language_id
and language.language_id
film.language_id refers to
language.language_id
15 FK_ORLANGUAGEID film.original_language_id
and language.language_id
film.original_language_id refers
to language.language_id
16 FK_ACTORID film_actor.actor_id and
actor.actor_id
film_actor.actor_id refers to
actor.actor_id
17 FK_CATEGORYID film_category.category_id
and category.category_id
film_category.category_id
refers to category.category_id
18 FK_FILMID1 film_actor.film_id and
film.film_id
film_actor.film_id refers to
film.film_id
19 FK_FILMID2 film_category.film_id and
film.film_id
film_category.film_id refers to
film.film_id
Table 1. Database constraints
-----------------
SECTION 2. ASSIGNMENT TASKS
Create and Populate Database: You need to execute the script file “prjScript.sql” to
create and populate your database before working on the following tasks. Wait till you
see the message “DONE! All data has been inserted.” It should only take one minute.
The script will also drop related tables.
Task 1 – Constraints
1. After running the script file, you will notice that only some of the constraints listed
in Table 1 were created. Write a SQL statement to find out what constraints have
been created on the six tables. (Note: some table names may need to be in capitals,
e.g., ‘FILM’ instead of ‘film’)
Question: Which constraints in Table 1 have been created on these six tables?
2. Write the SQL statements to create all the missing constraints.
Task 2 – Triggers
1. Assume that the film_id should be automatically populated when a new film is
added. Write a SQL statement to create a sequence object to generate values for
this column. The sequence, named FILM_ID_SEQ, should start from 20,010 and
increment by 10.
2. Write a SQL statement to create an Oracle trigger called BI_FILM_ID that binds
the sequence object FILM_ID_SEQ to the film_id column, i.e., the trigger populates
values of FILM_ID_SEQ to the film_id column when a new film is added.
3. Write a SQL statement to create an Oracle trigger BI_FILM_DESP that appends
text to the description of every new film inserted into the database. The text is
based on the rating, the language, and the original language of the film. The format
of the text you append should be as follows (replacing tokens):
-: Originally in . Re-released in .
Here, is the sequence number of the film with that , and

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!