/* When debugging the code, use Drop table statements
to drop previously created tables.
When code is re-run, new tables will be created.
This allows easy debugging. */
Drop table dept cascade constraints;
Drop table emp cascade constraints;
Drop table customer cascade constraints;
Drop table product cascade constraints;
Drop table ord cascade constraints;
Drop table item cascade constraints;
Drop table salgrade cascade constraints;
Drop table bonus cascade constraints;
Drop table price cascade constraints;
Drop table dummy cascade constraints;
Purge RecycleBin;
CREATE TABLE DEPT (
DEPTNO NUMBER(2) NOT NULL,
DNAME VARCHAR2(14),
LOC VARCHAR2(13),
CONSTRAINT DEPT_PRIMARY_KEY PRIMARY KEY (DEPTNO));
INSERT INTO DEPT VALUES (10,'ACCOUNTING','NEW YORK');
INSERT INTO DEPT VALUES (20,'RESEARCH','DALLAS');
INSERT INTO DEPT VALUES (30,'SALES','CHICAGO');
INSERT INTO DEPT VALUES (40,'OPERATIONS','BOSTON');
CREATE TABLE EMP (
EMPNO NUMBER(4) NOT NULL,
ENAME VARCHAR2(10),
JOB VARCHAR2(9),
MGR NUMBER(4) CONSTRAINT EMP_MGR_FK REFERENCES EMP (EMPNO),
HIREDATE DATE,
SAL NUMBER(7,2),
COMM NUMBER(7,2),
DEPTNO NUMBER(2) NOT NULL,
CONSTRAINT EMP_DEPTNO_FK FOREIGN KEY (DEPTNO) REFERENCES DEPT (DEPTNO),
CONSTRAINT EMP_EMPNO_PK PRIMARY KEY (EMPNO));
INSERT INTO EMP VALUES (7839,'KING','PRESIDENT',NULL,TO_DATE('17-NOV-2011','DD-MON-YYYY'),15000,NULL,10);
INSERT INTO EMP VALUES (7698,'Blake','MANAGER',7839,TO_DATE('1-MAY-2012','DD-MON-YYYY'),6850,NULL,30);
INSERT INTO EMP VALUES (7782,'CLARK','MANAGER',7839,TO_DATE('9-JUN-2013','DD-MON-YYYY'),5450,NULL,10);
INSERT INTO EMP VALUES (7566,'Jones','MANAGER',7839,TO_DATE('2-APR-2011','DD-MON-YYYY'),5975,NULL,20);
INSERT INTO EMP VALUES (7654,'Martin','SALESMAN',7698,TO_DATE('28-SEP-2012','DD-MON-YYYY'),4250,27400,30);
INSERT INTO EMP VALUES (7499,'ALLEN','SALESMAN',7698,TO_DATE('20-FEB-2013','DD-MON-YYYY'),3600,16300,30);
INSERT INTO EMP VALUES (7844,'TURNER','SALESMAN',7698,TO_DATE('8-SEP-2014','DD-MON-YYYY'),3500,0,30);
INSERT INTO EMP VALUES (7900,'James','CLERK',7698,TO_DATE('3-DEC-2015','DD-MON-YYYY'),4950,NULL,30);
INSERT INTO EMP VALUES (7521,'WARD','SALESMAN',7698,TO_DATE('22-FEB-2016','DD-MON-YYYY'),3250,55500,30);
INSERT INTO EMP VALUES (7902,'ford','ANALYST',7566,TO_DATE('3-DEC-2016','DD-MON-YYYY'),6000,NULL,20);
INSERT INTO EMP VALUES (7369,'SMITH','CLERK',7902,TO_DATE('17-DEC-2015','DD-MON-YYYY'),3800,NULL,20);
INSERT INTO EMP VALUES (7788,'SCOTT','ANALYST',7566,TO_DATE('09-DEC-2014','DD-MON-YYYY'),6000,NULL,20);
INSERT INTO EMP VALUES (7876,'ADAMS','CLERK',7788,TO_DATE('12-JAN-2013','DD-MON-YYYY'),4100,NULL,20);
INSERT INTO EMP VALUES (7934,'MILLER','CLERK',7782,TO_DATE('23-JAN-2016','DD-MON-YYYY'),4300,NULL,10);
CREATE TABLE BONUS (
ENAME VARCHAR2(10),
JOB ...
When debugging the code, use Drop table statementsto drop pr.docx
1. /* When debugging the code, use Drop table statements
to drop previously created tables.
When code is re-run, new tables will be created.
This allows easy debugging. */
Drop table dept cascade constraints;
Drop table emp cascade constraints;
Drop table customer cascade constraints;
Drop table product cascade constraints;
Drop table ord cascade constraints;
Drop table item cascade constraints;
Drop table salgrade cascade constraints;
Drop table bonus cascade constraints;
Drop table price cascade constraints;
Drop table dummy cascade constraints;
Purge RecycleBin;
2. CREATE TABLE DEPT (
DEPTNO NUMBER(2) NOT NULL,
DNAME VARCHAR2(14),
LOC VARCHAR2(13),
CONSTRAINT DEPT_PRIMARY_KEY PRIMARY KEY
(DEPTNO));
INSERT INTO DEPT VALUES (10,'ACCOUNTING','NEW
YORK');
INSERT INTO DEPT VALUES (20,'RESEARCH','DALLAS');
INSERT INTO DEPT VALUES (30,'SALES','CHICAGO');
INSERT INTO DEPT VALUES
(40,'OPERATIONS','BOSTON');
CREATE TABLE EMP (
EMPNO NUMBER(4) NOT NULL,
ENAME VARCHAR2(10),
JOB VARCHAR2(9),
MGR NUMBER(4) CONSTRAINT EMP_MGR_FK
3. REFERENCES EMP (EMPNO),
HIREDATE DATE,
SAL NUMBER(7,2),
COMM NUMBER(7,2),
DEPTNO NUMBER(2) NOT NULL,
CONSTRAINT EMP_DEPTNO_FK FOREIGN KEY (DEPTNO)
REFERENCES DEPT (DEPTNO),
CONSTRAINT EMP_EMPNO_PK PRIMARY KEY (EMPNO));
INSERT INTO EMP VALUES
(7839,'KING','PRESIDENT',NULL,TO_DATE('17-NOV-
2011','DD-MON-YYYY'),15000,NULL,10);
INSERT INTO EMP VALUES
(7698,'Blake','MANAGER',7839,TO_DATE('1-MAY-2012','DD-
MON-YYYY'),6850,NULL,30);
INSERT INTO EMP VALUES
(7782,'CLARK','MANAGER',7839,TO_DATE('9-JUN-
2013','DD-MON-YYYY'),5450,NULL,10);
INSERT INTO EMP VALUES
(7566,'Jones','MANAGER',7839,TO_DATE('2-APR-2011','DD-
MON-YYYY'),5975,NULL,20);
INSERT INTO EMP VALUES
(7654,'Martin','SALESMAN',7698,TO_DATE('28-SEP-
2012','DD-MON-YYYY'),4250,27400,30);
INSERT INTO EMP VALUES
4. (7499,'ALLEN','SALESMAN',7698,TO_DATE('20-FEB-
2013','DD-MON-YYYY'),3600,16300,30);
INSERT INTO EMP VALUES
(7844,'TURNER','SALESMAN',7698,TO_DATE('8-SEP-
2014','DD-MON-YYYY'),3500,0,30);
INSERT INTO EMP VALUES
(7900,'James','CLERK',7698,TO_DATE('3-DEC-2015','DD-
MON-YYYY'),4950,NULL,30);
INSERT INTO EMP VALUES
(7521,'WARD','SALESMAN',7698,TO_DATE('22-FEB-
2016','DD-MON-YYYY'),3250,55500,30);
INSERT INTO EMP VALUES
(7902,'ford','ANALYST',7566,TO_DATE('3-DEC-2016','DD-
MON-YYYY'),6000,NULL,20);
INSERT INTO EMP VALUES
(7369,'SMITH','CLERK',7902,TO_DATE('17-DEC-2015','DD-
MON-YYYY'),3800,NULL,20);
INSERT INTO EMP VALUES
(7788,'SCOTT','ANALYST',7566,TO_DATE('09-DEC-
2014','DD-MON-YYYY'),6000,NULL,20);
INSERT INTO EMP VALUES
(7876,'ADAMS','CLERK',7788,TO_DATE('12-JAN-2013','DD-
MON-YYYY'),4100,NULL,20);
INSERT INTO EMP VALUES
(7934,'MILLER','CLERK',7782,TO_DATE('23-JAN-2016','DD-
MON-YYYY'),4300,NULL,10);
5. CREATE TABLE BONUS (
ENAME VARCHAR2(10),
JOB VARCHAR2(9),
SAL NUMBER,
COMM NUMBER);
CREATE TABLE SALGRADE (
GRADE NUMBER,
LOSAL NUMBER,
HISAL NUMBER);
INSERT INTO SALGRADE VALUES (1,700,1200);
INSERT INTO SALGRADE VALUES (2,1201,1400);
INSERT INTO SALGRADE VALUES (3,1401,2000);
INSERT INTO SALGRADE VALUES (4,2001,3000);
INSERT INTO SALGRADE VALUES (5,3001,9999);
CREATE TABLE DUMMY (
DUMMY NUMBER );
6. INSERT INTO DUMMY VALUES (0);
CREATE TABLE CUSTOMER (
CUSTID NUMBER (6) NOT NULL,
NAME VARCHAR2 (45),
ADDRESS VARCHAR2 (40),
CITY VARCHAR2 (30),
STATE VARCHAR2 (2),
ZIP VARCHAR2 (9),
AREA NUMBER (3),
PHONE VARCHAR2 (9),
REPID NUMBER (4) NOT NULL,
CREDITLIMIT NUMBER (9,2),
COMMENTS VARCHAR2 (256),
CONSTRAINT CUSTOMER_CUSTID_PK PRIMARY KEY
(CUSTID),
CONSTRAINT CUSTOMER_CUSTID_CK CHECK (CUSTID >
0));
7. CREATE TABLE ORD (
ORDID NUMBER (4) NOT NULL,
ORDERDATE DATE,
COMMPLAN VARCHAR2 (1),
CUSTID NUMBER (6) NOT NULL,
SHIPDATE DATE,
TOTAL NUMBER (8,2) CONSTRAINT
ORD_TOTAL_CK CHECK (TOTAL >= 0),
CONSTRAINT ORD_CUSTID_FK FOREIGN KEY (CUSTID)
REFERENCES CUSTOMER (CUSTID),
CONSTRAINT ORD_ORDID_PK PRIMARY KEY (ORDID));
CREATE TABLE ITEM (
ORDID NUMBER (4) NOT NULL,
ITEMID NUMBER (4) NOT NULL,
PRODID NUMBER (6),
ACTUALPRICE NUMBER (8,2),
QTY NUMBER (8),
ITEMTOT NUMBER (8,2),
8. CONSTRAINT ITEM_ORDID_FK FOREIGN KEY (ORDID)
REFERENCES ORD (ORDID),
CONSTRAINT ITEM_ORDID_ITEMID_PK PRIMARY KEY
(ORDID,ITEMID));
CREATE TABLE PRODUCT (
PRODID NUMBER (6) CONSTRAINT PRODID_PK
PRIMARY KEY,
DESCRIP VARCHAR2 (30));
CREATE TABLE PRICE (
PRODID NUMBER (6) NOT NULL,
STDPRICE NUMBER (8,2),
MINPRICE NUMBER (8,2),
STARTDATE DATE,
ENDDATE DATE);
INSERT INTO CUSTOMER (ZIP, STATE, REPID, PHONE,
NAME, CUSTID, CREDITLIMIT,
CITY, AREA, ADDRESS, COMMENTS)
9. VALUES ('96711', 'CA', '7844', '598-6609',
'JOCKSPORTS',
'100', '5000', 'BELMONT', '415', '345 VIEWRIDGE',
'Very friendly people to work with -- sales rep likes to be
called Mike.');
INSERT INTO CUSTOMER (ZIP, STATE, REPID, PHONE,
NAME, CUSTID, CREDITLIMIT,
CITY, AREA, ADDRESS, COMMENTS)
VALUES ('94061', 'CA', '7521', '368-1223',
'TKB SPORT SHOP',
'101', '10000', 'REDWOOD CITY', '415', '490 BOLI RD.',
'Rep called 5/8 about change in order - contact shipping.');
INSERT INTO CUSTOMER (ZIP, STATE, REPID, PHONE,
NAME, CUSTID, CREDITLIMIT,
CITY, AREA, ADDRESS, COMMENTS)
VALUES ('95133', 'CA', '7654', '644-3341',
'VOLLYRITE',
'102', '7000', 'BURLINGAME', '415', '9722 HAMILTON',
'Company doing heavy promotion beginning 10/89. Prepare for
large orders during
10. winter.');
INSERT INTO CUSTOMER (ZIP, STATE, REPID, PHONE,
NAME, CUSTID, CREDITLIMIT,
CITY, AREA, ADDRESS, COMMENTS)
VALUES ('97544', 'CA', '7521', '677-9312',
'JUST TENNIS',
'103', '3000', 'BURLINGAME', '415', 'HILLVIEW MALL',
'Contact rep about new line of tennis rackets.');
INSERT INTO CUSTOMER (ZIP, STATE, REPID, PHONE,
NAME, CUSTID, CREDITLIMIT,
CITY, AREA, ADDRESS, COMMENTS)
VALUES ('93301', 'CA', '7499', '996-2323',
'EVERY MOUNTAIN',
'104', '10000', 'CUPERTINO', '408', '574 SUYYYYY RD.',
'Customer with high market share (23%) due to aggressive
advertising.');
INSERT INTO CUSTOMER (ZIP, STATE, REPID, PHONE,
NAME, CUSTID, CREDITLIMIT,
CITY, AREA, ADDRESS, COMMENTS)
VALUES ('91003', 'CA', '7844', '376-9966',
11. 'K + T SPORTS',
'105', '5000', 'SANTA CLARA', '408', '3476 EL PASEO',
'Tends to order large amounts of merchandise at once.
Accounting is considering
raising their credit limit. Usually pays on time.');
INSERT INTO CUSTOMER (ZIP, STATE, REPID, PHONE,
NAME, CUSTID, CREDITLIMIT,
CITY, AREA, ADDRESS, COMMENTS)
VALUES ('94301', 'CA', '7521', '364-9777',
'SHAPE UP',
'106', '6000', 'PALO ALTO', '415', '908 SEQUOIA',
'Support intensive. Orders small amounts (< 800) of
merchandise at a time.');
INSERT INTO CUSTOMER (ZIP, STATE, REPID, PHONE,
NAME, CUSTID, CREDITLIMIT,
CITY, AREA, ADDRESS, COMMENTS)
VALUES ('93301', 'CA', '7499', '967-4398',
'WOMENS SPORTS',
'107', '10000', 'SUNNYVALE', '408', 'VALCO VILLAGE',
'First sporting goods store geared exclusively towards women.
12. Unusual promotion
al style and very willing to take chances towards new
products!');
INSERT INTO CUSTOMER (ZIP, STATE, REPID, PHONE,
NAME, CUSTID, CREDITLIMIT,
CITY, AREA, ADDRESS, COMMENTS)
VALUES ('55649', 'MN', '7844', '566-9123',
'NORTH WOODS HEALTH AND FITNESS SUPPLY
CENTER',
'108', '8000', 'HIBBING', '612', '98 LONE PINE WAY', '');
INSERT INTO ORD (TOTAL, SHIPDATE, ORDID,
ORDERDATE, CUSTID, COMMPLAN)
VALUES ('101.4', TO_DATE('08-JAN-2017','DD-MON-
YYYY'), '610', TO_DATE('07-JAN-2017','DD-MON-YYYY'),
'101', 'A');
INSERT INTO ORD (TOTAL, SHIPDATE, ORDID,
ORDERDATE, CUSTID, COMMPLAN)
VALUES ('45', TO_DATE('11-JAN-2017','DD-MON-YYYY'),
'611', TO_DATE('11-JAN-2017','DD-MON-YYYY'), '102', 'B');
INSERT INTO ORD (TOTAL, SHIPDATE, ORDID,
ORDERDATE, CUSTID, COMMPLAN)
VALUES ('5860', TO_DATE('20-JAN-2017','DD-MON-
13. YYYY'), '612', TO_DATE('15-JAN-2017','DD-MON-YYYY'),
'104', 'C');
INSERT INTO ORD (TOTAL, SHIPDATE, ORDID,
ORDERDATE, CUSTID, COMMPLAN)
VALUES ('2.4', TO_DATE('30-MAY-2016','DD-MON-
YYYY'), '601', TO_DATE('01-MAY-2016','DD-MON-YYYY'),
'106', 'A');
INSERT INTO ORD (TOTAL, SHIPDATE, ORDID,
ORDERDATE, CUSTID, COMMPLAN)
VALUES ('56', TO_DATE('20-JUN-2016','DD-MON-YYYY'),
'602', TO_DATE('05-JUN-2016','DD-MON-YYYY'), '102', 'B');
INSERT INTO ORD (TOTAL, SHIPDATE, ORDID,
ORDERDATE, CUSTID, COMMPLAN)
VALUES ('698', TO_DATE('30-JUN-2016','DD-MON-YYYY'),
'604', TO_DATE('15-JUN-2016','DD-MON-YYYY'), '106', 'A');
INSERT INTO ORD (TOTAL, SHIPDATE, ORDID,
ORDERDATE, CUSTID, COMMPLAN)
VALUES ('8324',TO_DATE( '30-JUL-2016','DD-MON-
YYYY'), '605', TO_DATE('14-JUL-2016','DD-MON-YYYY'),
'106', 'A');
INSERT INTO ORD (TOTAL, SHIPDATE, ORDID,
ORDERDATE, CUSTID, COMMPLAN)
VALUES ('3.4', TO_DATE('30-JUL-2016','DD-MON-YYYY'),
'606', TO_DATE('14-JUL-2016','DD-MON-YYYY'), '100', 'A');
INSERT INTO ORD (TOTAL, SHIPDATE, ORDID,
14. ORDERDATE, CUSTID, COMMPLAN)
VALUES ('97.5', TO_DATE('15-AUG-2016','DD-MON-
YYYY'), '609', TO_DATE('01-AUG-2016','DD-MON-YYYY'),
'100', 'B');
INSERT INTO ORD (TOTAL, SHIPDATE, ORDID,
ORDERDATE, CUSTID, COMMPLAN)
VALUES ('5.6', TO_DATE('18-JUL-2016','DD-MON-YYYY'),
'607', TO_DATE('18-JUL-2016','DD-MON-YYYY'), '104', 'C');
INSERT INTO ORD (TOTAL, SHIPDATE, ORDID,
ORDERDATE, CUSTID, COMMPLAN)
VALUES ('35.2', TO_DATE('25-JUL-2016','DD-MON-
YYYY'), '608', TO_DATE('25-JUL-2016','DD-MON-YYYY'),
'104', 'C');
INSERT INTO ORD (TOTAL, SHIPDATE, ORDID,
ORDERDATE, CUSTID, COMMPLAN)
VALUES ('224', TO_DATE('05-JUN-2016','DD-MON-YYYY'),
'603', TO_DATE('05-JUN-2016','DD-MON-YYYY'), '102', '');
INSERT INTO ORD (TOTAL, SHIPDATE, ORDID,
ORDERDATE, CUSTID, COMMPLAN)
VALUES ('4450', TO_DATE('12-MAR-2017','DD-MON-
YYYY'), '620', TO_DATE('12-MAR-2017','DD-MON-YYYY'),
'100', '');
INSERT INTO ORD (TOTAL, SHIPDATE, ORDID,
ORDERDATE, CUSTID, COMMPLAN)
VALUES ('6400', TO_DATE('01-FEB-2017','DD-MON-
15. YYYY'), '613', TO_DATE('01-FEB-2017','DD-MON-YYYY'),
'108', '');
INSERT INTO ORD (TOTAL, SHIPDATE, ORDID,
ORDERDATE, CUSTID, COMMPLAN)
VALUES ('23940', TO_DATE('05-FEB-2017','DD-MON-
YYYY'), '614', TO_DATE('01-FEB-2017','DD-MON-YYYY'),
'102', '');
INSERT INTO ORD (TOTAL, SHIPDATE, ORDID,
ORDERDATE, CUSTID, COMMPLAN)
VALUES ('764', TO_DATE('10-FEB-2017','DD-MON-YYYY'),
'616', TO_DATE('03-FEB-2017','DD-MON-YYYY'), '103', '');
INSERT INTO ORD (TOTAL, SHIPDATE, ORDID,
ORDERDATE, CUSTID, COMMPLAN)
VALUES ('1260', TO_DATE('04-FEB-2017','DD-MON-
YYYY'), '619', TO_DATE('22-FEB-2017','DD-MON-YYYY'),
'104', '');
INSERT INTO ORD (TOTAL, SHIPDATE, ORDID,
ORDERDATE, CUSTID, COMMPLAN)
VALUES ('46370', TO_DATE('03-MAR-2017','DD-MON-
YYYY'), '617', TO_DATE('05-FEB-2017','DD-MON-YYYY'),
'105', '');
INSERT INTO ORD (TOTAL, SHIPDATE, ORDID,
ORDERDATE, CUSTID, COMMPLAN)
VALUES ('710', TO_DATE('06-FEB-2017','DD-MON-YYYY'),
'615', TO_DATE('01-FEB-2017','DD-MON-YYYY'), '107', '');
29. INSERT INTO PRODUCT (PRODID, DESCRIP)
VALUES ('100861', 'ACE TENNIS RACKET II');
INSERT INTO PRODUCT (PRODID, DESCRIP)
VALUES ('100870', 'ACE TENNIS BALLS-3 PACK');
INSERT INTO PRODUCT (PRODID, DESCRIP)
VALUES ('100871', 'ACE TENNIS BALLS-6 PACK');
INSERT INTO PRODUCT (PRODID, DESCRIP)
VALUES ('100890', 'ACE TENNIS NET');
INSERT INTO PRODUCT (PRODID, DESCRIP)
VALUES ('101860', 'SP TENNIS RACKET');
INSERT INTO PRODUCT (PRODID, DESCRIP)
VALUES ('101863', 'SP JUNIOR RACKET');
INSERT INTO PRODUCT (PRODID, DESCRIP)
VALUES ('102130', 'RH: "GUIDE TO TENNIS"');
INSERT INTO PRODUCT (PRODID, DESCRIP)
VALUES ('200376', 'SB ENERGY BAR-6 PACK');
INSERT INTO PRODUCT (PRODID, DESCRIP)
VALUES ('200380', 'SB VITA SNACK-6 PACK');
30. commit;
set feedback off
cl screen
set heading off
/* Drop Table statements are used during the code debugging
stage.
Once code is correct, they are no longer needed.
However, one can keep the statements for re-creating the initial
tables
later.*/
drop table TranDetail cascade constraints;
drop table Book cascade constraints;
drop table Tran cascade constraints;
drop table BookType cascade constraints;
drop table Student cascade constraints;
31. purge recyclebin;
Create table TranDetail
(TranID number(4),
Bcode varchar2(5),
ReturnDate Date);
insert into TranDetail values (1,'3330', to_date('3/5/2015
14:15:31','dd/mm/yyyy hh24:mi:ss'));
insert into TranDetail values (1,'9440', to_date('3/6/2015
11:00:21','dd/mm/yyyy hh24:mi:ss'));
insert into TranDetail values (2,'2220', to_date('3/8/2015
12:05:35','dd/mm/yyyy hh24:mi:ss'));
insert into TranDetail values (2,'2510', to_date('3/9/2015
13:32:45','dd/mm/yyyy hh24:mi:ss'));
insert into TranDetail values (3,'2740', to_date('3/9/2016
9:06:07','dd/mm/yyyy hh24:mi:ss'));
insert into TranDetail values (4,'3330', to_date('3/8/2016
8:30:46','dd/mm/yyyy hh24:mi:ss'));
insert into TranDetail values (4,'9440', to_date('3/8/2016
9:40:23','dd/mm/yyyy hh24:mi:ss'));
32. insert into TranDetail values (5,'1510', to_date('4/5/2016
15:09:45','dd/mm/yyyy hh24:mi:ss'));
insert into TranDetail values (5,'2220', to_date('4/6/2016
19:34:56','dd/mm/yyyy hh24:mi:ss'));
insert into TranDetail values (5,'2510', to_date('4/7/2016
8:56:12','dd/mm/yyyy hh24:mi:ss'));
insert into TranDetail values (6,'2510', to_date('5/6/2016
16:15:34','dd/mm/yyyy hh24:mi:ss'));
insert into TranDetail values (7,'2740', to_date('5/5/2016
11:04:09','dd/mm/yyyy hh24:mi:ss'));
Create table Book
(Bookcode varchar2(5) primary key,
Title varchar2(35),
Type varchar2(20));
insert into Book values ('1510','True confessions','Mistery');
insert into Book values ('2220','The big','Drama');
insert into Book values ('2510','The little mermaid','Children');
insert into Book values ('2740','Backdraft','Action');
insert into Book values ('3330','Steve Jobs','Biograph');
33. insert into Book values ('9440','Other world','Science Fiction');
Create table Tran
(TranID number(4) primary key,
StudentId varchar2(10),
TranDateAndTime date);
insert into Tran values (1,'1002', to_date('3/4/2015
9:45:15','dd/mm/yyyy hh24:mi:ss'));
insert into Tran values (2,'1003', to_date('3/5/2015
15:00:23','dd/mm/yyyy hh24:mi:ss'));
insert into Tran values (3,'1003', to_date('3/6/2016
14:00:45','dd/mm/yyyy hh24:mi:ss'));
insert into Tran values (4,'1004', to_date('3/7/2016
8:45:34','dd/mm/yyyy hh24:mi:ss'));
insert into Tran values (5,'1005', to_date('4/2/2016
9:00:21','dd/mm/yyyy hh24:mi:ss'));
insert into Tran values (6,'1001', to_date('5/2/2016
16:15:44','dd/mm/yyyy hh24:mi:ss'));
insert into Tran values (7,'1003', to_date('5/4/2016
15:00:51','dd/mm/yyyy hh24:mi:ss'));
34. create table Booktype
(typename varchar2(25) primary key,
avgscore number(4,2));
insert into Booktype values('Action',3.00);
insert into Booktype values('Biography',2.50);
insert into Booktype values('Children',4.00);
insert into Booktype values('Drama',3.50);
insert into Booktype values('Mistery',3.50);
insert into Booktype values('Science Fiction',3.50);
Create table Student
(StudentId varchar2(10) primary key,
Fname varchar2(20),
LName varchar2(25),
address varchar2(25),
city varchar2(15),
35. State char(2),
Zip varchar2(5),
Phone varchar2(12),
RegDate Date);
insert into Student values ('1001','Jerry','Seidmann','10 East
Ave','Englewood','CO','80111','303-429-2778',to_date('30-3-
2002','dd-mm-yyyy'));
insert into Student values ('1002','Mary','Taylor','37 South
Ave','Centennial','CO','80112','303-429-8990',to_date('2-4-
2004','dd-mm-yyyy'));
insert into Student values ('1003','Hugh','Ryan','68 Main
St.','Denver','CO','80202','429-742-7243',to_date('1-5-1994','dd-
mm-yyyy'));
insert into Student values ('1004','Robert','Russell','98 Lakeside
Dr.','Denver','CO','80217','720-643-7889',to_date('4-8-2014','dd-
mm-yyyy'));
insert into Student values ('1005','David','Stafford','80 River
Rd.','Bloomfield','CO','80020','303-447-1435',to_date('5-8-
2012','dd-mm-yyyy'));
set feedback on
commit;
36. set heading on
Students may form groups of 1-3 students for the project. One
page project proposal requirements
Please see the following four pages concerning where to find a
project, what projects are unsuitable, and the originality
requirements of the project.
For the one-page proposal on the project chosen, briefly address
these points:
· Describe background of the company;
· Describe relevant daily business operations and information
needed for or generated from those daily business operations.
These daily business operations require information as inputs
and/or generate information as outputs so it would benefit from
having relevant input and output information stored in a
database. For example, if the project chosen is for a store, the
daily operation is customer’s making purchases. You would say
something like this:
“Customers come to the store to select products they want to
buy. When they check out, the system (the store) calculates the
total due (relevant daily business operations). After the
customer pays for the purchase, the store gives the customer a
receipt. These daily business operations require price
information for each product and quantity information for each
product purchased by the customer (Inputs) in order to calculate
the total due. After the transaction is completed, the system
37. (store) stores that this transaction has taken placed, with details
about what were bought, how many, and at what prices
(outputs).”
· Problems with the current way of information (data)
management
· Proposed way of data management (i.e., what data to store in
the database and what functionalities to provide in the interface)
· What is your project source? (See Pages 2-3)
· How and from whom would you obtain data requirements for
the database?
· Who would be the intended users of your database?
· If possible for your project source, provide sample data
(modify any confidential data to preserve confidentiality. In
fact, actual data are NOT needed, only fictitious data that look
like the actual data are needed.) If sample data come on hard
copies of filled-out forms, blank forms filled with fictitious data
that look like the real data are sufficient.
You won’t be receiving a grade for this one-page project
proposal. The purpose of the report is to communicate your
topic selection to me so I can help you decide whether or not
the project is appropriate. Hand in your hard-copy project
proposal in class on or before the due date listed in Canvas and
in the Syllabus. Electronic submissions to Canvas are also
accepted.
Avoid unsuitable projects (See Page 4). You may change your
project idea later if you later find a better project idea. Please
provide another one-page project proposal as described above if
that happens.
Submitting this concept of a database for approval indicates that
you claim the originality of this project (See Pages 4-5).
In the next stage of the project, you’ll need to collect detailed
38. information about what data are needed for those businesses
operations, what data are generated that need to be stored in the
database, and how data relate to each other, that is, business
rules concerning the data. When designing the ERD, having
sample data will help you understand the data better. However,
when eventually submitting your database for grading, fictitious
data are sufficient.Size of the project
The ideal size of the project is 5-7 tables.Database Project
Sources
Decide on an application for which you’ll design the database.
Choose a project where the main purpose is to store and retrieve
operational data. The preferred project is one intended for some
real user(s) (including family and friends). A database intended
for your own use is ok. A made up database with imagined users
is not recommended though acceptable. Here I discuss four
sources of database projects (Pages 2-3). Unsuitable projects are
discussed on Page 4.Project Source 1: Organic
The most organic source of a database project is through your
network of friends, family members, acquaintances, or your own
work place. Many solo or other types of small businesses do not
already have a database for their day-to-day business
operations. Even some medium or large sized companies may
need a small database for non-mission-critical things like
employee training, various task forces, internal “instance”
reports and such, even though they usually have databases for
their core day-to-day business operations.
Here are some organically sourced project examples done by
students in the past:
· A database for a bed-and-breakfast place owned by a student’s
parents. The database keeps track of reservations, checking in,
checking out, and pricing.
39. · A database for a tree farm owned by a student’s parents that
stores information about various trees grown on the farm,
customer orders, and tree deliveries.
· A database for a daycare center operated by a student’s spouse
that stores information about the children, check-in and check-
out times on each day for each child, and their account balances
and payment information.
· A database that stores prospective real estate clients,
viewings, and mailings information for a student’s friend.
· A database that stores information about employee training,
courses they took, and certifications information for a student’s
workplace.
· A database that stores information about various small medical
devices that patients can rent out for a student’s workplace.
· A database that keeps track of various computing devices of
employees, licenses of applications, connections to various
servers etc. for a student’s workplaceProject Source 2: Reverse
engineering a database
If you really can’t find an organic project, before deciding on a
made-up project, try reverse engineering. Reverse engineering
is to design a database based on your interactions with an
existing database on the desktop or on the Web. For example, if
you work as a human resources specialist at a company and use
a human resources management software, you can design a
database based on your knowledge of the type of information
stored in the human resources database and the type of
interactions it affords the user. If you work or worked at a store
that sells and resells computer games and have used the sales
database, you can design a database based on your knowledge
and interactions with that database. You may also interact with
databases on the web (example, Amazon.com’s vast database).
You can design the database (a part of it) based on your
interactions with the ecommerce site.
Do Review Page 4 for originality requirements for reverse
40. reengineering.Project Source 3: Preferred way of making up a
database
If you still can’t find an organic project and can’t find a
database to reverse engineer, the preferred way of making up a
database project is to base your database on a real business that
you’re familiar with. As mentioned before, medium sized or
large companies usually already have databases to support their
day-to-day core business operations. If you work or worked for
a company and are familiar with the core business, you may
make up a database that would support the daily operations of
that company or that would support some other business
operations that you’re familiar with.Project Source 4: Desperate
way of making up a project
If no one in your network seems in need of a database, you have
not interacted with a database that could offer reverse
engineering, you have not worked for any company that used a
database, and you have not worked in a company that can give
you inspirations for a database idea, and you don’t know anyone
who may be able to help you get a project idea, in short, if you
are desperate, then imagine an organization or a business and
imagine how that organization or business work and proceed to
design your database. If you decide to proceed with a made-up
database, your database needs to be substantially different from
any of the examples or homework problems that I have written
up. Also talk to me first before choosing this route.
Unsuitable Projects
1. 1-3 tables: If a database project will end up having only 1-3
tables, it is not suitable because such a project, though maybe
valuable, does not offer you the opportunity to practice ERD or
table design. Examples are NFL team stats database (one table),
catalog of books (book table and category table-2 tables),
customer complaints database (complaints table --1 table). An
ideal project should have about 5-7 tables –complex enough to
41. offer ERD and table design practices and small enough to do as
a class project.
2. Database problems involving other main tasks such as
synchronizing data from multiple databases, integrating one
database into another, automatic uploading of data from an
outside source etc. are interesting and practical database
problems in general. However, they are not the topics of this
course and therefore are not suitable for the class project.
3. If two teams’ projects are too similar to each other’s, they are
not suitable.Originality Requirement
No matter what your source is for the database, it must satisfy
the originality requirement as discussed below.
Each student or team is required to collect and compile their
own information requirements, design the ERD, design the
tables, and implement the database in ACCESS and Oracle. A
project where information requirements are laid out already in
writing or where the ERD is already given, or where the tables
are already designed is not acceptable. When you submit a
project idea for me to approve, the assumption is that the
information requirements do not already exist in a document
written by someone else (changing a few things here and there
is not considered sufficiently different). If this is not the case,
you’re required to disclose that information to me, before the
project is approved.
Sometimes a student may have already done (or is doing)
an original project for a different course. If the project idea is
original to the student, the student may use that same idea in
this course with some penalty points. This is because the
student is using the same work to receive credits in two
different courses. If the database in the other course is not the
original work of the student, for example, when the instructor of
that course gives the information requirements and the ERD,
42. that database can’t be used as the class project.
Reverse engineering: If a student intends to design the database
based on his/her interactions with a user interface, it is
acceptable if 1) the student discloses that reverse engineering is
used based on the available (often web-based) interface, 2)
there is no written document of information requirements
available to the student, and 3) there is no corresponding ERD
or table design available to the student. Situations where these
conditions are not satisfied are unacceptable project situations.
Borrowed ideas: If a student finds project ideas from a written
source, the project is acceptable if 1) the student discloses that
the idea is borrowed from a written source and submits the
written source with the project submission, 2) the student
compiles information requirements using his/her own language
and the resulting document is substantially smaller (at least a
third smaller in number of words), and 3) there is no
corresponding ERD or table design available to the student.
Situations where these conditions are not satisfied are
unacceptable project situations.
Other limitations: Other situations not discussed here may or
may not be acceptable. When attempting a project in non-
standard situations (the standard situation is one where all
elements are original and the student is starting from ground
zero), it is the student’s responsibility to disclose all
information known to the student concerning what’s already
been done or will be done by others by the project due date
about a particular application environment.
5 | Page
Prj3: Project Final Requirements25 Points. Submit all
documents to Canvas.Deliverables
43. 1. An ACCESS database file containing all your tables and the
interface. (Steps 1 & 3)
2. A Word file containing Steps 2 & 4.
3. If relevant, supporting documents for Step 4.Submission of
project
Submit all documents through Canvas in one group member’s
Canvas account. Make sure you have attached all files before
hitting the submit button. Note that multiple files can be
attached, one-by-one, through the submission area.
Step 1 (0 Points). If you didn’t create all tables in ACCESS in
Prj3, implement all tables in ACCESS in this stage. Enter some
data in each table. Define the PKs and the FKs. You may use
fictitious data. For tables like Customer, Emp, and Product,
enter 5 or more rows of data; for tables like Order, Purchase,
Transaction, Class, enter 7 or more rows of data; For tables like
TransactionDetails; OrderDetails (i.e., tables created from m-n
relationships), enter 12 or more rows of data. (If you have
already done this for Prj3 and submitted it for grading, there is
nothing to do for Step 1.)
Step 2: (5 Points): Describe the functionalities that users of this
database would like implemented. This is the basis for your
interface design. This is where you discuss functionalities from
the user's perspective, before the interface is designed. This is
not where you discuss the forms in your database. Note that all
tables in your database must be used in some fashion; otherwise
you’ll lose points in the Interface Design step (Step 3). Submit
this in a Word document with a cover page that lists 1) name of
project, course number and title, semester and year, 2) group
member names.
Step 3: (20 Points) Interface Design
Design the ACCESS interface on top of the tables your created
in Step 1 to allow users to interact with them
44. (retrieve/insert/delete/update). Your interface should provide
functionalities described in Step 2. Since a database allows
users to retrieve, update, delete, and insert data, you may want
to design your interface to provide users with easy or
background retrieval/updating/deleting/inserting. For example,
you may want to design some parameter queries to retrieve
information. You may also allow users to perform searches. For
another example, if you are designing a database for a library,
the switchboard should contain a textbox or a combo box for
entering a PatronId for checking out books. Upon entering the
PatronId, a new row is automatically added to Table
"Transaction." This new row records current date/time and
PatronId. Next, there should be a textbox or combo box to
entering barcode of each book checked out. Upon checking out
each book, a new row is automatically added to Table
"TransactionDetails" for each barcode so entered so which
books the patron is taking out are recorded. Table "Book"
should be updated to record that these books are checked out.
Users should be able to navigate from one form to another in a
logical, easy-to-use fashion. To achieve that, use various
controls discussed in class such as combo boxes and command
buttons. Subforms are also a very good way to allow users
access multiple inter-connected tables in the database. Use
Macros to automate automating routine business operations such
as updating book status upon checking out as discussed above.
Just build a form for each table, which would allow users to
insert, delete, and update rows, would not earn you a good
grade for this step. Your design of the interface should validate
your data requirements stated in Prj1 (if users cannot interact
with certain data, why store them?), and should correspond to
required functionalities addressed in Step 2.
Note: Try to use all principles discussed in the handout: e.g., 1).
user combo boxes for foreign keys and other places, 2) use auto
look up forms, 3) use subforms, 4), use unbound controls to
solicit input for searches, 5) provide ADD, DELETE, SAVE,
45. and CLOSE buttons, 6) Use Update, Insert, and Delete queries
that are called by macros, 7) Use macros for automation.
Step 4: State project source (see Prj0 one-page description
requirements document) and Provide Supporting Documents, if
applicable
If your project is a real-world project, say so and provide
supporting documents. Attach blank paper forms for the
application environment that you are designing the database for.
In your write-up, provide the actual mailing or web address of
the company. You may provide other contact info as well (such
as phone numbers) and any information that may substantiate
your claim that it is a real-world project. If no claim is made or
no supporting documents are provided, your project will be
considered a made-up project. (Note, paper forms are forms
people fill out using a pen, not ACCESS forms.) If you’re
reverse engineering a database, say so and provide web links
and supporting documents if possible.Grading of the project:
The total project score is adjusted up for complex projects and
for real-world projects.
Late Project Policy
Late project carries a penalty of 0.5 point (out of 100) every 2
hours. 2 Points maximum every 24 hours. Late projects start
counting at 8:00 am the next day. (This is to say, even though
the project is due at 11:59 pm the previous day, as long as you
submit it by 8:00 am the next day, there is no penalty.) Late
projects submitted on or after the date that grades are due from
the instructor to the Registrar’s office is considered “Missed
Projects.” This date is usually the Wednesday after the final’s
week. Missed projects will receive 0. Exceptions may be made
concerning missed projects if special situations arise. Consult
the instructor as soon as possible if such situations arise.
Please note that if you wait until the last couple of days to work
46. on your project and something comes up (e.g., you get sick or
you experience a traumatic event) causing you to miss the
deadline, penalty will still be imposed. To give yourself enough
time, you may want to start this stage ASAP.
2 | Page
Project Stage 2: Oracle Implementation25 Points. Submit all
documents to Canvas.Size of Database
The ideal size of the project is about 5-7 tables. This offers
enough complexity and is also manageable. More than seven
tables may be too large. Oracle Account to Use and Clean Up
1. Each student has another account with the userid ORA##PRJ.
The initial password is dbclass. (So you log in using ORA##PRJ
as userid and dbclass as password. ## is the two digits assigned
to you.)
2. You must use ORA##PRJ for this part of the project
(otherwise you’ll lose points).
3. Clean up your ORA##PRJ account first by removing all
tables irrelevant to your project. By the time I grade your
project, your ORA##PRJ must contain only tables relevant to
your project (otherwise you’ll lose points).
Be sure to change your password otherwise someone else may
accidentally log in to your account, remove all your tables, and
put his/her tables in your account. You would lose a lot of
points if that happens to you.
PRJ2 Steps
Step 1) (5 Points). Implement all tables in ACCESS. Enter some
data in each table. Define the PKs and the FKs. You may use
fictitious data. For tables like Customer, Emp, and Product,
enter 5 or more rows of data; for tables like Order, Purchase,
Transaction, Class, enter 7 or more rows of data; For tables like
TransactionDetails, OrderDetails (i.e., tables created from m-n
relationships), enter 12 or more rows of data.
47. Step 2: (20 Points): Oracle SQL
a). Drop all tables in your project account (ORA##PRJ) that are
irrelevant to your project. Each group member must do this and
is evaluated separately for a)..
b). Choose 6 tables connected through PK-FK pairs (no islands)
AND create those tables in each group member’s ORA##PRJ
account. In a script file, create the tables, define all primary
keys and foreign keys, and insert the same data that you entered
in ACCESS. If a table has many rows of data, inserting up to 12
rows of data is sufficient. See cretabs.sql posted in Oracle
module for example. (For example, the tables that we have been
working with: Product—Item—Ord—Customer—Emp—Dept are
6 tables that are connected by PK-FK pairs as indicated by “—“.
If you have 6 or fewer tables, create all your tables in Oracle.)
Note, I ask you to create the tables in ACCESS first so you only
need to type the actual data once. After entering the data in
ACCESS, from ACCESS, you can use the “Export” function to
export the data in each table to a text file. Then you can
combine the text files and modify the combined text file to
create the script file for Oracle.
c). At the beginning of the script, add some comments (use /*
*/ or use --) to provide a “Cover Page.” The comments area
should contain i) name of project, course number and title,
semester and year, ii) all group member names, and iii) Oracle
account Ids for all group members. I need your account user
names but not your passwords to grade your project.
d). Each group member should run the script in his/her own
ORA##PRJ account and generate the same project tables. If
your account does not contain your project tables, you’ll lose 12
points for Step 2. Group members are graded separately for d).
48. You’ll lose points if 1) you did not indicate on your cover page
your oracle account(s) used for your project, or 2) your ora##prj
account has irrelevant tables.
Deliverables
1. An ACCESS file containing all your tables, with the primary
keys and foreign keys defined and data inserted.
2. ONE script file creating 6 of your tables, related keys, and
data, with a comments area at the beginning that serves as a the
“Cover Page.” Do not put the “Cover Page” on a separate file.
3. The 6 Tables with data and related keys created in your
Oracle project accounts (ORA##PRJ). This is the result of Step
2. I'll check them in your Oracle project accounts using my own
script. There is nothing to actually submit for this deliverable
item. Run the script in each group member’ account to create
the tables, define constraints, and insert data.Submission of
project
Submit both documents (ACCESS file and Script file) through
Canvas in one group member’s Canvas account. Make sure you
have attached both files before hitting the submit button. Note
that multiple files can be attached, one-by-one, BEFORE
clicking on the Submit button.
Do not make two submissions each with a different file. When I
download students’ submissions for grading, only files in the
last submission will be downloaded. So if you have to make
another submission before the deadline, attach both files again.
Do not make submissions from two or more group members’
Canvas accounts. Submit both files from one group member’s
Canvas account only.
2 | Page
Project Requirements Stage 2 15 Points
Step 1) (0 Points) Include your ERD with this submission. Stage
2 can’t be graded if your ERD is not included. Modify your
49. ERD according to feedbacks given. If you have modified your
ERD, submit the modified ERD.
Step 2) (15 Points) Transform the E-R model into a relational
data model. Report the following 6 steps. Follow the example
seen here.
a) Convert every entity into a table. Use underline(s) to identify
the primary key of a table. See Example a) on the next page.
b) Convert all 1-n and 1-1 relationships. Clearly indicate
attributes added as a result of converting a 1-1 or a 1-n
relationships. Use italic fonts for this purpose. See Example b)
on the next page.
c) Convert all m-n relationships. See Example b) on the next
Page.
d) List the final conversion result. See Example c) on the next
page. Use underlines to indicate primary keys. Identify foreign
keys in each table.
e) After you have listed the tables based on the ERD, determine
which normal form each table is in. If a table does not satisfy
BCNF, either normalize it or clearly state the reasons why you
choose to keep the table in a lower normal form. See Example
d) on the next page.
f) List the final normalized tables with primary keys and foreign
keys identified. See Example e) on the next page.Example:
Project ERD and the conversion process are shown on the next
pages.
50. a): Convert all entities and get:
Vendor: (vendorId, vname, address, phone)
Order: (order#, Orderdate)
Product: (Stock#, price, Desc)
Payment: (PaymentNo, Pdate, Amount)
b): Convert all relationships
· Vendor-places-Order Relationship: This is a 1-n relationship
with an attribute. Add the primary key of "1" entity (Vendor) to
the many side (Order) as a foreign key. Relationship attribute is
added too. Get:
Order: (order#, Orderdate, VendorId, OrderSource)
Foreign key: VendorId
· Order-Contains-Products Relationship: This is anm-n
relationship with attributes, so make a new table, OrderDetails:
OrderDetails: (Order#, Stock#, Quantity, Price)
Foreign keys: Order#, Stock#
· Payment-pays for-Order: This is a 1-1 relationship. Since each
payment must have a corresponding order but each order may
not have a corresponding payment yet, to advoid null values,
add order# (“1” side) to Payment (pretend “many” side). Get:
Payment: (PaymentNo, PDate, Amount, Order#)
Foreign key: Order#
c): Final Conversion Result:
53. 1
1
n
Desc
Source
Quantity
Price
Amount
Stage 1 Project Requirements –Data Requirements and ERD
35 Total Points. Submit a hard copy before class.
Step 1): (15 Points) Discuss information requirements for the
database application, addressing the following points.
· (0.5 point) Discuss background of the company and the
industry they are in.
· (0.5 point) Discuss problems with the current way of doing
business or with the current system, problems with obtaining
timely and accurate vital information. Your database may not be
able to resolve all problems identified here. Specify the
problems your database is trying to solve (i.e.; scope of your
solution).
· (4 points) Provide detailed descriptions of business operations
that will need or generate data for which you are designing the
database. The write up here serves as the natural language
description of data requirements. This is not the place to
describe your tables or what the attributes are for the tables.
This is where you describe business processes and business
rules.
· (8 Points) Use the four sentence templates discussed in class
to describe detailed data requirements that mostly match the
data requirements descriptions in the last bullet. The sentences
54. should start with “Database needs to store.” For cardinality of
each relationship, start the two sentences with “each.” See the
third sub-bullet below. The descriptions of data requirements
should be such that another person (say, your instructor) can
draw an ERD based on your descriptions. You may want to use
bulleted statements to clearly state data requirements. Provide
an example instance of each entity as well as for attributes of
relationships. Here are some examples:
· (For entities, attributes, and primary keys). Database needs to
store information about each Order. For each order, database
needs to store OrderId, OrderDate, and Total dollar amount.
OrderId is unique to each Order. Order example: Order1234
ordered on 3/1/2015, with a dollar amount of $540.
· (For relationships) Database needs to store information about
what products are being ordered in each order.
· (For relationship cardinalities): Each order can contain
multiple products. Each product can appear in multiple orders.
For example, Order1234 ordered SKU78 and SKU72; Order34
ordered SKU72 and SKU83.
· (For relationship attributes): Database needs to store quantity
and price of each product ordered in each order. (Or, for each
product ordered in each order, database needs to store quantity
and price.) For example, Order 1234 ordered Product SKU78 at
$78/unit for 5 units. Order1234 also ordered SKU72 at $60/unit
for 9 units.
Your write-up may benefit from an iterative process whereby
you compare your ERD with your write-up and revise the write-
up if you find that certain information is not contained in the
write-up to allow another person to derive attributes, primary
keys, or cardinalities, or if you find that your ERD does not
match your write up. Give examples of data elements if those
elements are specific to the application environment, because
55. other people (e.g., your instructor) may not know what they are
(see the next requirement).
· (2 points) Provide sample data for all data requirements as
part of the submission. If the application environment uses any
paper forms to collect data, fill out a set of forms with fictitious
information as sample data and attach those forms as part of the
submission. If the application environment does not use paper
forms, provide screen captures or otherwise provide sample data
(made up data are fine). If your project is made up, provide
made up forms or data.
Step 2): (20 Points) Draw an E-R diagram to document your
application according to your descriptions provided in Step 1),
including the mapping ratios for relationships. The ERD you
draw here should match your descriptions in Step 1, Bullet 4.
Clearly identify attributes of entities and relationships. Each
entity must have a primary key and necessary attributes.
· To save on diagramming effort, you may want to list all
attributes of an entity inside the box for that entity.
· For each entity, underline or otherwise indicate the primary
key.
· If writing out the attributes inside the box crowds the diagram,
list the attributes for each entity separately, beneath the diagram
if there is room, or on a separate page.
· If the meaning of an attribute is not self-explanatory, add
explanations.
You may hand-draw your ERD, or you may use any drawing
tools.
There are many free online drawing tools available, for
example, http://www.draw.io (use a template under Software
Design). ERDplus.com is another good tool. If you’re not using
Visio, Take a screenshot of your ERD and insert the screenshot
as an image in your Word Document. If you’re using Visio,
56. insert the ERD as an editable image. The solution file for ERD
exercises posted in Canvas were drawn with Visio. You can
copy one and modify it for your own ERD. It would save you
some time this way.
Important
Drawing ERD and converting it to a list of tables is an iterative
process. After drawing the ERD, it’s beneficial to convert that
ERD into a list of tables and then investigate whether the final
tables make sense. This often will give you feedback on your
ERD. However, ERD conversion is not required in Prj1. It’ll be
on Prj2 (because your ERD may change).
2