You are on page 1of 3

Name: Dixon B.

Delos Santos
Course/Set: BSIT – 2C

Module 03 – Lesson 02 Application

1. Create the following relations under IT223 database. BNO and SNO are primary keys.

Branch Staff

BNO BNAME SNO SNAME BNO!


100 Panabo 1 Peter 100
2 John 200
200 Davao

CREATING BRANCH TABLE:

CREATING STAFF TABLE:

2. Can you insert record (S3,Jean,300) into STAFF relation? If YES, what is the message?

3. Delete staff S3. Is it successful? Yes/No


4. Create a FOREIGN KEY in the branch relation
ALTER TABLE staff ADD CONSTRAINT staff_branch
FOREIGN KEY(bno)
REFERENCES branch(bno)
ON DELETE CASCADE
ON UPDATE NO ACTION;

5. Can you insert record (S3,Jean,300) into STAFF relation? If YES, what is the message?

6. Can you update the Branch # of John to 300. UPDATE staff SET bno = 300 WHERE sno = 2; If YES, what is the
message?

7. Insert record (300,Tagum) into BRANCH relation. Is it successful? Yes/No

8. Can you insert record (S3,Jean,300) into STAFF relation? If YES, what is the message?

9. Delete Branch 100 in the BRANCH relation Is it successful? Yes/No


10. What happen to the records under STAFF relation?

11. Drop the FOREIGN KEY of the STAFF relation ALTER TABLE staff DROP FOREIGN KEY staff_branch

12. Create a new FOREIGN KEY in the STAFF relation


ALTER TABLE staff ADD CONSTRAINT staff_branch
FOREIGN KEY (bno)
REFERENCES branch(bno)
ON DELETE NO ACTION
ON UPDATE CASCADE

13. Can you delete Panabo branch? If YES, what is the message?
-No, as Panabo is Branch 100 and has been for some time.
removed from number 9. No rows were affected.

14. Can you update Panabo branch number from 100 into 500? If YES, what is the message?
-No, because the branch table doesn't list a Panabo branch name.
Rows matched: 0 Changed: 0 Warned: 0 0 row(s) affected

15. Examine the STAFF and BRANCH relations what have you observed?
-The parent table is called BRANCH, while the child table is called STAFF. BRANCH's 'Bno' primary key, which is
connected,
to STAFF's 'Bno' section. For each row of the table, it refers to STAFF who has been given a specific branch name.

16. Create a backup of the database and send it together with your answers to exercise. Name your document as
“FK_urNameAndUrSet”
-

You might also like