Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Department(department_id,name) Q1:write an sql to create a staff table having(st

ID: 3589206 • Letter: D

Question

Department(department_id,name)

Q1:write an sql to create a staff table having(staff_id,department_id,first_name,last_name,salary)using the integrity enhancement features of SQL with the following constraints:

salary must be between$1000 and $5000

staff must work in an existing department

no two employees wit the same last name may work for the company

Q2 If a department is removed from the department table, what type of integrity constraint could be violated

Q3 what if we delete a department from department table, how would the staff table contents be affected. What is the side effect as a whole database?

Explanation / Answer

Q1) Create table staff(staff_id into, department_id int, first_name varchar2(10),last_name varchar2 (10) unique, salary int check(salary between 1000 and 5000),foreign key(department_id) references department (department_id));

Q2) Delete violation will occur because there is a dependent column is there in staff table which is referencing this department of column. So it raises an error.

Q3) The department could not be deleted because it will raise an integrated constraint violation error will raise because of the staff table reference. This causes inconsistency in the database.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote