0% found this document useful (0 votes)
13 views

Lab 1 - SQL Commands and Database Sequences

Lab 1 - SQL Commands and Database Sequences

Uploaded by

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

Lab 1 - SQL Commands and Database Sequences

Lab 1 - SQL Commands and Database Sequences

Uploaded by

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

Student Name: Weight: 1.

25%

Student ID: Marks: /34

Lab: SQL Commands and Database Sequences and


Views
Equipment and Materials
For this lab, you will need:
 A Windows computer with a minimum of 16 GB RAM and 250 GB of free disk space,
capable of nested virtualization
 Access to ORACLE SQL*PLUS
 The More Movies database
Note: Execute the Create_MM.sql script file, located in the Course Resources section
of Brightspace in zipped folder named More Movies.
 A CPRG 307 user account (see instructions below)

Instructions
Part A: Complete the Pre-Lab Tasks
1. Attend the lectures related to the lab activities.
2. Complete the out-of-class learning activities, as indicated by your instructor.
3. Download and review the More Movies database.
4. Create a CPRG 307 user account.
a. Execute the Create_CPRG307_Users.sql script located in the Course Resources
section of Brightspace.
b. Ensure that you log into the database as the user SYS (SYS as sysdba).
This script creates two new users with specific privileges you will be using in the labs
for this course.
Notes:
 You don’t need to understand the code in this script.
 If you see errors when executing the script, ask your instructor for guidance.
 If you need to remove the users, execute Drop_CPRG307_Users.sql script in
the Course Resources section of Brightspace.
 This step does not need to be presented in your discussion board post.
5. Create the More Movies database tables in your database.

© 2023, Southern Alberta Institute of Technology 1


a. Log into the database using SQL*Plus as user CPRG307 with the
password: password.
b. Execute the script Create_MM.sql (e.g., @c:\cprg307\Create_MM.sql). Do not copy
and paste.
Notes:
 For this lab, it is recommended that you use SQL*Plus, rather than SQL
Developer, to remind you how to execute a file.
 You can use SQL Developer in this course if you wish.
 This step does not need to be presented in your discussion board post.
6. Review the Restrictions and Marking Criteria sections below.
7. See Brightspace for the lab due date.
8. Submit your solution in the Discussion Board, copy and paste your solution, not attach.

Part B: Complete the Lab Tasks


1. Display the structure of the MM_MEMBER table. (2 marks)
2. Add yourself as a member. (2 marks)
Hint: Only populate the first three columns.
3. Modify your membership by adding a made-up credit card number. Do not use your real-
life credit card number. (2 marks)
Hint: There is a check constraint on this column.
4. Remove your membership. (2 marks)
5. Save your data changes. (2 marks)
6. Display the title of each movie, the rental ID and the last names of all members who have
rented those movies. (2 marks)
a. Sort the result set by the rental ID.
b. Ensure that no other information appears.
c. Use three tables for this query: MM_MEMBER, MM_MOVIE and MM_RENTAL.
Restriction: Solve using JOIN…ON as your join method.
7. Display the title of each movie, the rental ID, and the last names of all members who have
rented those movies. (2 marks)
a. No other information should appear.
b. Use three tables for this query: MM_MEMBER, MM_MOVIE and MM_RENTAL.
Restriction: Solve using the traditional join method, where join is in the WHERE clause.

© 2023, Southern Alberta Institute of Technology 2


8. Create a new table called MY_TABLE that is made up of three columns: MY_NUMBER,
MY_DATE and MY_STRING, and that have data types: NUMBER, DATE and
VARCHAR2(5), respectively. (2 marks)
9. Create a new sequence called seq_movie_id. Have the sequence start at 20 and
increment by 2. (2 marks)
10. Display the sequence information (at least the last number and increment by) from the data
dictionary’s user_sequences view.
Note: Your output should only show this one sequence.
11. Use a query to display the next sequence number on the screen. (2 marks)
12. Change the sequence created in Step 9 to increment by 5 instead of 2. (2 marks)
13. Add your favorite movie to the MM_MOVIE table using the sequence created in Step 9 for
the movie_id. (2 marks)
Notes:
 You can create values for the other columns (all columns must be given a value).
 MM_MOVIE has a foreign key, which means any value placed in this column must
already exist as primary key value in the table being referenced.
 MM_MOVIE has a check constraint.
14. Create a view named VW_MOVIE_RENTAL using the query from either Step 6 or Step 7.
(2 marks)
15. Use a query to display the data accessed by the VW_MOVIE_RENTAL view. (2 marks)
16. Make the VW_MOVIE_RENTAL view read only. (2 marks)
17. Using the VW_MOVIE_RENTAL view in Step 14, change the last name of the member
who rented the movie with the ID of 2 to Tangier 1. (2 marks)
18. Submit your completed test plan to Brightspace by the due date.

Part C: Complete the Post-Lab Tasks


1. Compare your posted solution to the solution posted by your instructor.
2. Talk with your instructor if you are unsure why there are differences between the solutions.

© 2023, Southern Alberta Institute of Technology 3

You might also like