SlideShare a Scribd company logo
1 of 3
Prepared by: Dr. Deepani Guruge Moderated By: A/Prof. Savitri Bevinakoppa Nov, 2016
MN405 Data and Information Management
Laboratory 9 : Database Design
Submission Due: End of laboratory class, submit the file on Moodle at least 10 minutes before
the end of laboratory class.
Total Marks = 5 marks for 10 weeks
Marks will be given only to students who attend and participate during 2 hours laboratory class.
Submission on Moodle is mandatory as an evidence of participation.
Description of the laboratory exercise:
The purpose of this assignment is to understand some database functions related to data integrity,
Primary keys, foreign keys, referential integrity, structured query language (SQL) and issues related
to data integrity and security.
This laboratory exercise has 2 parts, Part A and Part B.
Part A
Complete the Practice quiz 5 quiz and paste the result here. Try to obtain 85%+ on the quiz.
Part B
1.
a. What is Referential Integrity?
It the concept related to database in which all foreign keys should check with the
primary key which should be indicated to foreign key.
b. What is Data independence?
Data independence is a term that is related to data transparency that is linked to
centralized DBMS and gives to immunity to the user to make changes in the data.
c. List 3 DBMS’s security features.
1.) Access control
2.) Auditing
3.) Authentication
2. Search on-line and list types of threat that could affect a database system.
Different kind of threats that could affect a database system
1.) Execessive privilege
MN405 Data and Information Management Page 2 of2
Prepared by: Dr. Deepani Guruge Moderated By: A/Prof. Savitri Bevinakoppa Nov, 2016
2.) Legitimate privilege abuse
3.) Database injection attacks
4.) Maleware
5.) Storage media exposure
6.) Exploitation of vulnerable database
7.) Unmanaged sensitive data
8.) The human factor
3. Consider the following relational schema: Questions 3 -11 are based on referential
integrity.
Table Name Attributes
Emp (eid: integer, ename: string, age: integer, salary: real,did: integer)
Works (eid: integer, did: integer, ptime: integer)
Dept (did: integer, dname: string, budget: real, managerid: integer
Example : to CREATE TABLE Command with constraints
CREATE TABLE Emp(
eid int NOT NULL PRIMARY KEY,
age int NOT NULL,
……………………………..
did int FOREIGN KEY REFERENCES Dept(did)
);
4. Write SQL statements to create Dept relation. Note: did is the primary key (not null).
Hint: use CREATE TABLE Command with constraints
CREATE TABLE Dept
did INTEGER,
dhame STRING,
budget REAL,
managerid INTEGER,
PRIMARY KEY (did) ON DELETE SET NULL
5. Define the DeptrelationinSQLsothat everydepartmentisguaranteedtohave amanager.
CREATE TABLE Dept(
didINTEGER,
budgetSTRING,
manageridINTEGER,
PRIMARY KEY (did)
FOREIGN KEY (managerid) REFERENCES(Emp)
MN405 Data and Information Management Page 3 of3
Prepared by: Dr. Deepani Guruge Moderated By: A/Prof. Savitri Bevinakoppa Nov, 2016
6. Enter followinginformationintoDepttable.
did dname budget managerid
3 Finance 2000.50 6
4 Administration 5000.70 7
INSERT
INTODept(did,dname,budget,managerid)
VALUES (3,‘finance’,2000.50, 6)
VALUES (4,‘administration’,5000.70, 7)
7. Write SQL statementstocreate Emp relation.
a. Addthe FOREIGN KEY that will relate the DEPTtable tothe EMP table.
b. Include appropriate versionsof all primaryandforeignkeyintegrityconstraints.
8. Enter followinginformationintoEMP table
Eid Eame Age Salary did
1006 Peter Miller 40 4000.90 3
1007 David John 30 5000.80 3
1008 Kevin Studd 29 6000.70 4
INSERT
INTOEmp (eid,ename,age,salary,did)
VALUES (1006, ‘petermiller’,40,4000.90, 3)
VALUES (1007, ‘davidjohn’,30,5000.80, 3)
VALUES (1008, ‘kevinstudd’,29,6000.70, 4)
9. Can you insert following record into EMP table?
Eid Eame Age Salary did
1008 Cathy Simon 35 5000.80 5
NO, we cannot insert record into EMP table.
10. If you cannot insert, give an explanation why you couldn’t.
We cannot because EID is already taken by other person.
11. Delete department 3 from the DEPT table using the following command
a. DELETE FROMDept WHERE did=3;
DELETE
FROMdept
WHERE did=’3’
b. Explain what happens to EMP table when this statement is executed.
It will not execute.

More Related Content

What's hot

Chapter 7 relation database language
Chapter 7 relation database languageChapter 7 relation database language
Chapter 7 relation database language
Jafar Nesargi
 

What's hot (15)

introduction of database in DBMS
introduction of database in DBMSintroduction of database in DBMS
introduction of database in DBMS
 
Chapter 7 relation database language
Chapter 7 relation database languageChapter 7 relation database language
Chapter 7 relation database language
 
Informatica Data Modelling : Importance of Conceptual Models
Informatica Data Modelling : Importance of  Conceptual ModelsInformatica Data Modelling : Importance of  Conceptual Models
Informatica Data Modelling : Importance of Conceptual Models
 
Chapter 3 Entity Relationship Model
Chapter 3 Entity Relationship ModelChapter 3 Entity Relationship Model
Chapter 3 Entity Relationship Model
 
TWO PARTY HIERARICHAL CLUSTERING OVER HORIZONTALLY PARTITIONED DATA SET
TWO PARTY HIERARICHAL CLUSTERING OVER HORIZONTALLY PARTITIONED DATA SETTWO PARTY HIERARICHAL CLUSTERING OVER HORIZONTALLY PARTITIONED DATA SET
TWO PARTY HIERARICHAL CLUSTERING OVER HORIZONTALLY PARTITIONED DATA SET
 
Ds
DsDs
Ds
 
A Detail Database Architecture
A Detail Database ArchitectureA Detail Database Architecture
A Detail Database Architecture
 
Database aggregation using metadata
Database aggregation using metadataDatabase aggregation using metadata
Database aggregation using metadata
 
Nagaraju
NagarajuNagaraju
Nagaraju
 
Data Models [DATABASE SYSTEMS: Design, Implementation, and Management]
Data Models [DATABASE SYSTEMS: Design, Implementation, and Management]Data Models [DATABASE SYSTEMS: Design, Implementation, and Management]
Data Models [DATABASE SYSTEMS: Design, Implementation, and Management]
 
Improved Slicing Algorithm For Greater Utility In Privacy Preserving Data Pub...
Improved Slicing Algorithm For Greater Utility In Privacy Preserving Data Pub...Improved Slicing Algorithm For Greater Utility In Privacy Preserving Data Pub...
Improved Slicing Algorithm For Greater Utility In Privacy Preserving Data Pub...
 
OODM-object oriented data model
OODM-object oriented data modelOODM-object oriented data model
OODM-object oriented data model
 
Introduction to Data Abstraction
Introduction to Data AbstractionIntroduction to Data Abstraction
Introduction to Data Abstraction
 
Week 4 The Relational Data Model & The Entity Relationship Data Model
Week 4 The Relational Data Model & The Entity Relationship Data ModelWeek 4 The Relational Data Model & The Entity Relationship Data Model
Week 4 The Relational Data Model & The Entity Relationship Data Model
 
Dbms
DbmsDbms
Dbms
 

Similar to Week 9.docx

Discussion 1 The incorrect implementation of databases ou
Discussion 1 The incorrect implementation of databases ouDiscussion 1 The incorrect implementation of databases ou
Discussion 1 The incorrect implementation of databases ou
huttenangela
 
Software Systems Modularization
Software Systems ModularizationSoftware Systems Modularization
Software Systems Modularization
chiao-fan yang
 
Sql interview-question-part-9
Sql interview-question-part-9Sql interview-question-part-9
Sql interview-question-part-9
kaashiv1
 

Similar to Week 9.docx (20)

T6
T6T6
T6
 
Discussion 1 The incorrect implementation of databases ou
Discussion 1 The incorrect implementation of databases ouDiscussion 1 The incorrect implementation of databases ou
Discussion 1 The incorrect implementation of databases ou
 
Software Systems Modularization
Software Systems ModularizationSoftware Systems Modularization
Software Systems Modularization
 
Ebook9
Ebook9Ebook9
Ebook9
 
Sql interview question part 9
Sql interview question part 9Sql interview question part 9
Sql interview question part 9
 
Ebook9
Ebook9Ebook9
Ebook9
 
Sql interview-question-part-9
Sql interview-question-part-9Sql interview-question-part-9
Sql interview-question-part-9
 
S2 DATA PROCESSING FIRST TERM C.A 2
S2 DATA PROCESSING FIRST TERM C.A 2S2 DATA PROCESSING FIRST TERM C.A 2
S2 DATA PROCESSING FIRST TERM C.A 2
 
Employee management system1
Employee management system1Employee management system1
Employee management system1
 
IRJET - Voice based Natural Language Query Processing
IRJET -  	  Voice based Natural Language Query ProcessingIRJET -  	  Voice based Natural Language Query Processing
IRJET - Voice based Natural Language Query Processing
 
Test Strategy Utilising Mc Useful Tools
Test Strategy Utilising Mc Useful ToolsTest Strategy Utilising Mc Useful Tools
Test Strategy Utilising Mc Useful Tools
 
Microsoft azure data fundamentals (dp 900) practice tests 2022
Microsoft azure data fundamentals (dp 900) practice tests 2022Microsoft azure data fundamentals (dp 900) practice tests 2022
Microsoft azure data fundamentals (dp 900) practice tests 2022
 
Cse443 Project Report - LPU (Modern Big Data Analysis with SQL Specialization)
Cse443 Project Report - LPU (Modern Big Data Analysis with SQL Specialization)Cse443 Project Report - LPU (Modern Big Data Analysis with SQL Specialization)
Cse443 Project Report - LPU (Modern Big Data Analysis with SQL Specialization)
 
Mca5033 open source db systems
Mca5033 open source db systemsMca5033 open source db systems
Mca5033 open source db systems
 
Teknik-Tekniknya
Teknik-TekniknyaTeknik-Tekniknya
Teknik-Tekniknya
 
dbms final.pdf
dbms final.pdfdbms final.pdf
dbms final.pdf
 
Job Failure Analysis in Mainframes Production Support
Job Failure Analysis in Mainframes Production SupportJob Failure Analysis in Mainframes Production Support
Job Failure Analysis in Mainframes Production Support
 
Data Base
Data BaseData Base
Data Base
 
D 17
D 17D 17
D 17
 
Corruption detection using machine learning and natural language
Corruption detection using machine learning and natural languageCorruption detection using machine learning and natural language
Corruption detection using machine learning and natural language
 

More from NidhiGupta8431 (9)

T9
T9T9
T9
 
T4
T4T4
T4
 
T7
T7T7
T7
 
T10
T10T10
T10
 
T3
T3T3
T3
 
T2
T2T2
T2
 
T1
T1T1
T1
 
Ict713 t320-t10-dl-08 dec2020
Ict713 t320-t10-dl-08 dec2020Ict713 t320-t10-dl-08 dec2020
Ict713 t320-t10-dl-08 dec2020
 
Ict713 t320-t7-dl-20 oct2020
Ict713 t320-t7-dl-20 oct2020Ict713 t320-t7-dl-20 oct2020
Ict713 t320-t7-dl-20 oct2020
 

Recently uploaded

Bur Dubai Call Girl Service #$# O56521286O Call Girls In Bur Dubai
Bur Dubai Call Girl Service #$# O56521286O Call Girls In Bur DubaiBur Dubai Call Girl Service #$# O56521286O Call Girls In Bur Dubai
Bur Dubai Call Girl Service #$# O56521286O Call Girls In Bur Dubai
parisharma5056
 
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
amitlee9823
 
Presentation on Workplace Politics.ppt..
Presentation on Workplace Politics.ppt..Presentation on Workplace Politics.ppt..
Presentation on Workplace Politics.ppt..
Masuk Ahmed
 
Escorts Service Cambridge Layout ☎ 7737669865☎ Book Your One night Stand (Ba...
Escorts Service Cambridge Layout  ☎ 7737669865☎ Book Your One night Stand (Ba...Escorts Service Cambridge Layout  ☎ 7737669865☎ Book Your One night Stand (Ba...
Escorts Service Cambridge Layout ☎ 7737669865☎ Book Your One night Stand (Ba...
amitlee9823
 
Delhi Call Girls South Delhi 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls South Delhi 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls South Delhi 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls South Delhi 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
shivangimorya083
 
Zeeman Effect normal and Anomalous zeeman effect
Zeeman Effect normal and Anomalous zeeman effectZeeman Effect normal and Anomalous zeeman effect
Zeeman Effect normal and Anomalous zeeman effect
PriyanshuRawat56
 
Internship Report].pdf iiwmoosmsosmshkssmk
Internship Report].pdf iiwmoosmsosmshkssmkInternship Report].pdf iiwmoosmsosmshkssmk
Internship Report].pdf iiwmoosmsosmshkssmk
SujalTamhane
 
Dombivli Call Girls, 9892124323, Kharghar Call Girls, chembur Call Girls, Vas...
Dombivli Call Girls, 9892124323, Kharghar Call Girls, chembur Call Girls, Vas...Dombivli Call Girls, 9892124323, Kharghar Call Girls, chembur Call Girls, Vas...
Dombivli Call Girls, 9892124323, Kharghar Call Girls, chembur Call Girls, Vas...
Pooja Nehwal
 
Vip Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...
Vip  Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...Vip  Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...
Vip Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...
shivangimorya083
 
CALL ON ➥8923113531 🔝Call Girls Husainganj Lucknow best Female service 🧳
CALL ON ➥8923113531 🔝Call Girls Husainganj Lucknow best Female service  🧳CALL ON ➥8923113531 🔝Call Girls Husainganj Lucknow best Female service  🧳
CALL ON ➥8923113531 🔝Call Girls Husainganj Lucknow best Female service 🧳
anilsa9823
 

Recently uploaded (20)

Bur Dubai Call Girl Service #$# O56521286O Call Girls In Bur Dubai
Bur Dubai Call Girl Service #$# O56521286O Call Girls In Bur DubaiBur Dubai Call Girl Service #$# O56521286O Call Girls In Bur Dubai
Bur Dubai Call Girl Service #$# O56521286O Call Girls In Bur Dubai
 
VVVIP Call Girls In East Of Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In East Of Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...VVVIP Call Girls In East Of Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In East Of Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
 
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 
Toxicokinetics studies.. (toxicokinetics evaluation in preclinical studies)
Toxicokinetics studies.. (toxicokinetics evaluation in preclinical studies)Toxicokinetics studies.. (toxicokinetics evaluation in preclinical studies)
Toxicokinetics studies.. (toxicokinetics evaluation in preclinical studies)
 
Presentation on Workplace Politics.ppt..
Presentation on Workplace Politics.ppt..Presentation on Workplace Politics.ppt..
Presentation on Workplace Politics.ppt..
 
Escorts Service Cambridge Layout ☎ 7737669865☎ Book Your One night Stand (Ba...
Escorts Service Cambridge Layout  ☎ 7737669865☎ Book Your One night Stand (Ba...Escorts Service Cambridge Layout  ☎ 7737669865☎ Book Your One night Stand (Ba...
Escorts Service Cambridge Layout ☎ 7737669865☎ Book Your One night Stand (Ba...
 
Delhi Call Girls South Delhi 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls South Delhi 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls South Delhi 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls South Delhi 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Zeeman Effect normal and Anomalous zeeman effect
Zeeman Effect normal and Anomalous zeeman effectZeeman Effect normal and Anomalous zeeman effect
Zeeman Effect normal and Anomalous zeeman effect
 
Hyderabad 💫✅💃 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATIS...
Hyderabad 💫✅💃 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATIS...Hyderabad 💫✅💃 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATIS...
Hyderabad 💫✅💃 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATIS...
 
Internship Report].pdf iiwmoosmsosmshkssmk
Internship Report].pdf iiwmoosmsosmshkssmkInternship Report].pdf iiwmoosmsosmshkssmk
Internship Report].pdf iiwmoosmsosmshkssmk
 
Joshua Minker Brand Exploration Sports Broadcaster .pptx
Joshua Minker Brand Exploration Sports Broadcaster .pptxJoshua Minker Brand Exploration Sports Broadcaster .pptx
Joshua Minker Brand Exploration Sports Broadcaster .pptx
 
TEST BANK For An Introduction to Brain and Behavior, 7th Edition by Bryan Kol...
TEST BANK For An Introduction to Brain and Behavior, 7th Edition by Bryan Kol...TEST BANK For An Introduction to Brain and Behavior, 7th Edition by Bryan Kol...
TEST BANK For An Introduction to Brain and Behavior, 7th Edition by Bryan Kol...
 
Dombivli Call Girls, 9892124323, Kharghar Call Girls, chembur Call Girls, Vas...
Dombivli Call Girls, 9892124323, Kharghar Call Girls, chembur Call Girls, Vas...Dombivli Call Girls, 9892124323, Kharghar Call Girls, chembur Call Girls, Vas...
Dombivli Call Girls, 9892124323, Kharghar Call Girls, chembur Call Girls, Vas...
 
Motilal Oswal Gift City Fund PPT - Apr 2024.pptx
Motilal Oswal Gift City Fund PPT - Apr 2024.pptxMotilal Oswal Gift City Fund PPT - Apr 2024.pptx
Motilal Oswal Gift City Fund PPT - Apr 2024.pptx
 
Vip Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...
Vip  Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...Vip  Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...
Vip Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...
 
WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Salarpur Sector 81 ( Noida)
 
CALL ON ➥8923113531 🔝Call Girls Husainganj Lucknow best Female service 🧳
CALL ON ➥8923113531 🔝Call Girls Husainganj Lucknow best Female service  🧳CALL ON ➥8923113531 🔝Call Girls Husainganj Lucknow best Female service  🧳
CALL ON ➥8923113531 🔝Call Girls Husainganj Lucknow best Female service 🧳
 
Call Girls Alandi Road Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Alandi Road Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Alandi Road Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Alandi Road Call Me 7737669865 Budget Friendly No Advance Booking
 
Top Rated Pune Call Girls Warje ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Warje ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Warje ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Warje ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
 
Dubai Call Girls Demons O525547819 Call Girls IN DUbai Natural Big Boody
Dubai Call Girls Demons O525547819 Call Girls IN DUbai Natural Big BoodyDubai Call Girls Demons O525547819 Call Girls IN DUbai Natural Big Boody
Dubai Call Girls Demons O525547819 Call Girls IN DUbai Natural Big Boody
 

Week 9.docx

  • 1. Prepared by: Dr. Deepani Guruge Moderated By: A/Prof. Savitri Bevinakoppa Nov, 2016 MN405 Data and Information Management Laboratory 9 : Database Design Submission Due: End of laboratory class, submit the file on Moodle at least 10 minutes before the end of laboratory class. Total Marks = 5 marks for 10 weeks Marks will be given only to students who attend and participate during 2 hours laboratory class. Submission on Moodle is mandatory as an evidence of participation. Description of the laboratory exercise: The purpose of this assignment is to understand some database functions related to data integrity, Primary keys, foreign keys, referential integrity, structured query language (SQL) and issues related to data integrity and security. This laboratory exercise has 2 parts, Part A and Part B. Part A Complete the Practice quiz 5 quiz and paste the result here. Try to obtain 85%+ on the quiz. Part B 1. a. What is Referential Integrity? It the concept related to database in which all foreign keys should check with the primary key which should be indicated to foreign key. b. What is Data independence? Data independence is a term that is related to data transparency that is linked to centralized DBMS and gives to immunity to the user to make changes in the data. c. List 3 DBMS’s security features. 1.) Access control 2.) Auditing 3.) Authentication 2. Search on-line and list types of threat that could affect a database system. Different kind of threats that could affect a database system 1.) Execessive privilege
  • 2. MN405 Data and Information Management Page 2 of2 Prepared by: Dr. Deepani Guruge Moderated By: A/Prof. Savitri Bevinakoppa Nov, 2016 2.) Legitimate privilege abuse 3.) Database injection attacks 4.) Maleware 5.) Storage media exposure 6.) Exploitation of vulnerable database 7.) Unmanaged sensitive data 8.) The human factor 3. Consider the following relational schema: Questions 3 -11 are based on referential integrity. Table Name Attributes Emp (eid: integer, ename: string, age: integer, salary: real,did: integer) Works (eid: integer, did: integer, ptime: integer) Dept (did: integer, dname: string, budget: real, managerid: integer Example : to CREATE TABLE Command with constraints CREATE TABLE Emp( eid int NOT NULL PRIMARY KEY, age int NOT NULL, …………………………….. did int FOREIGN KEY REFERENCES Dept(did) ); 4. Write SQL statements to create Dept relation. Note: did is the primary key (not null). Hint: use CREATE TABLE Command with constraints CREATE TABLE Dept did INTEGER, dhame STRING, budget REAL, managerid INTEGER, PRIMARY KEY (did) ON DELETE SET NULL 5. Define the DeptrelationinSQLsothat everydepartmentisguaranteedtohave amanager. CREATE TABLE Dept( didINTEGER, budgetSTRING, manageridINTEGER, PRIMARY KEY (did) FOREIGN KEY (managerid) REFERENCES(Emp)
  • 3. MN405 Data and Information Management Page 3 of3 Prepared by: Dr. Deepani Guruge Moderated By: A/Prof. Savitri Bevinakoppa Nov, 2016 6. Enter followinginformationintoDepttable. did dname budget managerid 3 Finance 2000.50 6 4 Administration 5000.70 7 INSERT INTODept(did,dname,budget,managerid) VALUES (3,‘finance’,2000.50, 6) VALUES (4,‘administration’,5000.70, 7) 7. Write SQL statementstocreate Emp relation. a. Addthe FOREIGN KEY that will relate the DEPTtable tothe EMP table. b. Include appropriate versionsof all primaryandforeignkeyintegrityconstraints. 8. Enter followinginformationintoEMP table Eid Eame Age Salary did 1006 Peter Miller 40 4000.90 3 1007 David John 30 5000.80 3 1008 Kevin Studd 29 6000.70 4 INSERT INTOEmp (eid,ename,age,salary,did) VALUES (1006, ‘petermiller’,40,4000.90, 3) VALUES (1007, ‘davidjohn’,30,5000.80, 3) VALUES (1008, ‘kevinstudd’,29,6000.70, 4) 9. Can you insert following record into EMP table? Eid Eame Age Salary did 1008 Cathy Simon 35 5000.80 5 NO, we cannot insert record into EMP table. 10. If you cannot insert, give an explanation why you couldn’t. We cannot because EID is already taken by other person. 11. Delete department 3 from the DEPT table using the following command a. DELETE FROMDept WHERE did=3; DELETE FROMdept WHERE did=’3’ b. Explain what happens to EMP table when this statement is executed. It will not execute.