UMUC Asia - CMIS320 - Relational Database Concepts and Applications
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]
開始行:
#contents
** E-R Diagramming Paid/Freeware Tools [#n67347d3]
Here are some links to some ER tools you could use for yo...
Purchase from Microsoft: Microsoft Visio~
http://office.microsoft.com/en-us/visio/
This might save people some money if they want to buy vis...
https://my.umuc.edu/psp/uucepprd_newwin/EMPLOYEE/EMPL/e/?...
Freeware Tools:~
https://wiki.gnome.org/action/show/Apps/Dia?action=show&r...
https://www.lucidchart.com/pages/b?utm_expid=39895073-40....
http://ermaster.sourceforge.net/~
//** Week 1 Introduction
//
//- Question
//
//Introduce yourself here by telling us your name, what p...
//
//- Answer
//
//Hello everyone, my name is Yuji Shimojo and I'm 27. I a...
//
//In my spare time, I enjoy traveling. I've been to Calif...
//
//I also enjoy scuba diving. Okinawa is known as one of t...
** Week 1 Discussion Entities and Attributes [#pa7da807]
- Question
You have been tasked to create a database for your colleg...
Describe the entities and their attributes that might be ...
Consider all users of the application and how the issues ...
- Answer
I believe the type of database processing required for th...
In designing a relational database, each relation needs t...
#ref(CMIS320_W1_ERM.png,,90%)
Since the system is simple and small scale, Microsoft Acc...
** Homework1 [#dfacf0ef]
- Question
Consider a student club or organization in which you are ...
- Answer
#ref(CMIS320_Homework1.pdf)
** Week2 Relational Model and an Introduction to SQL [#m9...
- Question
Answer just one of the following questions. Be sure to re...
1) What is Dr. Codd's relational model and what does it i...
2) Contrast the terms relation, tuple, and attribute with...
3) Describe the relationship between a superkey, a candid...
4) Explain where you can use business rules in an organiz...
5) Describe and give an example of one of the following:
-- derived attribute
-- multivalued attribute
-- ternary relationship
-- required attribute
- Answer
''3) Describe the relationship between a superkey, a cand...
A super key of a relation is an attribute or a subset of ...
A candidate key of a relation is one of super keys which ...
A primary key of a relation is a candidate key which is t...
For example, when there are multiple attributes named Cit...
** Homework2 [#l4f5e909]
- Question
For each of the following descriptions:
a. A piano manufacturer wants to track all pianos it make...
b. A vendor builds multiple types of tablet computers. Ea...
perform the following tasks:
1. Identify the degree and cardinalities of the relations...
2. Express the relationships graphically with an E-R diag...
Document your work into a single, well-organized, well-wr...
- Answer
#ref(CMIS320_Homework2.pdf)
- GitHub Repository: https://github.com/yujishimojo/CMIS3...
** Week3 Enhanced E-R model discussion [#nfd6afa1]
- Question
Provide your own unique example of a supertype/subtype re...
** Homework3 [#m5bad23e]
- Question
You are working for country club with thousands of member...
The club keeps track of mail and telephone contact inform...
Develop, document and design an EER for this situation.
Submit your word document no later than the due date.
- Answer
#ref(CMIS320_Homework3.pdf)
** Week4 Data Dictionary Views [#r7905787]
- Question
Conduct some research on Oracle Data dictionary views usi...
Pick a view and describe and provide at least two columns...
Be sure to pick a dictionary view no one else has already...
** Project1 [#tc282e50]
- Question
''Instructions:''
This project allows students to demonstrate their skills ...
''Project 1 Details:''
In this project you will be provided with a description o...
You are a database consultant with Ace Software, Inc. and...
You sit down with Mom and Pop to discuss their business, ...
The price of a DVD for a movie might be different than th...
Each video and DVD has a unique identification number tha...
Mom and Pop need to record when a video or DVD is rented,...
There must be no limit to the number of video and/or DVD ...
Using this information, you should:
Step 1) (7 points) Determine and list your entities. Then...
Step 2) (13 points) Create an entity/relationship diagram...
Step 3) (5 points) Create metadata that describes the tab...
Follow the procedures in the course modules and the Datab...
Submit everything for the above steps in a single Microso...
- Answer
#ref(CMIS320_Project1.pdf)
- GitHub Repository: https://github.com/yujishimojo/CMIS3...
** Homework4 [#nabbc2fa]
- Question
Choose Oracle datatypes for the following attributes from...
Vendor (VendorID, Address, ContactName)~
Item (ItemID, Description)~
PriceQuote (VendorID, ItemID, Price)
Describe why you selected the datatypes for each attribute.
- Answer
#ref(CMIS320_Homework4.pdf)
- GitHub Repository: https://github.com/yujishimojo/CMIS3...
** Week5 3rd Normal Form [#c6660284]
- Question
Give your own example of a relationship that is in 3rd No...
Be sure to discuss why it is in 3rd Normal Form.
- Answer
There are three tables: Order, Customer, and Product. The...
#ref(CMIS320_W5_Order.png,,80%)
#ref(CMIS320_W5_Customer(2ndNF).png,,80%)
#ref(CMIS320_W5_Product.png,,80%)
To remove the transitive dependency, I divided them into ...
#ref(CMIS320_W5_Customer(3rdNF).png,,80%)
#ref(CMIS320_W5_Industry(3rdNF).png,,80%)
** Week6 SQL discussions [#gecb0f36]
- Question
You only need to make a single posting each week. You do...
1) Explain why it's a good idea to have DROP TABLE statem...
2) How can you drop a table from your database that has o...
3) What is a HAVING clause used for and how does this dif...
4) Give an example of how a subquery can be used in the W...
5) Give your own example of SQL containing one of the fol...
- Answer
First of all, I defined the following tables: customers, ...
#ref(CMIS320_W6.png,,90%);
I created examples of SQL for the tables above for questi...
''4) Give an example of how a subquery can be used in the...
/* Retrieves records of which customers purchased someth...
SELECT *
FROM customers
WHERE customer_id IN ( SELECT customer_id
FROM orders
WHERE purchase_date
BETWEEN '6/1/2015' AND '6...
''5) Give your own example of SQL containing one of the f...
/* Creates the customers table. */
CREATE TABLE customers
(
customer_id number(5,0) NOT NULL UNIQUE,
registration_date date,
active varchar2(1),
name char,
gender varchar2(1),
age number(3,0),
address char,
phone_number char,
PRIMARY KEY (customer_id)
);
/* Deletes the record of customer id number 100 from the...
DELETE
FROM customers
WHERE customer_id = 100;
/* Changes the active status of customer id number 100 f...
UPDATE customers
SET active = 'f'
WHERE customer_id = 100;
/* Inserts a record into the customers table. */
INSERT INTO CUSTOMERS (
registration_date,
active,
name,
gender,
age,
address,
phone_number
) VALUES (
'6/28/2015',
't',
'John Smith',
'm',
'30',
'123 Cherry Street, Naha, Okinawa 9011234, JAPAN',
'+81-98-123-4567'
);
** Project2 [#u65af70f]
- Question
''Instructions:''
In this project you will perform the ''physical'' design ...
Each of the steps below requires a SPOOL file to be submi...
''Project 2 Details:''
+ ''Create Oracle database tables'' using SQL Data Defini...
+ Provide two examples of SQL DML (i.e., "INSERT") comman...
+ Populate each of your tables with at least five ''valid...
+ Write SQL to perform the following queries and updates....
-- Retrieve all of your customers' names, account numbers...
-- Retrieve all of the videos rented in the last 30 days ...
-- Produce a list of your distributors and all their info...
-- Update a customer name to change their maiden names to...
-- Delete customers from the database. You can choose whi...
Submit your SPOOL file(s) showing that all SQL in your SQ...
- Step 1
-- SQL statements
/* Create Sequences */
CREATE SEQUENCE SEQ_academy_awards_id INCREMENT BY 1 STA...
CREATE SEQUENCE SEQ_academy_awards_movies_id INCREMENT B...
CREATE SEQUENCE SEQ_actors_id INCREMENT BY 1 START WITH 1;
CREATE SEQUENCE SEQ_actors_movies_id INCREMENT BY 1 STAR...
CREATE SEQUENCE SEQ_charges_id INCREMENT BY 1 START WITH...
CREATE SEQUENCE SEQ_charges_rentals_id INCREMENT BY 1 ST...
CREATE SEQUENCE SEQ_customers_id INCREMENT BY 1 START WI...
CREATE SEQUENCE SEQ_directors_id INCREMENT BY 1 START WI...
CREATE SEQUENCE SEQ_directors_movies_id INCREMENT BY 1 S...
CREATE SEQUENCE SEQ_distributors_id INCREMENT BY 1 START...
CREATE SEQUENCE SEQ_inventories_id INCREMENT BY 1 START ...
CREATE SEQUENCE SEQ_movies_id INCREMENT BY 1 START WITH 1;
CREATE SEQUENCE SEQ_rentals_id INCREMENT BY 1 START WITH...
/* Create Tables */
CREATE TABLE academy_awards
(
id number(5,0) NOT NULL,
category varchar2(25) NOT NULL,
year_awarded number(5,0) NOT NULL,
is_winner varchar2(1) NOT NULL,
is_nominee varchar2(1) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE academy_awards_movies
(
id number(10,0) NOT NULL,
academy_award_id number(5,0) NOT NULL,
movie_id number(5,0) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE actors
(
id number(5,0) NOT NULL,
first_name varchar2(15) NOT NULL,
middle_name varchar2(15),
last_name varchar2(15) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE actors_movies
(
id number(10,0) NOT NULL,
actor_id number(5,0) NOT NULL,
movie_id number(5,0) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE charges
(
id number(3,0) NOT NULL,
-- standard_charge
-- late_fee
-- damaged_fee
-- failure_to_rewind_fee
-- other
charge_type varchar2(30) NOT NULL,
charge number(19,4) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE charges_rentals
(
id number(10,0) NOT NULL,
rental_id number(10,0) NOT NULL,
charge_id number(3,0) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE customers
(
id number(5,0) NOT NULL,
first_name varchar2(15) NOT NULL,
middle_name varchar2(15),
last_name varchar2(15) NOT NULL,
street_address varchar2(30) NOT NULL,
city varchar2(15) NOT NULL,
state varchar2(5) NOT NULL,
zip_code number(10,0) NOT NULL,
phone_number varchar2(20) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE directors
(
id number(5,0) NOT NULL,
first_name varchar2(15) NOT NULL,
middle_name varchar2(15),
last_name varchar2(15) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE directors_movies
(
id number(10,0) NOT NULL,
director_id number(5,0) NOT NULL,
movie_id number(5,0) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE distributors
(
id number(3,0) NOT NULL,
name varchar2(40) NOT NULL,
shipment_quantity number(5,0),
PRIMARY KEY (id)
);
CREATE TABLE inventories
(
id number(10,0) NOT NULL,
movie_id number(5,0) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE movies
(
id number(5,0) NOT NULL,
distributor_id number(3,0) NOT NULL,
title varchar2(50) NOT NULL,
-- suspense
-- horror
-- mystery
-- comedy
-- other
movie_type varchar2(15) NOT NULL,
running_length number(5,0) NOT NULL,
rating number(3,0),
year_released number(5,0) NOT NULL,
is_video varchar2(1) NOT NULL,
is_dvd varchar2(1) NOT NULL,
wholesale_price number(19,4) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE rentals
(
id number(10,0) NOT NULL,
customer_id number(5,0) NOT NULL,
inventory_id number(10,0) NOT NULL,
rental_date date NOT NULL,
return_due_date date NOT NULL,
is_rented varchar2(1) NOT NULL,
is_returned varchar2(1) NOT NULL,
total_charge number(19,4) NOT NULL,
tax number(19,4) NOT NULL,
PRIMARY KEY (id)
);
/* Create Foreign Keys */
ALTER TABLE academy_awards_movies
ADD FOREIGN KEY (academy_award_id)
REFERENCES academy_awards (id)
;
ALTER TABLE actors_movies
ADD FOREIGN KEY (actor_id)
REFERENCES actors (id)
;
ALTER TABLE charges_rentals
ADD FOREIGN KEY (charge_id)
REFERENCES charges (id)
;
ALTER TABLE rentals
ADD FOREIGN KEY (customer_id)
REFERENCES customers (id)
;
ALTER TABLE directors_movies
ADD FOREIGN KEY (director_id)
REFERENCES directors (id)
;
ALTER TABLE movies
ADD FOREIGN KEY (distributor_id)
REFERENCES distributors (id)
;
ALTER TABLE rentals
ADD FOREIGN KEY (inventory_id)
REFERENCES inventories (id)
;
ALTER TABLE directors_movies
ADD FOREIGN KEY (movie_id)
REFERENCES movies (id)
;
ALTER TABLE actors_movies
ADD FOREIGN KEY (movie_id)
REFERENCES movies (id)
;
ALTER TABLE academy_awards_movies
ADD FOREIGN KEY (movie_id)
REFERENCES movies (id)
;
ALTER TABLE inventories
ADD FOREIGN KEY (movie_id)
REFERENCES movies (id)
;
ALTER TABLE charges_rentals
ADD FOREIGN KEY (rental_id)
REFERENCES rentals (id)
;
/* Create Triggers */
CREATE OR REPLACE TRIGGER TRI_academy_awards_id BEFORE I...
FOR EACH ROW
BEGIN
SELECT SEQ_academy_awards_id.nextval
INTO :new.id
FROM dual;
END;
/
CREATE OR REPLACE TRIGGER TRI_academy_awards_movies_id B...
FOR EACH ROW
BEGIN
SELECT SEQ_academy_awards_movies_id.nextval
INTO :new.id
FROM dual;
END;
/
CREATE OR REPLACE TRIGGER TRI_actors_id BEFORE INSERT ON...
FOR EACH ROW
BEGIN
SELECT SEQ_actors_id.nextval
INTO :new.id
FROM dual;
END;
/
CREATE OR REPLACE TRIGGER TRI_actors_movies_id BEFORE IN...
FOR EACH ROW
BEGIN
SELECT SEQ_actors_movies_id.nextval
INTO :new.id
FROM dual;
END;
/
CREATE OR REPLACE TRIGGER TRI_charges_id BEFORE INSERT O...
FOR EACH ROW
BEGIN
SELECT SEQ_charges_id.nextval
INTO :new.id
FROM dual;
END;
/
CREATE OR REPLACE TRIGGER TRI_charges_rentals_id BEFORE ...
FOR EACH ROW
BEGIN
SELECT SEQ_charges_rentals_id.nextval
INTO :new.id
FROM dual;
END;
/
CREATE OR REPLACE TRIGGER TRI_customers_id BEFORE INSERT...
FOR EACH ROW
BEGIN
SELECT SEQ_customers_id.nextval
INTO :new.id
FROM dual;
END;
/
CREATE OR REPLACE TRIGGER TRI_directors_id BEFORE INSERT...
FOR EACH ROW
BEGIN
SELECT SEQ_directors_id.nextval
INTO :new.id
FROM dual;
END;
/
CREATE OR REPLACE TRIGGER TRI_directors_movies_id BEFORE...
FOR EACH ROW
BEGIN
SELECT SEQ_directors_movies_id.nextval
INTO :new.id
FROM dual;
END;
/
CREATE OR REPLACE TRIGGER TRI_distributors_id BEFORE INS...
FOR EACH ROW
BEGIN
SELECT SEQ_distributors_id.nextval
INTO :new.id
FROM dual;
END;
/
CREATE OR REPLACE TRIGGER TRI_inventories_id BEFORE INSE...
FOR EACH ROW
BEGIN
SELECT SEQ_inventories_id.nextval
INTO :new.id
FROM dual;
END;
/
CREATE OR REPLACE TRIGGER TRI_movies_id BEFORE INSERT ON...
FOR EACH ROW
BEGIN
SELECT SEQ_movies_id.nextval
INTO :new.id
FROM dual;
END;
/
CREATE OR REPLACE TRIGGER TRI_rentals_id BEFORE INSERT O...
FOR EACH ROW
BEGIN
SELECT SEQ_rentals_id.nextval
INTO :new.id
FROM dual;
END;
/
/* Comments */
COMMENT ON COLUMN charges.charge_type IS 'standard_charge
late_fee
damaged_fee
failure_to_rewind_fee
other';
COMMENT ON COLUMN movies.movie_type IS 'suspense
horror
mystery
comedy
other';
-- Output
CREATE SEQUENCE succeeded.
CREATE SEQUENCE succeeded.
CREATE SEQUENCE succeeded.
CREATE SEQUENCE succeeded.
CREATE SEQUENCE succeeded.
CREATE SEQUENCE succeeded.
CREATE SEQUENCE succeeded.
CREATE SEQUENCE succeeded.
CREATE SEQUENCE succeeded.
CREATE SEQUENCE succeeded.
CREATE SEQUENCE succeeded.
CREATE SEQUENCE succeeded.
CREATE SEQUENCE succeeded.
CREATE TABLE succeeded.
CREATE TABLE succeeded.
CREATE TABLE succeeded.
CREATE TABLE succeeded.
CREATE TABLE succeeded.
CREATE TABLE succeeded.
CREATE TABLE succeeded.
CREATE TABLE succeeded.
CREATE TABLE succeeded.
CREATE TABLE succeeded.
CREATE TABLE succeeded.
CREATE TABLE succeeded.
CREATE TABLE succeeded.
ALTER TABLE academy_awards_movies succeeded.
ALTER TABLE actors_movies succeeded.
ALTER TABLE charges_rentals succeeded.
ALTER TABLE rentals succeeded.
ALTER TABLE directors_movies succeeded.
ALTER TABLE movies succeeded.
ALTER TABLE rentals succeeded.
ALTER TABLE directors_movies succeeded.
ALTER TABLE actors_movies succeeded.
ALTER TABLE academy_awards_movies succeeded.
ALTER TABLE inventories succeeded.
ALTER TABLE charges_rentals succeeded.
TRIGGER TRI_academy_awards_id Compiled.
TRIGGER TRI_academy_awards_movies_id Compiled.
TRIGGER TRI_actors_id Compiled.
TRIGGER TRI_actors_movies_id Compiled.
TRIGGER TRI_charges_id Compiled.
TRIGGER TRI_charges_rentals_id Compiled.
TRIGGER TRI_customers_id Compiled.
TRIGGER TRI_directors_id Compiled.
TRIGGER TRI_directors_movies_id Compiled.
TRIGGER TRI_distributors_id Compiled.
TRIGGER TRI_inventories_id Compiled.
TRIGGER TRI_movies_id Compiled.
TRIGGER TRI_rentals_id Compiled.
COMMENT ON succeeded.
COMMENT ON succeeded.
- Step 2
-- SQL statements
/* You will get an error: "ORA-01400" because the custom...
INSERT INTO customers (id, first_name, middle_name, last...
/* You will get an error: "ORA-02292: integrity constrai...
delete from customers where id = 5;
-- Output
Error starting at line 2 in command:
INSERT INTO customers (id, first_name, middle_name, last...
Error report:
SQL Error: ORA-01400: cannot insert NULL into ("CM320B11...
01400. 00000 - "cannot insert NULL into (%s)"
*Cause:
*Action:
Error starting at line 5 in command:
delete from customers where id = 5
Error report:
SQL Error: ORA-02292: integrity constraint (CM320B11.SYS...
02292. 00000 - "integrity constraint (%s.%s) violated - ...
*Cause: attempted to delete a parent key value that h...
dependency.
*Action: delete dependencies first then parent or disa...
- Step 3
-- SQL statements
-- customers
INSERT INTO customers (id, first_name, middle_name, last...
INSERT INTO customers (id, first_name, middle_name, last...
INSERT INTO customers (id, first_name, middle_name, last...
INSERT INTO customers (id, first_name, middle_name, last...
INSERT INTO customers (id, first_name, middle_name, last...
-- charges
INSERT INTO charges (id, charge_type, charge) VALUES ('1...
INSERT INTO charges (id, charge_type, charge) VALUES ('2...
INSERT INTO charges (id, charge_type, charge) VALUES ('3...
INSERT INTO charges (id, charge_type, charge) VALUES ('4...
-- distributors
INSERT INTO distributors (id, name, shipment_quantity) V...
INSERT INTO distributors (id, name, shipment_quantity) V...
INSERT INTO distributors (id, name, shipment_quantity) V...
-- movies
INSERT INTO movies (id, distributor_id, title, movie_typ...
INSERT INTO movies (id, distributor_id, title, movie_typ...
INSERT INTO movies (id, distributor_id, title, movie_typ...
INSERT INTO movies (id, distributor_id, title, movie_typ...
INSERT INTO movies (id, distributor_id, title, movie_typ...
INSERT INTO movies (id, distributor_id, title, movie_typ...
-- inventories
INSERT INTO inventories (id, movie_id) VALUES ('1', '1');
INSERT INTO inventories (id, movie_id) VALUES ('2', '1');
INSERT INTO inventories (id, movie_id) VALUES ('3', '1');
INSERT INTO inventories (id, movie_id) VALUES ('4', '2');
INSERT INTO inventories (id, movie_id) VALUES ('5', '2');
INSERT INTO inventories (id, movie_id) VALUES ('6', '2');
INSERT INTO inventories (id, movie_id) VALUES ('7', '2');
INSERT INTO inventories (id, movie_id) VALUES ('8', '3');
INSERT INTO inventories (id, movie_id) VALUES ('9', '3');
INSERT INTO inventories (id, movie_id) VALUES ('10', '3');
INSERT INTO inventories (id, movie_id) VALUES ('11', '3');
INSERT INTO inventories (id, movie_id) VALUES ('12', '4');
INSERT INTO inventories (id, movie_id) VALUES ('13', '4');
INSERT INTO inventories (id, movie_id) VALUES ('14', '4');
INSERT INTO inventories (id, movie_id) VALUES ('15', '5');
INSERT INTO inventories (id, movie_id) VALUES ('16', '5');
INSERT INTO inventories (id, movie_id) VALUES ('17', '6');
INSERT INTO inventories (id, movie_id) VALUES ('18', '6');
INSERT INTO inventories (id, movie_id) VALUES ('19', '6');
INSERT INTO inventories (id, movie_id) VALUES ('20', '6');
INSERT INTO inventories (id, movie_id) VALUES ('21', '6');
INSERT INTO inventories (id, movie_id) VALUES ('22', '6');
INSERT INTO inventories (id, movie_id) VALUES ('23', '6');
INSERT INTO inventories (id, movie_id) VALUES ('24', '6');
-- rentals
INSERT INTO rentals (id, inventory_id, customer_id, rent...
INSERT INTO rentals (id, inventory_id, customer_id, rent...
INSERT INTO rentals (id, inventory_id, customer_id, rent...
INSERT INTO rentals (id, inventory_id, customer_id, rent...
INSERT INTO rentals (id, inventory_id, customer_id, rent...
INSERT INTO rentals (id, inventory_id, customer_id, rent...
INSERT INTO rentals (id, inventory_id, customer_id, rent...
INSERT INTO rentals (id, inventory_id, customer_id, rent...
INSERT INTO rentals (id, inventory_id, customer_id, rent...
INSERT INTO rentals (id, inventory_id, customer_id, rent...
INSERT INTO rentals (id, inventory_id, customer_id, rent...
-- charges_rentals
INSERT INTO charges_rentals (id, rental_id, charge_id) V...
INSERT INTO charges_rentals (id, rental_id, charge_id) V...
INSERT INTO charges_rentals (id, rental_id, charge_id) V...
INSERT INTO charges_rentals (id, rental_id, charge_id) V...
INSERT INTO charges_rentals (id, rental_id, charge_id) V...
INSERT INTO charges_rentals (id, rental_id, charge_id) V...
INSERT INTO charges_rentals (id, rental_id, charge_id) V...
INSERT INTO charges_rentals (id, rental_id, charge_id) V...
INSERT INTO charges_rentals (id, rental_id, charge_id) V...
INSERT INTO charges_rentals (id, rental_id, charge_id) V...
INSERT INTO charges_rentals (id, rental_id, charge_id) V...
-- actors
INSERT INTO actors (id, first_name, middle_name, last_na...
INSERT INTO actors (id, first_name, middle_name, last_na...
INSERT INTO actors (id, first_name, middle_name, last_na...
INSERT INTO actors (id, first_name, middle_name, last_na...
INSERT INTO actors (id, first_name, middle_name, last_na...
INSERT INTO actors (id, first_name, middle_name, last_na...
-- actors_movies
INSERT INTO actors_movies (id, actor_id, movie_id) VALUE...
INSERT INTO actors_movies (id, actor_id, movie_id) VALUE...
INSERT INTO actors_movies (id, actor_id, movie_id) VALUE...
INSERT INTO actors_movies (id, actor_id, movie_id) VALUE...
INSERT INTO actors_movies (id, actor_id, movie_id) VALUE...
INSERT INTO actors_movies (id, actor_id, movie_id) VALUE...
-- directors
INSERT INTO directors (id, first_name, middle_name, last...
INSERT INTO directors (id, first_name, middle_name, last...
INSERT INTO directors (id, first_name, middle_name, last...
INSERT INTO directors (id, first_name, middle_name, last...
INSERT INTO directors (id, first_name, middle_name, last...
INSERT INTO directors (id, first_name, middle_name, last...
-- directors_movies
INSERT INTO directors_movies (id, director_id, movie_id)...
INSERT INTO directors_movies (id, director_id, movie_id)...
INSERT INTO directors_movies (id, director_id, movie_id)...
INSERT INTO directors_movies (id, director_id, movie_id)...
INSERT INTO directors_movies (id, director_id, movie_id)...
INSERT INTO directors_movies (id, director_id, movie_id)...
-- academy_awards
INSERT INTO academy_awards (id, category, year_awarded, ...
INSERT INTO academy_awards (id, category, year_awarded, ...
INSERT INTO academy_awards (id, category, year_awarded, ...
INSERT INTO academy_awards (id, category, year_awarded, ...
INSERT INTO academy_awards (id, category, year_awarded, ...
INSERT INTO academy_awards (id, category, year_awarded, ...
-- academy_awards_movies
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
-- Output
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
- Step 4
-- SQL statements
select id, first_name, middle_name, last_name, street_ad...
select * from rentals where rental_date >= (sysdate-30) ...
select * from distributors order by name;
update customers set last_name = 'Jones' where id = 4;
-- Output
ID FIRST_NAME MIDDLE_NAME L...
---------------------- --------------- --------------- -...
1 John D. S...
2 Jane S...
3 Myke H. J...
4 Anne M...
5 Bob B...
5 rows selected
ID CUSTOMER_ID INVENTORY_...
---------------------- ---------------------- ----------...
1 1 1 ...
2 2 4 ...
3 2 4 ...
4 4 9 ...
5 5 13 ...
6 5 13 ...
7 2 16 ...
8 3 17 ...
9 3 17 ...
10 5 21 ...
11 1 22 ...
11 rows selected
ID NAME ...
---------------------- ---------------------------------...
1 A Corporation ...
2 B Inc. ...
3 C LLC. ...
3 rows selected
1 rows updated
- ERD
#ref(CMIS320_PRJ2_ERD.png,,80%)
- GitHub Repository: https://github.com/yujishimojo/CMIS3...
** Week 7 Creating and Using Tables [#q6a86066]
- Question
Use SQL to Create a table with at least 4 attributes one ...
Then, insert 2 records into the table.
Finally, use a select statement to show the content of yo...
Be sure your SQL statements work without issue and show e...
- Answer
I created a students table as shown in the ERD below and ...
#ref(CMIS320_W7_ERD.png,,80%)
/* Creates the students table. */
CREATE TABLE students (
student_id number(5,0) NOT NULL UNIQUE,
last_name char NOT NULL,
first_name char NOT NULL,
middle_name char,
enrolled_at date NOT NULL,
finished_at date,
active_status varchar2(1) NOT NULL,
date_of_birthday date NOT NULL,
gender varchar2(1) NOT NULL,
address char NOT NULL,
city char NOT NULL,
state char NOT NULL,
zip_code number(10,0) NOT NULL,
PRIMARY KEY (student_id)
);
/* Inserts two records into the students table. */
INSERT ALL
INTO students (
last_name,
first_name,
enrolled_at date,
active_status,
gender,
date_of_birthday,
address,
city,
state,
zip_code
) values (
'Smith',
'John',
'7/1/2015',
't',
'm',
'4/1/1996',
'123 Cherry Stree',
'San Jose',
'CA'
95124
)
INTO students (
last_name,
first_name,
enrolled_at date,
active_status,
gender,
date_of_birthday,
address,
city,
state,
zip_code
) values (
'Smith',
'Jane',
'7/1/2015',
't',
'f',
'3/1/1996',
'456 Blossom Avenue',
'Santa Clara',
'CA'
950506709
)
SELECT * FROM dual;
/* Retrieves all the records of the students table. */
SELECT *
FROM students;
#ref(CMIS320_W7_TableInfo.png,,80%)
** Week 8 Advanced database topics [#k763eebb]
- Question
For your final discussion topic, repond to at least one o...
1) In reviewing current help wanted advertising in the pa...
2) What is PL/SQL and how can that be used in DBA and dat...
3) What are stored procedures and triggers and how are th...
4) What trends in Database technology seem to be most pro...
- Answer
''2) What is PL/SQL and how can that be used in DBA and d...
''3) What are stored procedures and triggers and how are ...
A stored procedure is a group of SQL statements. Most of ...
PL/SQL is a stored procedure for Oracle Database, which i...
CENTER:References
-- Chapple, M. (n.d.). Stored Procedure. '''About.com,'''...
-- Hall, T. (n.d.). Introduction to PL/SQL, Retrieved Jul...
-- Owens, K. (2003). '''Programming Oracle Triggers and S...
** Research Paper [#qfad325f]
- Question
''Instructions''
Write a two-page executive summary for your boss explaini...
Your paper must follow all APA Style Guide requirements. ...
Submissions:
1. You should submit your well-organized Word document in...
2. You should name your paper Yourname_shortpaper.docx.
- Answer
#ref(CMIS320_ResearchPaper.pdf)
終了行:
#contents
** E-R Diagramming Paid/Freeware Tools [#n67347d3]
Here are some links to some ER tools you could use for yo...
Purchase from Microsoft: Microsoft Visio~
http://office.microsoft.com/en-us/visio/
This might save people some money if they want to buy vis...
https://my.umuc.edu/psp/uucepprd_newwin/EMPLOYEE/EMPL/e/?...
Freeware Tools:~
https://wiki.gnome.org/action/show/Apps/Dia?action=show&r...
https://www.lucidchart.com/pages/b?utm_expid=39895073-40....
http://ermaster.sourceforge.net/~
//** Week 1 Introduction
//
//- Question
//
//Introduce yourself here by telling us your name, what p...
//
//- Answer
//
//Hello everyone, my name is Yuji Shimojo and I'm 27. I a...
//
//In my spare time, I enjoy traveling. I've been to Calif...
//
//I also enjoy scuba diving. Okinawa is known as one of t...
** Week 1 Discussion Entities and Attributes [#pa7da807]
- Question
You have been tasked to create a database for your colleg...
Describe the entities and their attributes that might be ...
Consider all users of the application and how the issues ...
- Answer
I believe the type of database processing required for th...
In designing a relational database, each relation needs t...
#ref(CMIS320_W1_ERM.png,,90%)
Since the system is simple and small scale, Microsoft Acc...
** Homework1 [#dfacf0ef]
- Question
Consider a student club or organization in which you are ...
- Answer
#ref(CMIS320_Homework1.pdf)
** Week2 Relational Model and an Introduction to SQL [#m9...
- Question
Answer just one of the following questions. Be sure to re...
1) What is Dr. Codd's relational model and what does it i...
2) Contrast the terms relation, tuple, and attribute with...
3) Describe the relationship between a superkey, a candid...
4) Explain where you can use business rules in an organiz...
5) Describe and give an example of one of the following:
-- derived attribute
-- multivalued attribute
-- ternary relationship
-- required attribute
- Answer
''3) Describe the relationship between a superkey, a cand...
A super key of a relation is an attribute or a subset of ...
A candidate key of a relation is one of super keys which ...
A primary key of a relation is a candidate key which is t...
For example, when there are multiple attributes named Cit...
** Homework2 [#l4f5e909]
- Question
For each of the following descriptions:
a. A piano manufacturer wants to track all pianos it make...
b. A vendor builds multiple types of tablet computers. Ea...
perform the following tasks:
1. Identify the degree and cardinalities of the relations...
2. Express the relationships graphically with an E-R diag...
Document your work into a single, well-organized, well-wr...
- Answer
#ref(CMIS320_Homework2.pdf)
- GitHub Repository: https://github.com/yujishimojo/CMIS3...
** Week3 Enhanced E-R model discussion [#nfd6afa1]
- Question
Provide your own unique example of a supertype/subtype re...
** Homework3 [#m5bad23e]
- Question
You are working for country club with thousands of member...
The club keeps track of mail and telephone contact inform...
Develop, document and design an EER for this situation.
Submit your word document no later than the due date.
- Answer
#ref(CMIS320_Homework3.pdf)
** Week4 Data Dictionary Views [#r7905787]
- Question
Conduct some research on Oracle Data dictionary views usi...
Pick a view and describe and provide at least two columns...
Be sure to pick a dictionary view no one else has already...
** Project1 [#tc282e50]
- Question
''Instructions:''
This project allows students to demonstrate their skills ...
''Project 1 Details:''
In this project you will be provided with a description o...
You are a database consultant with Ace Software, Inc. and...
You sit down with Mom and Pop to discuss their business, ...
The price of a DVD for a movie might be different than th...
Each video and DVD has a unique identification number tha...
Mom and Pop need to record when a video or DVD is rented,...
There must be no limit to the number of video and/or DVD ...
Using this information, you should:
Step 1) (7 points) Determine and list your entities. Then...
Step 2) (13 points) Create an entity/relationship diagram...
Step 3) (5 points) Create metadata that describes the tab...
Follow the procedures in the course modules and the Datab...
Submit everything for the above steps in a single Microso...
- Answer
#ref(CMIS320_Project1.pdf)
- GitHub Repository: https://github.com/yujishimojo/CMIS3...
** Homework4 [#nabbc2fa]
- Question
Choose Oracle datatypes for the following attributes from...
Vendor (VendorID, Address, ContactName)~
Item (ItemID, Description)~
PriceQuote (VendorID, ItemID, Price)
Describe why you selected the datatypes for each attribute.
- Answer
#ref(CMIS320_Homework4.pdf)
- GitHub Repository: https://github.com/yujishimojo/CMIS3...
** Week5 3rd Normal Form [#c6660284]
- Question
Give your own example of a relationship that is in 3rd No...
Be sure to discuss why it is in 3rd Normal Form.
- Answer
There are three tables: Order, Customer, and Product. The...
#ref(CMIS320_W5_Order.png,,80%)
#ref(CMIS320_W5_Customer(2ndNF).png,,80%)
#ref(CMIS320_W5_Product.png,,80%)
To remove the transitive dependency, I divided them into ...
#ref(CMIS320_W5_Customer(3rdNF).png,,80%)
#ref(CMIS320_W5_Industry(3rdNF).png,,80%)
** Week6 SQL discussions [#gecb0f36]
- Question
You only need to make a single posting each week. You do...
1) Explain why it's a good idea to have DROP TABLE statem...
2) How can you drop a table from your database that has o...
3) What is a HAVING clause used for and how does this dif...
4) Give an example of how a subquery can be used in the W...
5) Give your own example of SQL containing one of the fol...
- Answer
First of all, I defined the following tables: customers, ...
#ref(CMIS320_W6.png,,90%);
I created examples of SQL for the tables above for questi...
''4) Give an example of how a subquery can be used in the...
/* Retrieves records of which customers purchased someth...
SELECT *
FROM customers
WHERE customer_id IN ( SELECT customer_id
FROM orders
WHERE purchase_date
BETWEEN '6/1/2015' AND '6...
''5) Give your own example of SQL containing one of the f...
/* Creates the customers table. */
CREATE TABLE customers
(
customer_id number(5,0) NOT NULL UNIQUE,
registration_date date,
active varchar2(1),
name char,
gender varchar2(1),
age number(3,0),
address char,
phone_number char,
PRIMARY KEY (customer_id)
);
/* Deletes the record of customer id number 100 from the...
DELETE
FROM customers
WHERE customer_id = 100;
/* Changes the active status of customer id number 100 f...
UPDATE customers
SET active = 'f'
WHERE customer_id = 100;
/* Inserts a record into the customers table. */
INSERT INTO CUSTOMERS (
registration_date,
active,
name,
gender,
age,
address,
phone_number
) VALUES (
'6/28/2015',
't',
'John Smith',
'm',
'30',
'123 Cherry Street, Naha, Okinawa 9011234, JAPAN',
'+81-98-123-4567'
);
** Project2 [#u65af70f]
- Question
''Instructions:''
In this project you will perform the ''physical'' design ...
Each of the steps below requires a SPOOL file to be submi...
''Project 2 Details:''
+ ''Create Oracle database tables'' using SQL Data Defini...
+ Provide two examples of SQL DML (i.e., "INSERT") comman...
+ Populate each of your tables with at least five ''valid...
+ Write SQL to perform the following queries and updates....
-- Retrieve all of your customers' names, account numbers...
-- Retrieve all of the videos rented in the last 30 days ...
-- Produce a list of your distributors and all their info...
-- Update a customer name to change their maiden names to...
-- Delete customers from the database. You can choose whi...
Submit your SPOOL file(s) showing that all SQL in your SQ...
- Step 1
-- SQL statements
/* Create Sequences */
CREATE SEQUENCE SEQ_academy_awards_id INCREMENT BY 1 STA...
CREATE SEQUENCE SEQ_academy_awards_movies_id INCREMENT B...
CREATE SEQUENCE SEQ_actors_id INCREMENT BY 1 START WITH 1;
CREATE SEQUENCE SEQ_actors_movies_id INCREMENT BY 1 STAR...
CREATE SEQUENCE SEQ_charges_id INCREMENT BY 1 START WITH...
CREATE SEQUENCE SEQ_charges_rentals_id INCREMENT BY 1 ST...
CREATE SEQUENCE SEQ_customers_id INCREMENT BY 1 START WI...
CREATE SEQUENCE SEQ_directors_id INCREMENT BY 1 START WI...
CREATE SEQUENCE SEQ_directors_movies_id INCREMENT BY 1 S...
CREATE SEQUENCE SEQ_distributors_id INCREMENT BY 1 START...
CREATE SEQUENCE SEQ_inventories_id INCREMENT BY 1 START ...
CREATE SEQUENCE SEQ_movies_id INCREMENT BY 1 START WITH 1;
CREATE SEQUENCE SEQ_rentals_id INCREMENT BY 1 START WITH...
/* Create Tables */
CREATE TABLE academy_awards
(
id number(5,0) NOT NULL,
category varchar2(25) NOT NULL,
year_awarded number(5,0) NOT NULL,
is_winner varchar2(1) NOT NULL,
is_nominee varchar2(1) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE academy_awards_movies
(
id number(10,0) NOT NULL,
academy_award_id number(5,0) NOT NULL,
movie_id number(5,0) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE actors
(
id number(5,0) NOT NULL,
first_name varchar2(15) NOT NULL,
middle_name varchar2(15),
last_name varchar2(15) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE actors_movies
(
id number(10,0) NOT NULL,
actor_id number(5,0) NOT NULL,
movie_id number(5,0) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE charges
(
id number(3,0) NOT NULL,
-- standard_charge
-- late_fee
-- damaged_fee
-- failure_to_rewind_fee
-- other
charge_type varchar2(30) NOT NULL,
charge number(19,4) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE charges_rentals
(
id number(10,0) NOT NULL,
rental_id number(10,0) NOT NULL,
charge_id number(3,0) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE customers
(
id number(5,0) NOT NULL,
first_name varchar2(15) NOT NULL,
middle_name varchar2(15),
last_name varchar2(15) NOT NULL,
street_address varchar2(30) NOT NULL,
city varchar2(15) NOT NULL,
state varchar2(5) NOT NULL,
zip_code number(10,0) NOT NULL,
phone_number varchar2(20) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE directors
(
id number(5,0) NOT NULL,
first_name varchar2(15) NOT NULL,
middle_name varchar2(15),
last_name varchar2(15) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE directors_movies
(
id number(10,0) NOT NULL,
director_id number(5,0) NOT NULL,
movie_id number(5,0) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE distributors
(
id number(3,0) NOT NULL,
name varchar2(40) NOT NULL,
shipment_quantity number(5,0),
PRIMARY KEY (id)
);
CREATE TABLE inventories
(
id number(10,0) NOT NULL,
movie_id number(5,0) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE movies
(
id number(5,0) NOT NULL,
distributor_id number(3,0) NOT NULL,
title varchar2(50) NOT NULL,
-- suspense
-- horror
-- mystery
-- comedy
-- other
movie_type varchar2(15) NOT NULL,
running_length number(5,0) NOT NULL,
rating number(3,0),
year_released number(5,0) NOT NULL,
is_video varchar2(1) NOT NULL,
is_dvd varchar2(1) NOT NULL,
wholesale_price number(19,4) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE rentals
(
id number(10,0) NOT NULL,
customer_id number(5,0) NOT NULL,
inventory_id number(10,0) NOT NULL,
rental_date date NOT NULL,
return_due_date date NOT NULL,
is_rented varchar2(1) NOT NULL,
is_returned varchar2(1) NOT NULL,
total_charge number(19,4) NOT NULL,
tax number(19,4) NOT NULL,
PRIMARY KEY (id)
);
/* Create Foreign Keys */
ALTER TABLE academy_awards_movies
ADD FOREIGN KEY (academy_award_id)
REFERENCES academy_awards (id)
;
ALTER TABLE actors_movies
ADD FOREIGN KEY (actor_id)
REFERENCES actors (id)
;
ALTER TABLE charges_rentals
ADD FOREIGN KEY (charge_id)
REFERENCES charges (id)
;
ALTER TABLE rentals
ADD FOREIGN KEY (customer_id)
REFERENCES customers (id)
;
ALTER TABLE directors_movies
ADD FOREIGN KEY (director_id)
REFERENCES directors (id)
;
ALTER TABLE movies
ADD FOREIGN KEY (distributor_id)
REFERENCES distributors (id)
;
ALTER TABLE rentals
ADD FOREIGN KEY (inventory_id)
REFERENCES inventories (id)
;
ALTER TABLE directors_movies
ADD FOREIGN KEY (movie_id)
REFERENCES movies (id)
;
ALTER TABLE actors_movies
ADD FOREIGN KEY (movie_id)
REFERENCES movies (id)
;
ALTER TABLE academy_awards_movies
ADD FOREIGN KEY (movie_id)
REFERENCES movies (id)
;
ALTER TABLE inventories
ADD FOREIGN KEY (movie_id)
REFERENCES movies (id)
;
ALTER TABLE charges_rentals
ADD FOREIGN KEY (rental_id)
REFERENCES rentals (id)
;
/* Create Triggers */
CREATE OR REPLACE TRIGGER TRI_academy_awards_id BEFORE I...
FOR EACH ROW
BEGIN
SELECT SEQ_academy_awards_id.nextval
INTO :new.id
FROM dual;
END;
/
CREATE OR REPLACE TRIGGER TRI_academy_awards_movies_id B...
FOR EACH ROW
BEGIN
SELECT SEQ_academy_awards_movies_id.nextval
INTO :new.id
FROM dual;
END;
/
CREATE OR REPLACE TRIGGER TRI_actors_id BEFORE INSERT ON...
FOR EACH ROW
BEGIN
SELECT SEQ_actors_id.nextval
INTO :new.id
FROM dual;
END;
/
CREATE OR REPLACE TRIGGER TRI_actors_movies_id BEFORE IN...
FOR EACH ROW
BEGIN
SELECT SEQ_actors_movies_id.nextval
INTO :new.id
FROM dual;
END;
/
CREATE OR REPLACE TRIGGER TRI_charges_id BEFORE INSERT O...
FOR EACH ROW
BEGIN
SELECT SEQ_charges_id.nextval
INTO :new.id
FROM dual;
END;
/
CREATE OR REPLACE TRIGGER TRI_charges_rentals_id BEFORE ...
FOR EACH ROW
BEGIN
SELECT SEQ_charges_rentals_id.nextval
INTO :new.id
FROM dual;
END;
/
CREATE OR REPLACE TRIGGER TRI_customers_id BEFORE INSERT...
FOR EACH ROW
BEGIN
SELECT SEQ_customers_id.nextval
INTO :new.id
FROM dual;
END;
/
CREATE OR REPLACE TRIGGER TRI_directors_id BEFORE INSERT...
FOR EACH ROW
BEGIN
SELECT SEQ_directors_id.nextval
INTO :new.id
FROM dual;
END;
/
CREATE OR REPLACE TRIGGER TRI_directors_movies_id BEFORE...
FOR EACH ROW
BEGIN
SELECT SEQ_directors_movies_id.nextval
INTO :new.id
FROM dual;
END;
/
CREATE OR REPLACE TRIGGER TRI_distributors_id BEFORE INS...
FOR EACH ROW
BEGIN
SELECT SEQ_distributors_id.nextval
INTO :new.id
FROM dual;
END;
/
CREATE OR REPLACE TRIGGER TRI_inventories_id BEFORE INSE...
FOR EACH ROW
BEGIN
SELECT SEQ_inventories_id.nextval
INTO :new.id
FROM dual;
END;
/
CREATE OR REPLACE TRIGGER TRI_movies_id BEFORE INSERT ON...
FOR EACH ROW
BEGIN
SELECT SEQ_movies_id.nextval
INTO :new.id
FROM dual;
END;
/
CREATE OR REPLACE TRIGGER TRI_rentals_id BEFORE INSERT O...
FOR EACH ROW
BEGIN
SELECT SEQ_rentals_id.nextval
INTO :new.id
FROM dual;
END;
/
/* Comments */
COMMENT ON COLUMN charges.charge_type IS 'standard_charge
late_fee
damaged_fee
failure_to_rewind_fee
other';
COMMENT ON COLUMN movies.movie_type IS 'suspense
horror
mystery
comedy
other';
-- Output
CREATE SEQUENCE succeeded.
CREATE SEQUENCE succeeded.
CREATE SEQUENCE succeeded.
CREATE SEQUENCE succeeded.
CREATE SEQUENCE succeeded.
CREATE SEQUENCE succeeded.
CREATE SEQUENCE succeeded.
CREATE SEQUENCE succeeded.
CREATE SEQUENCE succeeded.
CREATE SEQUENCE succeeded.
CREATE SEQUENCE succeeded.
CREATE SEQUENCE succeeded.
CREATE SEQUENCE succeeded.
CREATE TABLE succeeded.
CREATE TABLE succeeded.
CREATE TABLE succeeded.
CREATE TABLE succeeded.
CREATE TABLE succeeded.
CREATE TABLE succeeded.
CREATE TABLE succeeded.
CREATE TABLE succeeded.
CREATE TABLE succeeded.
CREATE TABLE succeeded.
CREATE TABLE succeeded.
CREATE TABLE succeeded.
CREATE TABLE succeeded.
ALTER TABLE academy_awards_movies succeeded.
ALTER TABLE actors_movies succeeded.
ALTER TABLE charges_rentals succeeded.
ALTER TABLE rentals succeeded.
ALTER TABLE directors_movies succeeded.
ALTER TABLE movies succeeded.
ALTER TABLE rentals succeeded.
ALTER TABLE directors_movies succeeded.
ALTER TABLE actors_movies succeeded.
ALTER TABLE academy_awards_movies succeeded.
ALTER TABLE inventories succeeded.
ALTER TABLE charges_rentals succeeded.
TRIGGER TRI_academy_awards_id Compiled.
TRIGGER TRI_academy_awards_movies_id Compiled.
TRIGGER TRI_actors_id Compiled.
TRIGGER TRI_actors_movies_id Compiled.
TRIGGER TRI_charges_id Compiled.
TRIGGER TRI_charges_rentals_id Compiled.
TRIGGER TRI_customers_id Compiled.
TRIGGER TRI_directors_id Compiled.
TRIGGER TRI_directors_movies_id Compiled.
TRIGGER TRI_distributors_id Compiled.
TRIGGER TRI_inventories_id Compiled.
TRIGGER TRI_movies_id Compiled.
TRIGGER TRI_rentals_id Compiled.
COMMENT ON succeeded.
COMMENT ON succeeded.
- Step 2
-- SQL statements
/* You will get an error: "ORA-01400" because the custom...
INSERT INTO customers (id, first_name, middle_name, last...
/* You will get an error: "ORA-02292: integrity constrai...
delete from customers where id = 5;
-- Output
Error starting at line 2 in command:
INSERT INTO customers (id, first_name, middle_name, last...
Error report:
SQL Error: ORA-01400: cannot insert NULL into ("CM320B11...
01400. 00000 - "cannot insert NULL into (%s)"
*Cause:
*Action:
Error starting at line 5 in command:
delete from customers where id = 5
Error report:
SQL Error: ORA-02292: integrity constraint (CM320B11.SYS...
02292. 00000 - "integrity constraint (%s.%s) violated - ...
*Cause: attempted to delete a parent key value that h...
dependency.
*Action: delete dependencies first then parent or disa...
- Step 3
-- SQL statements
-- customers
INSERT INTO customers (id, first_name, middle_name, last...
INSERT INTO customers (id, first_name, middle_name, last...
INSERT INTO customers (id, first_name, middle_name, last...
INSERT INTO customers (id, first_name, middle_name, last...
INSERT INTO customers (id, first_name, middle_name, last...
-- charges
INSERT INTO charges (id, charge_type, charge) VALUES ('1...
INSERT INTO charges (id, charge_type, charge) VALUES ('2...
INSERT INTO charges (id, charge_type, charge) VALUES ('3...
INSERT INTO charges (id, charge_type, charge) VALUES ('4...
-- distributors
INSERT INTO distributors (id, name, shipment_quantity) V...
INSERT INTO distributors (id, name, shipment_quantity) V...
INSERT INTO distributors (id, name, shipment_quantity) V...
-- movies
INSERT INTO movies (id, distributor_id, title, movie_typ...
INSERT INTO movies (id, distributor_id, title, movie_typ...
INSERT INTO movies (id, distributor_id, title, movie_typ...
INSERT INTO movies (id, distributor_id, title, movie_typ...
INSERT INTO movies (id, distributor_id, title, movie_typ...
INSERT INTO movies (id, distributor_id, title, movie_typ...
-- inventories
INSERT INTO inventories (id, movie_id) VALUES ('1', '1');
INSERT INTO inventories (id, movie_id) VALUES ('2', '1');
INSERT INTO inventories (id, movie_id) VALUES ('3', '1');
INSERT INTO inventories (id, movie_id) VALUES ('4', '2');
INSERT INTO inventories (id, movie_id) VALUES ('5', '2');
INSERT INTO inventories (id, movie_id) VALUES ('6', '2');
INSERT INTO inventories (id, movie_id) VALUES ('7', '2');
INSERT INTO inventories (id, movie_id) VALUES ('8', '3');
INSERT INTO inventories (id, movie_id) VALUES ('9', '3');
INSERT INTO inventories (id, movie_id) VALUES ('10', '3');
INSERT INTO inventories (id, movie_id) VALUES ('11', '3');
INSERT INTO inventories (id, movie_id) VALUES ('12', '4');
INSERT INTO inventories (id, movie_id) VALUES ('13', '4');
INSERT INTO inventories (id, movie_id) VALUES ('14', '4');
INSERT INTO inventories (id, movie_id) VALUES ('15', '5');
INSERT INTO inventories (id, movie_id) VALUES ('16', '5');
INSERT INTO inventories (id, movie_id) VALUES ('17', '6');
INSERT INTO inventories (id, movie_id) VALUES ('18', '6');
INSERT INTO inventories (id, movie_id) VALUES ('19', '6');
INSERT INTO inventories (id, movie_id) VALUES ('20', '6');
INSERT INTO inventories (id, movie_id) VALUES ('21', '6');
INSERT INTO inventories (id, movie_id) VALUES ('22', '6');
INSERT INTO inventories (id, movie_id) VALUES ('23', '6');
INSERT INTO inventories (id, movie_id) VALUES ('24', '6');
-- rentals
INSERT INTO rentals (id, inventory_id, customer_id, rent...
INSERT INTO rentals (id, inventory_id, customer_id, rent...
INSERT INTO rentals (id, inventory_id, customer_id, rent...
INSERT INTO rentals (id, inventory_id, customer_id, rent...
INSERT INTO rentals (id, inventory_id, customer_id, rent...
INSERT INTO rentals (id, inventory_id, customer_id, rent...
INSERT INTO rentals (id, inventory_id, customer_id, rent...
INSERT INTO rentals (id, inventory_id, customer_id, rent...
INSERT INTO rentals (id, inventory_id, customer_id, rent...
INSERT INTO rentals (id, inventory_id, customer_id, rent...
INSERT INTO rentals (id, inventory_id, customer_id, rent...
-- charges_rentals
INSERT INTO charges_rentals (id, rental_id, charge_id) V...
INSERT INTO charges_rentals (id, rental_id, charge_id) V...
INSERT INTO charges_rentals (id, rental_id, charge_id) V...
INSERT INTO charges_rentals (id, rental_id, charge_id) V...
INSERT INTO charges_rentals (id, rental_id, charge_id) V...
INSERT INTO charges_rentals (id, rental_id, charge_id) V...
INSERT INTO charges_rentals (id, rental_id, charge_id) V...
INSERT INTO charges_rentals (id, rental_id, charge_id) V...
INSERT INTO charges_rentals (id, rental_id, charge_id) V...
INSERT INTO charges_rentals (id, rental_id, charge_id) V...
INSERT INTO charges_rentals (id, rental_id, charge_id) V...
-- actors
INSERT INTO actors (id, first_name, middle_name, last_na...
INSERT INTO actors (id, first_name, middle_name, last_na...
INSERT INTO actors (id, first_name, middle_name, last_na...
INSERT INTO actors (id, first_name, middle_name, last_na...
INSERT INTO actors (id, first_name, middle_name, last_na...
INSERT INTO actors (id, first_name, middle_name, last_na...
-- actors_movies
INSERT INTO actors_movies (id, actor_id, movie_id) VALUE...
INSERT INTO actors_movies (id, actor_id, movie_id) VALUE...
INSERT INTO actors_movies (id, actor_id, movie_id) VALUE...
INSERT INTO actors_movies (id, actor_id, movie_id) VALUE...
INSERT INTO actors_movies (id, actor_id, movie_id) VALUE...
INSERT INTO actors_movies (id, actor_id, movie_id) VALUE...
-- directors
INSERT INTO directors (id, first_name, middle_name, last...
INSERT INTO directors (id, first_name, middle_name, last...
INSERT INTO directors (id, first_name, middle_name, last...
INSERT INTO directors (id, first_name, middle_name, last...
INSERT INTO directors (id, first_name, middle_name, last...
INSERT INTO directors (id, first_name, middle_name, last...
-- directors_movies
INSERT INTO directors_movies (id, director_id, movie_id)...
INSERT INTO directors_movies (id, director_id, movie_id)...
INSERT INTO directors_movies (id, director_id, movie_id)...
INSERT INTO directors_movies (id, director_id, movie_id)...
INSERT INTO directors_movies (id, director_id, movie_id)...
INSERT INTO directors_movies (id, director_id, movie_id)...
-- academy_awards
INSERT INTO academy_awards (id, category, year_awarded, ...
INSERT INTO academy_awards (id, category, year_awarded, ...
INSERT INTO academy_awards (id, category, year_awarded, ...
INSERT INTO academy_awards (id, category, year_awarded, ...
INSERT INTO academy_awards (id, category, year_awarded, ...
INSERT INTO academy_awards (id, category, year_awarded, ...
-- academy_awards_movies
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
INSERT INTO academy_awards_movies (id, academy_award_id,...
-- Output
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
- Step 4
-- SQL statements
select id, first_name, middle_name, last_name, street_ad...
select * from rentals where rental_date >= (sysdate-30) ...
select * from distributors order by name;
update customers set last_name = 'Jones' where id = 4;
-- Output
ID FIRST_NAME MIDDLE_NAME L...
---------------------- --------------- --------------- -...
1 John D. S...
2 Jane S...
3 Myke H. J...
4 Anne M...
5 Bob B...
5 rows selected
ID CUSTOMER_ID INVENTORY_...
---------------------- ---------------------- ----------...
1 1 1 ...
2 2 4 ...
3 2 4 ...
4 4 9 ...
5 5 13 ...
6 5 13 ...
7 2 16 ...
8 3 17 ...
9 3 17 ...
10 5 21 ...
11 1 22 ...
11 rows selected
ID NAME ...
---------------------- ---------------------------------...
1 A Corporation ...
2 B Inc. ...
3 C LLC. ...
3 rows selected
1 rows updated
- ERD
#ref(CMIS320_PRJ2_ERD.png,,80%)
- GitHub Repository: https://github.com/yujishimojo/CMIS3...
** Week 7 Creating and Using Tables [#q6a86066]
- Question
Use SQL to Create a table with at least 4 attributes one ...
Then, insert 2 records into the table.
Finally, use a select statement to show the content of yo...
Be sure your SQL statements work without issue and show e...
- Answer
I created a students table as shown in the ERD below and ...
#ref(CMIS320_W7_ERD.png,,80%)
/* Creates the students table. */
CREATE TABLE students (
student_id number(5,0) NOT NULL UNIQUE,
last_name char NOT NULL,
first_name char NOT NULL,
middle_name char,
enrolled_at date NOT NULL,
finished_at date,
active_status varchar2(1) NOT NULL,
date_of_birthday date NOT NULL,
gender varchar2(1) NOT NULL,
address char NOT NULL,
city char NOT NULL,
state char NOT NULL,
zip_code number(10,0) NOT NULL,
PRIMARY KEY (student_id)
);
/* Inserts two records into the students table. */
INSERT ALL
INTO students (
last_name,
first_name,
enrolled_at date,
active_status,
gender,
date_of_birthday,
address,
city,
state,
zip_code
) values (
'Smith',
'John',
'7/1/2015',
't',
'm',
'4/1/1996',
'123 Cherry Stree',
'San Jose',
'CA'
95124
)
INTO students (
last_name,
first_name,
enrolled_at date,
active_status,
gender,
date_of_birthday,
address,
city,
state,
zip_code
) values (
'Smith',
'Jane',
'7/1/2015',
't',
'f',
'3/1/1996',
'456 Blossom Avenue',
'Santa Clara',
'CA'
950506709
)
SELECT * FROM dual;
/* Retrieves all the records of the students table. */
SELECT *
FROM students;
#ref(CMIS320_W7_TableInfo.png,,80%)
** Week 8 Advanced database topics [#k763eebb]
- Question
For your final discussion topic, repond to at least one o...
1) In reviewing current help wanted advertising in the pa...
2) What is PL/SQL and how can that be used in DBA and dat...
3) What are stored procedures and triggers and how are th...
4) What trends in Database technology seem to be most pro...
- Answer
''2) What is PL/SQL and how can that be used in DBA and d...
''3) What are stored procedures and triggers and how are ...
A stored procedure is a group of SQL statements. Most of ...
PL/SQL is a stored procedure for Oracle Database, which i...
CENTER:References
-- Chapple, M. (n.d.). Stored Procedure. '''About.com,'''...
-- Hall, T. (n.d.). Introduction to PL/SQL, Retrieved Jul...
-- Owens, K. (2003). '''Programming Oracle Triggers and S...
** Research Paper [#qfad325f]
- Question
''Instructions''
Write a two-page executive summary for your boss explaini...
Your paper must follow all APA Style Guide requirements. ...
Submissions:
1. You should submit your well-organized Word document in...
2. You should name your paper Yourname_shortpaper.docx.
- Answer
#ref(CMIS320_ResearchPaper.pdf)
ページ名: