Document on Database SQL

   

Added on  2020-04-13

6 Pages571 Words62 Views
Running head: DATABASE SQLDatabase SQLName of the Student:Name of the University:Author note:
Document on Database SQL_1
1DATABASE SQLQuestion 1a) Develop an SQL query to answer the following question: What are the names of theadmin people?Answer:SELECT name FROM StaffWHERE role = ‘admin’;b) Develop an SQL query that will produce a table such as TimeRecords, but which willprint the title of the project instead of the pid and the name of the staff instead of thesid.Answer:SELECT ResearchProject.pid, Staff.name, TimeRecords.workDate, TimeRecords.workHoursFROM ((TimeRecords INNER JOIN ResearchProject ON TimeRecords.pid = Staff.pid)INNER JOIN Staff ON TimeRecords.sid = Staff.sid);c) Develop an SQL query to answer the following question: What is the title of theproject with the highest pid number?Answer:SELECT title AS Max pid Title
Document on Database SQL_2
2DATABASE SQLFROM ResearchProject WHERE pid = (SELECT MAX(pid) FROM ResearchProject);d) Develop an SQL query to answer the following question: Which projects had morethan one person working on it?Answer:SELECT title FROM ResearchProject WHERE pid = (SELECT pid FROM TimeRecords GROUP BY pid, sidHAVING COUNT(*) > 1);e) What would happen if you tried to execute the following SQL statement? DELETEfrom Staff where sid = 12Answer:This command will not only delete the entire row with ‘sid’=12 from Staff, but willalso bring changes to the ResearchProject table. The ‘pi’ field with rows having 12 as theirvalues, will be set to NULL. This is because ‘pi’ is a foreign key that references the ‘sid’ fieldfrom the Staff table.
Document on Database SQL_3

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Assignment On Functional Dependencies In ER Diagram
|7
|813
|260

Student Database Management System Project Specification
|4
|693
|420

Database Design and Management - PDF
|5
|568
|318

Ethical Approval Application Form
|7
|2156
|84

Case Study of Sunny Hostel Project
|8
|2002
|130

Recruit, Select and Induct Staff for Imagine Hotel - SITXHRM004
|44
|8561
|273