0% found this document useful (0 votes)
27 views8 pages

Ash Oracle

The document describes the creation of tables and sequences to develop a database for a video rental store. It creates tables for members, titles, title copies, rentals, and reservations. It then selects the table names and constraints. Sequences are created for member IDs and title IDs. Data is inserted into the title table and the titles are selected to confirm the inserts.

Uploaded by

ashley beato
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)
27 views8 pages

Ash Oracle

The document describes the creation of tables and sequences to develop a database for a video rental store. It creates tables for members, titles, title copies, rentals, and reservations. It then selects the table names and constraints. Sequences are created for member IDs and title IDs. Data is inserted into the title table and the titles are selected to confirm the inserts.

Uploaded by

ashley beato
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/ 8

Beato, Ashley Raeven F.

/ G12 ICT-B

1.)
A.) CREATE TABLE members
(member_id NUMBER(10) CONSTRAINT members_member_id_pk PRIMARY KEY,
last_name VARCHAR2(25) CONSTRAINT members_last_name_nn NOT NULL,
first_name VARCHAR2(25),
address VARCHAR2(100),
city VARCHAR2(30),
phone VARCHAR2(15),
join_date DATE DEFAULT SYSDATE CONSTRAINT members_join_date_nn NOT NULL);

B.) CREATE TABLE title


(title_id NUMBER(10) CONSTRAINT title_title_pk PRIMARY KEY,
title VARCHAR2(60) CONSTRAINT title_title_nn NOT NULL,
description VARCHAR2(400) CONSTRAINT title_description_nn NOT NULL,
rating VARCHAR2(4) CONSTRAINT title_rating_ck CHECK (rating IN ('G','PG','R','NC17','NR')),
category VARCHAR2(20) CONSTRAINT title_category_ck CHECK (category IN
('DRAMA','COMEDY','ACTION','CHILD','DOCUMENTARY')),
release_date DATE);

C.)
CREATE TABLE title_copy
(copy_id NUMBER(10),
title_id NUMBER(10) CONSTRAINT title_copy_title_id_fk REFERENCES title(title_id),
status VARCHAR2(15) CONSTRAINT title_copy_status_nn NOT NULL CONSTRAINT
title_copy_status_ck CHECK (status
IN('AVAILABLE','DESTROYED','RENTED','RESERVED')),
CONSTRAINT title_copy_copy_id_title_id PRIMARY KEY (copy_id,title_id));
D.)
CREATE TABLE rental
(book_date DATE DEFAULT SYSDATE,
member_id NUMBER(10) CONSTRAINT rental_member_id_fk
REFERENCES member(member_id),
copy_id NUMBER(10),
act_ret_date DATE,
exp_ret_date DATE DEFAULT SYSDATE + 2,
title_id NUMBER(10),
CONSTRAINT rental_book_date_copy_title_pk
PRIMARY KEY (book_date, member_id,
copy_id,title_id),
CONSTRAINT rental_copy_id_title_id_fk
FOREIGN KEY (copy_id, title_id)
REFERENCES title_copy(copy_id, title_id));

E.)
CREATE TABLE reservation (
res_date DATE CONSTRAINT reservation_res_date_nn NOT NULL,
member_id NUMBER(10) CONSTRAINT reservation_member_id_fk1 REFERENCES
member_id(member),
title_id NUMBER(10) CONSTRAINT reservation_title_id_fk2_ REFERENCES title(title_id),
CONSTRAINT reservation_member_id_title_id_pk PRIMARY KEY (member_id,title_id));

2.)
SELECT table_name
FROM user_tables
WHERE table_name IN ('MEMBER', 'TITLE', 'TITLE_COPY',
'RENTAL', 'RESERVATION');
SELECT constraint_name, constraint_type, table_name
FROM user_constraints
WHERE table_name IN ('MEMBER', 'TITLE', 'TITLE_COPY',
'RENTAL', 'RESERVATION');

3.)
A.)
CREATE SEQUENCE member_id_seq
START WITH 101
NOCACHE

B.)
CREATE SEQUENCE title_id_seq
START WITH 92
NOCACHE;

C.) SELECT sequence_name, increment_by, last_number


FROM user_sequences
WHERE sequence_name IN ('MEMBER_ID_SEQ', 'TITLE_ID_SEQ ');

4.SET ECHO OFF


INSERT INTO title(title_id, title, description, rating,
category, release_date)
VALUES (title_id_seq.NEXTVAL, 'Willie and Christmas Too',
'All of Willie''s friends make a Christmas list for
Santa, but Willie has yet to add his own wish list.',
'G', 'CHILD', TO_DATE('05-OCT-1995','DD-MON-YYYY')
/
INSERT INTO title(title_id , title, description, rating,
category, release_date)
VALUES (title_id_seq.NEXTVAL, 'Alien Again', 'Yet another
installment of science fiction history. Can the
heroine save the planet from the alien life form?',
'R', 'SCIFI', TO_DATE( '19-MAY-1995','DD-MON-YYYY'))
/
INSERT INTO title(title_id, title, description, rating,
category, release_date)
VALUES (title_id_seq.NEXTVAL, 'The Glob', 'A meteor crashes
near a small American town and unleashes carnivorous
goo in this classic.', 'NR', 'SCIFI',
TO_DATE( '12-AUG-1995','DD-MON-YYYY'))
/
INSERT INTO title(title_id, title, description, rating,
category, release_date)
VALUES (title_id_seq.NEXTVAL, 'My Day Off', 'With a little
luck and a lot ingenuity, a teenager skips school for
a day in New York.', 'PG', 'COMEDY',
TO_DATE( '12-JUL-1995','DD-MON-YYYY'))
/
COMMIT
/
SET ECHO ON
SELECT title
FROM title;
B.
C.

D.

5.

6.
A.

B.

C.
7.

A. B.

C.

8.

You might also like