DOC PREVIEW
UT Dallas CS 6385 - activity_sep11_solution

This preview shows page 1 out of 4 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CSE 5330/7330Activity – Sept 11, 2014 - Solution3.11 Suppose that each of the following Update operations is applied directly to the database state shown in Figure 3.6. Discuss all integrity constraints violated by each operation, if any, and the different ways of enforcing these constraints.a. Insert <Robert, 'F', 'Scott', '943775543', '1972-06-21', '2365 Newcastle Rd, Bellaire, TX', M, 58000, '888665555',1> into EMPLOYEE. Okayb. Insert <'ProductA', 4, 'Bellaire', 2> into PROJECT. Dnum 2 does not exist in DEPENDENT as required by the foreign key constraint.c. Insert <'Production', 4, '943775543', '2007-10-01'> into DEPARTMENT. Dnumber 4 already exists in table, this would cause a duplicate, so the row not addedd. Insert <'677678989', NULL, '40.0'> into WORKS_ON. The primary key is a composite of Essn and Pno, null values are not allowed in keyse. Insert <'453453453', 'John', 'M', '1990-12-12', 'spouse'> into DEPENDENT. Okayf. Delete the WORKS_ON tuples with Essn = '333445555'. Okay, deletes 4 rowsg. Delete the EMPLOYEE tuple with Ssn = '987654321'. This starts a cascading action, also need to delete rows in DEPENDENT, delete the row in DEPARTMENT, which would really cause other problems with deletes in all tables since this person is a department manager! Delete option could be: cascade, do nothing, or set null. h. Delete the PROJECT tuple with Pname = 'ProductX'. Deleting a project, should cascade to the WORKS_ON table to enforce the foreign key reference.i. Modify the Mgr_ssn and Mgr_start_date of the DEPARTMENT tuple with Dnumber = 5 to '123456789' and '2007-10-01', respectively. Okayj. Modify the Super_ssn attribute of the EMPLOYEE tuple with Ssn ='999887777' to '943775543'.Okay, this is using the data that was inserted in the first insert above. k. Modify the Hours attribute of the WORKS_ON tuple with Essn = '999887777' and Pno = 10 to '5.0'.Okay, example of using a composite key.create table EMPLOYEE ( Fname char (20), Minit char (1), Lname char (20), SSN char (9) primary key, Bdate char(10), Address Char (40), Sex Char (1), Salary integer, Super_ssn char(9), Dno integer, foreign key (dno) references Department (Dnumber ) deferrable initially deferred, foreign key (super_ssn) references Employee (ssn) deferrable initiallydeferred );create table Department ( Dname char (20), Dnumber integer primary key, Mgr_ssn char(9), mgr_start_date char(10), foreign key (mgr_ssn) references employee (SSN) );Create table Dept_Locations ( Dnumber integer, Dlocation char (20), primary key (dnumber, dlocation), foreign key (dnumber) references Department (dnumber) );Create table Project ( Pname char (20), Pnumber integer primary key, Plocation char(20), Dnum integer, foreign key (dnum) references Department(Dnumber) );Create table works_on ( Essn char (9), Pno integer, hours float, primary key (Essn, Pno), foreign key (essn) references Employee (ssn), foreign key (pno) references Project (pnumber) );Create table Dependent ( Essn char (9), Dependent_Name char(20), Sex Char(1), Bdate char(10), Relationship char(10), check (relationship="Son" or relationship="Daughter" or relationship="Spouse"), primary key (essn, dependent_name ), foreign key (Essn) references Employee(ssn) );insert into EMPLOYEE values ("John","B","Smith","123456789","1965-01-09","731 Fondren, Houston, TX","M",30000,"333445555",5);insert into EMPLOYEE values ("Franklin","T","Wong","333445555","1955-12-08","638 Voss, Houston, TX","M",40000,"888665555",5);insert into EMPLOYEE values ("Alicia","J","Zelaya","999887777","1968-01-19","3321 Castle, Spring, TX","F",25000,"987654321",4);insert into EMPLOYEE values ("Jennifer","S","Wallace","987654321","1941-06-20","291 Berry, Bellaire, TX","F",43000,"888665555",4);insert into EMPLOYEE values ("Ramesh","K","Narayan","666884444","1962-09-15","975 Fire Oak, Humble, TX","M",38000,"333445555",5);insert into EMPLOYEE values ("Joyce","A","English","453453453","1972-07-31","5631 Rice, Houston, TX","F",25000,"333445555",5);insert into EMPLOYEE values ("Ahmad","V","Jabbar","987987987","1969-03-29","980 Dallas, Houston, TX","M",25000,"987654321",4);insert into EMPLOYEE values ("James","E","Borg","888665555","1937-11-10","450 Stone, Houston, TX","M",55000,null,1);insert into DEPARTMENT values ("Research",5,"333445555","1988-05-22");insert into DEPARTMENT values ("Administration",4,"987654321","1995-01-01");insert into DEPARTMENT values ("Headquarters",1,"888665555","1981-06-19");insert into DEPT_LOCATIONS values (1,"Houston");insert into DEPT_LOCATIONS values (4,"Stafford");insert into DEPT_LOCATIONS values (5,"Bellaire");insert into DEPT_LOCATIONS values (5,"Sugarland");insert into DEPT_LOCATIONS values (5,"Houston");insert into PROJECT values ("ProductX",1,"Bellaire",5);insert into PROJECT values ("ProductY",2,"Sugarland",5);insert into PROJECT values ("ProductZ",3,"Houston",5);insert into PROJECT values ("Computerization",10,"Stafford",4);insert into PROJECT values ("Reorganization",20,"Houston",1);insert into PROJECT values ("Newbenefits",30,"Stafford",4);insert into DEPENDENT values ("333445555","Alice","F","1986-04-05","Daughter");insert into DEPENDENT values ("333445555","Theodore","M","1983-10-25","Son");insert into DEPENDENT values ("333445555","Joy","F","1958-05-03","Spouse");insert into DEPENDENT values ("987654321","Abner","M","1941-02-28","Spouse");insert into DEPENDENT values ("123456789","Michael","M","1988-01-04","Son");insert into DEPENDENT values ("123456789","Alice","F","1988-12-30","Daughter");insert into DEPENDENT values ("123456789","Elizabeth","F","1967-05-05","Spouse");insert into WORKS_ON values ("123456789",1,32.5);insert into WORKS_ON values ("123456789",2,7.5);insert into WORKS_ON values ("666884444",3,40);insert into WORKS_ON values ("453453453",1,20);insert into WORKS_ON values ("453453453",2,20);insert into WORKS_ON values ("333445555",2,10);insert into WORKS_ON values ("333445555",3,10);insert into WORKS_ON values ("333445555",10,10);insert into WORKS_ON values ("333445555",20,10);insert into WORKS_ON values ("999887777",30,30);insert into WORKS_ON values ("999887777",10,10);insert into WORKS_ON values ("987987987",10,35);insert into WORKS_ON values ("987987987",30,5);insert into WORKS_ON values ("987654321",30,20);insert into WORKS_ON values ("987654321",20,15);insert into WORKS_ON values


View Full Document

UT Dallas CS 6385 - activity_sep11_solution

Documents in this Course
assn1

assn1

2 pages

38rel2

38rel2

5 pages

Report

Report

3 pages

networks

networks

18 pages

lp2

lp2

44 pages

lp2 (2)

lp2 (2)

27 pages

lp1(1)

lp1(1)

21 pages

integer1

integer1

50 pages

FrankR2

FrankR2

3 pages

duality

duality

28 pages

CMST

CMST

44 pages

hw4

hw4

3 pages

for 1

for 1

11 pages

ENCh02

ENCh02

33 pages

pree

pree

2 pages

new  3

new 3

2 pages

new  2

new 2

2 pages

hw4a

hw4a

2 pages

T2_Sol

T2_Sol

4 pages

ISM3

ISM3

8 pages

hw4_sol

hw4_sol

6 pages

Elm04_06

Elm04_06

11 pages

atn proj2

atn proj2

20 pages

12CUT1

12CUT1

8 pages

09Ford

09Ford

23 pages

08FLOW

08FLOW

6 pages

03LP_su

03LP_su

6 pages

40REL40

40REL40

5 pages

39rel3

39rel3

5 pages

38arel2

38arel2

5 pages

37REL1

37REL1

3 pages

24TABU

24TABU

3 pages

22DYNPR

22DYNPR

3 pages

21B&C

21B&C

2 pages

20BBEX0

20BBEX0

3 pages

19BB

19BB

5 pages

14CAPBUD0

14CAPBUD0

11 pages

35BRXCH

35BRXCH

2 pages

34COMB

34COMB

4 pages

32CAPAS

32CAPAS

4 pages

31QUEUE

31QUEUE

3 pages

Load more
Download activity_sep11_solution
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view activity_sep11_solution and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view activity_sep11_solution 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?