In: Computer Science
Write CREATE TABLE and INSERT INTO statements in order to create and populate five tables in Oracle’s SQL*Plus.The information you need about the database ARE IN THE CHARTS BELOW.
Each worksheet includes the following information about its associated table:
➢ Column names (for example, the jr_order table contains the orderID, customerID, orderDate, orderStatus, and orderShippedDate columns);
➢ Column data types (for example, orderID is INT, orderStatus is VARCHAR2(2), etc.);
➢ Column constraints, if any (for example, orderID in the jr_order table is a primary key,
supplierName in the jr_supplier table is NOT NULL, etc.); and
➢ All values (i.e., the data).
Example INSERT code for each table
[Note that each of these INSERT INTO statements corresponds to the first row in its respective Excel worksheet!]
Example INSERT code for the xx_customer table
INSERT INTO jr_customer (
customerID, customerLastName, customerFirstName,
customerCity, customerState, customerZIP, customerEmail,
jr_customerPhoneNum ) VALUES (1,'Alexander','Michael',
'Highland Heights','KY','41076','[email protected]',NULL) ;
Example INSERT code for the xx_supplier table
INSERT INTO jr_supplier (
supplierID, supplierName, supplierCity, supplierState,
supplierContactName, supplierContactTitle, supplierContactEmail )
VALUES (1,'Reaper','Denton',’TX’,
'John Franklin','Product Marketing Manager','[email protected]') ;
Example INSERT code for the xx_order table
INSERT INTO jr_order (
orderID, customerID, orderDate, orderStatus, orderShippedDate )
VALUES (1,1,TO_DATE('2018-03-01','yyyy-mm-dd'),'SP',
TO_DATE('2018-03-04','yyyy-mm-dd') ) ;
Example INSERT code for the xx_product table
INSERT INTO jr_product (
productCode, supplierID, productName, suggestedPrice,
unitsInStock, unitsOnOrder, discontinued ) VALUES
('IM511',2,'Cloaked Assassin',4.95,4,1,'N') ;
Example INSERT code for the xx_orderLine table
INSERT INTO jr_orderLine (
orderLineID, orderID, productCode, quantity, unitPrice )
VALUES (1,1,'IM511',1,5.49) ;
MS EXCEL WORKBOOK INFO:
SUPPLIER:
customerID |
|
|
|
|
|
|
|
|||||||||
INT |
|
|
|
|
|
|
|
|||||||||
PRIMARY KEY |
|
|
||||||||||||||
1 | Alexander | Michael | Highland Heights | KY | 41706 |
|
|
|||||||||
2 | Clark | Franklin | Amelia | OH | 45102 |
|
|
|||||||||
3 | Philips | Trevor | Newtown | OH | 45244 |
|
|
|||||||||
4 | Butler | Ashley | Erlanger | KY | 42017 |
|
|
|||||||||
5 | Landon | Frank | Reading | OH | 45215 |
|
|
|||||||||
6 | Herbert | Floyd | Cincinnati | OH | 45211 |
|
|
|||||||||
7 | McGee | Martin | Cincinnati | OH | 45238 |
|
|
ORDER:
orderID | customerID | orderDate | orderStatus | orderShippedDate |
INT | INT | DATE | VARCHAR2(2) | DATE |
PRIMARY KEY | NOT NULL, foreign key | NOT NULL | NOT NULL | |
1 | 1 | 2018-03-01 | SP | 2018-03-04 |
2 | 2 | 2018-03-02 | SP | 2018-03-04 |
3 | 3 | 2018-03-03 | SP | 2018-03-05 |
4 | 4 | 2018-03-03 | SP | 2018-03-05 |
5 | 5 | 2018-03-05 | SP | 2018-03-07 |
6 | 6 | 2018-03-05 | SP | 2018-03-08 |
7 | 7 | 2018-03-08 | SP | 2018-03-10 |
16 | 2 | 2018-03-15 | SP | 2018-03-17 |
17 | 4 | 2018-03-16 | SP | 2018-03-19 |
20 | 7 | 2018-03-18 | SP | 2018-03-20 |
23 | 5 | 2018-03-20 | SP | 2018-03-22 |
PRODUCT:
productCode | supplierID | productName | suggestedPrice | unitsInStock | unitsOnOrder | discontinued |
VARCHAR2(15) | INT | VARCHAR2(30) | NUMBER(5,2) | NUMBER(3) | NUMBER(3) | VARCHAR2(1) |
PRIMARY KEY | NOT NULL, foreign key | NOT NULL | ||||
IM511 | 2 | Cloaked Assassin | 4.95 | 4 | 1 | N |
IM514 | 2 | Hooded Female Thief | 4.25 | 3 | 0 | N |
IM517 | 2 | Cleric with Staff | 4.95 | 5 | 2 | N |
IM519 | 2 | Berserker | 3.71 | 2 | 1 | N |
IM527 | 2 | Grand Mystic | 4.95 | 3 | 0 | N |
IM537 | 2 | Hydra | 29.95 | 3 | 0 | Y |
IM539 | 2 | Umber Hulk | 11.59 | 4 | 1 | N |
IM540 | 2 | Wraith | 5.25 | 6 | 2 | N |
IM556 | 2 | Heroic Paladin | 5.99 | 7 | 3 | N |
IM657 | 2 | Two-Headed Troll | 12.99 | 2 | 0 | Y |
R03495 | 1 | Werewolf | 9.99 | 3 | 0 | Y |
R03515 | 1 | Dervish Warrior | 4.99 | 4 | 2 | N |
R03527 | 1 | Scourge Devil | 11.99 | 1 | 2 | N |
R03581 | 1 | Human Ranger | 7.49 | 9 | 2 | N |
R03669 | 1 | Dark Elf | 7.99 | 8 | 0 | N |
OrderLine:
orderLineID | orderID | productCode | quantity | unitPrice |
INT | INT | VARCHAR2(15) | NUMBER(3) | NUMBER(5,2) |
PRIMARY KEY | NOT NULL, foreign key | NOT NULL, foreign key | NOT NULL | NOT NULL |
1 | 1 | IM511 | 1 | 5.49 |
2 | 1 | R03495 | 1 | 10.99 |
3 | 2 | IM514 | 1 | 4.99 |
4 | 3 | IM517 | 1 | 4.99 |
5 | 4 | R03515 | 1 | 5.99 |
6 | 5 | R03669 | 1 | 8.99 |
7 | 6 | IM657 | 1 | 12.99 |
9 | 7 | R03527 | 1 | 11.99 |
8 | 7 | R03581 | 2 | 7.49 |
19 | 16 | IM527 | 1 | 4.95 |
18 | 16 | IM537 | 1 | 34.95 |
20 | 16 | IM540 | 1 | 5.99 |
21 | 17 | IM556 | 1 | 6.99 |
27 | 20 | IM519 | 1 | 4.19 |
31 | 23 | IM539 | 1 | 12.49 |
Here are the SQL statements:
CREATE TABLE jr_customer (customerID number(10) NOT NULL, customerLastName varchar2(20) NOT NULL, customerFirstName varchar2(20) NOT NULL, customerCity varchar2(20) NOT NULL, customerState varchar2(2) NOT NULL, customerZIP varchar2(5) NOT NULL, customerEmail varchar2(25) NOT NULL,jr_customerPhoneNum varchar2(15), CONSTRAINT customers_pk PRIMARY KEY (customerID) );
CREATE TABLE jr_supplier (supplierID number(10) NOT NULL, supplierName varchar2(20) NOT NULL, supplierCity varchar2(20) NOT NULL, supplierState varchar2(2) NOT NULL, supplierContactName varchar2(20) NOT NULL, supplierContactTitle varchar2(20) NOT NULL, supplierContactEmail varchar2(25) NOT NULL, CONSTRAINT supplier_pk PRIMARY KEY (supplierID));
CREATE TABLE jr_order (orderID number(10) NOT NULL, customerID number(10) NOT NULL, orderDate date, orderStatus varchar2(2) NOT NULL, orderShippedDate date, CONSTRAINT order_pk PRIMARY KEY (orderID), CONSTRAINT fk_cust FOREIGN KEY (customerID) REFERENCES jr_customer(customerID));
CREATE TABLE jr_product (productCode varchar2(10) NOT NULL, supplierID number(10) NOT NULL, productName varchar2(10) NOT NULL, suggestedPrice number(10, 2) NOT NULL, unitsInStock number(10) NOT NULL, unitsOnOrder number(10) NOT NULL, discontinued varchar2(1) NOT NULL, CONSTRAINT product_pk PRIMARY KEY (productCode), CONSTRAINT fk_sup FOREIGN KEY (supplierID) REFERENCES jr_supplier (supplierID));
CREATE TABLE jr_orderLine (orderLineID number(10) NOT NULL, orderID number(10) NOT NULL, productCode varchar2(10) NOT NULL, quantity number(10) NOT NULL, unitPrice number(10, 2) NOT NULL, CONSTRAINT orderline_pk PRIMARY KEY (orderLineID), CONSTRAINT o_fk FOREIGN KEY (orderID) REFERENCES jr_order (orderID), CONSTRAINT pc_fk FOREIGN KEY (productCode) REFERENCES jr_product (productCode));
INSERT INTO jr_customer (customerID, customerLastName, customerFirstName, customerCity, customerState, customerZIP, customerEmail,jr_customerPhoneNum ) VALUES
(1,'Alexander','Michael','Highland Heights','KY','41076','[email protected]',NULL) ;
INSERT INTO jr_customer (customerID, customerLastName, customerFirstName, customerCity, customerState, customerZIP, customerEmail,jr_customerPhoneNum ) VALUES
(2,'Clark','Franklin','Amelia','OH','45102','[email protected]','513-293-4435') ;
INSERT INTO jr_customer (customerID, customerLastName, customerFirstName, customerCity, customerState, customerZIP, customerEmail,jr_customerPhoneNum ) VALUES
(3,'Philips','Trevor','Newtown','OH','45244','[email protected]',NULL) ;
INSERT INTO jr_customer (customerID, customerLastName, customerFirstName, customerCity, customerState, customerZIP, customerEmail,jr_customerPhoneNum ) VALUES
(4,'Butler','Ashley','Erlanger','KY','42017','[email protected]','859-563-8090') ;
INSERT INTO jr_customer (customerID, customerLastName, customerFirstName, customerCity, customerState, customerZIP, customerEmail,jr_customerPhoneNum ) VALUES
(5,'Landon','Frank','Reading','OH','45215','[email protected]',NULL) ;
INSERT INTO jr_customer (customerID, customerLastName, customerFirstName, customerCity, customerState, customerZIP, customerEmail,jr_customerPhoneNum ) VALUES
(6,'Herbert','Floyd','Cincinnati','OH','45211','[email protected]',NULL) ;
INSERT INTO jr_customer (customerID, customerLastName, customerFirstName, customerCity, customerState, customerZIP, customerEmail,jr_customerPhoneNum ) VALUES
(7,'McGee','Martin','Cincinnati','OH','45238','[email protected]',NULL) ;
INSERT INTO jr_supplier (supplierID, supplierName, supplierCity, supplierState, supplierContactName, supplierContactTitle, supplierContactEmail ) VALUES
(1,'Reaper','Denton',’TX’,'John Franklin','Product Marketing Manager','[email protected]') ;
INSERT INTO jr_order (orderID, customerID, orderDate, orderStatus, orderShippedDate ) VALUES
(1,1,TO_DATE('2018-03-01','yyyy-mm-dd'),'SP', TO_DATE('2018-03-04','yyyy-mm-dd') ) ;
INSERT INTO jr_order (orderID, customerID, orderDate, orderStatus, orderShippedDate ) VALUES
(2,2,TO_DATE('2018-03-02','yyyy-mm-dd'),'SP', TO_DATE('2018-03-04','yyyy-mm-dd') ) ;
INSERT INTO jr_order (orderID, customerID, orderDate, orderStatus, orderShippedDate ) VALUES
(3,3,TO_DATE('2018-03-03','yyyy-mm-dd'),'SP', TO_DATE('2018-03-05','yyyy-mm-dd') ) ;
INSERT INTO jr_order (orderID, customerID, orderDate, orderStatus, orderShippedDate ) VALUES
(4,4,TO_DATE('2018-03-03','yyyy-mm-dd'),'SP', TO_DATE('2018-03-05','yyyy-mm-dd') ) ;
INSERT INTO jr_order (orderID, customerID, orderDate, orderStatus, orderShippedDate ) VALUES
(5,5,TO_DATE('2018-03-05','yyyy-mm-dd'),'SP', TO_DATE('2018-03-07','yyyy-mm-dd') ) ;
INSERT INTO jr_order (orderID, customerID, orderDate, orderStatus, orderShippedDate ) VALUES
(6,6,TO_DATE('2018-03-05','yyyy-mm-dd'),'SP', TO_DATE('2018-03-08','yyyy-mm-dd') ) ;
INSERT INTO jr_order (orderID, customerID, orderDate, orderStatus, orderShippedDate ) VALUES
(7,7,TO_DATE('2018-03-08','yyyy-mm-dd'),'SP', TO_DATE('2018-03-10','yyyy-mm-dd') ) ;
INSERT INTO jr_order (orderID, customerID, orderDate, orderStatus, orderShippedDate ) VALUES
(16,2,TO_DATE('2018-03-15','yyyy-mm-dd'),'SP', TO_DATE('2018-03-17','yyyy-mm-dd') ) ;
INSERT INTO jr_order (orderID, customerID, orderDate, orderStatus, orderShippedDate ) VALUES
(17,4,TO_DATE('2018-03-16','yyyy-mm-dd'),'SP', TO_DATE('2018-03-19','yyyy-mm-dd') ) ;
INSERT INTO jr_order (orderID, customerID, orderDate, orderStatus, orderShippedDate ) VALUES
(20,7,TO_DATE('2018-03-18','yyyy-mm-dd'),'SP', TO_DATE('2018-03-20','yyyy-mm-dd') ) ;
INSERT INTO jr_order (orderID, customerID, orderDate, orderStatus, orderShippedDate ) VALUES
(23,5,TO_DATE('2018-03-20','yyyy-mm-dd'),'SP', TO_DATE('2018-03-22','yyyy-mm-dd') ) ;
INSERT INTO jr_product (productCode, supplierID, productName, suggestedPrice, unitsInStock, unitsOnOrder, discontinued ) VALUES
('IM511',2,'Cloaked Assassin',4.95,4,1,'N') ;
INSERT INTO jr_product (productCode, supplierID, productName, suggestedPrice, unitsInStock, unitsOnOrder, discontinued ) VALUES
('IM514',2,'Hooded Female Thief',4.25,3,0,'N') ;
INSERT INTO jr_product (productCode, supplierID, productName, suggestedPrice, unitsInStock, unitsOnOrder, discontinued ) VALUES
('IM517',2,'Cleric with Staff',4.95,5,2,'N') ;
INSERT INTO jr_product (productCode, supplierID, productName, suggestedPrice, unitsInStock, unitsOnOrder, discontinued ) VALUES
('IM519',2,'Berserker',3.71,2,1,'N') ;
INSERT INTO jr_product (productCode, supplierID, productName, suggestedPrice, unitsInStock, unitsOnOrder, discontinued ) VALUES
('IM527',2,'Grand Mystic',4.95,3,0,'N') ;
INSERT INTO jr_product (productCode, supplierID, productName, suggestedPrice, unitsInStock, unitsOnOrder, discontinued ) VALUES
('IM537',2,'Hydra',29.95,3,0,'Y') ;
INSERT INTO jr_product (productCode, supplierID, productName, suggestedPrice, unitsInStock, unitsOnOrder, discontinued ) VALUES
('IM539',2,'Umber Hulk',11.59,4,1,'N') ;
INSERT INTO jr_product (productCode, supplierID, productName, suggestedPrice, unitsInStock, unitsOnOrder, discontinued ) VALUES
('IM540',2,'Wraith',5.25,6,2,'N') ;
INSERT INTO jr_product (productCode, supplierID, productName, suggestedPrice, unitsInStock, unitsOnOrder, discontinued ) VALUES
('IM556',2,'Heroic Paladin',5.99,7,3,'N') ;
INSERT INTO jr_product (productCode, supplierID, productName, suggestedPrice, unitsInStock, unitsOnOrder, discontinued ) VALUES
('IM657',2,'Two-Headed Troll',12.99,2,0,'Y') ;
INSERT INTO jr_product (productCode, supplierID, productName, suggestedPrice, unitsInStock, unitsOnOrder, discontinued ) VALUES
('R03495',1,'Werewolf',9.99,3,0,'Y') ;
INSERT INTO jr_product (productCode, supplierID, productName, suggestedPrice, unitsInStock, unitsOnOrder, discontinued ) VALUES
('R03515',1,'Dervish Warrior',4.99,4,2,'N') ;
INSERT INTO jr_product (productCode, supplierID, productName, suggestedPrice, unitsInStock, unitsOnOrder, discontinued ) VALUES
('R03527',1,'Scourge Devil',11.99,1,2,'N') ;
INSERT INTO jr_product (productCode, supplierID, productName, suggestedPrice, unitsInStock, unitsOnOrder, discontinued ) VALUES
('R03581',1,'Human Ranger',7.49,9,2,'N') ;
INSERT INTO jr_product (productCode, supplierID, productName, suggestedPrice, unitsInStock, unitsOnOrder, discontinued ) VALUES
('R03669',1,'Dark Elf',7.99,8,0,'N') ;
INSERT INTO jr_orderLine (orderLineID, orderID, productCode, quantity, unitPrice ) VALUES
(1,1,'IM511',1,5.49) ;
INSERT INTO jr_orderLine (orderLineID, orderID, productCode, quantity, unitPrice ) VALUES
(2,1,'R03495',1,10.99) ;
INSERT INTO jr_orderLine (orderLineID, orderID, productCode, quantity, unitPrice ) VALUES
(3,2,'IM514',1,4.99) ;
INSERT INTO jr_orderLine (orderLineID, orderID, productCode, quantity, unitPrice ) VALUES
(4,3,'IM517',1,4.99) ;
INSERT INTO jr_orderLine (orderLineID, orderID, productCode, quantity, unitPrice ) VALUES
(5,4,'R03515',1,5.99) ;
INSERT INTO jr_orderLine (orderLineID, orderID, productCode, quantity, unitPrice ) VALUES
(6,5,'R03669',1,8.99) ;
INSERT INTO jr_orderLine (orderLineID, orderID, productCode, quantity, unitPrice ) VALUES
(7,6,'IM657',1,12.99) ;
INSERT INTO jr_orderLine (orderLineID, orderID, productCode, quantity, unitPrice ) VALUES
(9,7,'R03527',1,11.99) ;
INSERT INTO jr_orderLine (orderLineID, orderID, productCode, quantity, unitPrice ) VALUES
(8,7,'R03581',2,7.49) ;
INSERT INTO jr_orderLine (orderLineID, orderID, productCode, quantity, unitPrice ) VALUES
(19,16,'IM527',1,4.95) ;
INSERT INTO jr_orderLine (orderLineID, orderID, productCode, quantity, unitPrice ) VALUES
(18,16,'IM537',1,34.95) ;
INSERT INTO jr_orderLine (orderLineID, orderID, productCode, quantity, unitPrice ) VALUES
(20,16,'IM540',1,5.99) ;
INSERT INTO jr_orderLine (orderLineID, orderID, productCode, quantity, unitPrice ) VALUES
(21,17,'IM556',1,6.99) ;
INSERT INTO jr_orderLine (orderLineID, orderID, productCode, quantity, unitPrice ) VALUES
(27,20,'IM519',1,4.19) ;
INSERT INTO jr_orderLine (orderLineID, orderID, productCode, quantity, unitPrice ) VALUES
(31,23,'IM539',1,12.49) ;