• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

DBMS-GATE | Question 6

Consider the following tables:
Employees:

1. EmployeeID (Primary Key)
2. FirstName
3. LastName
4. DepartmentID (Foreign Key referencing Departments.DepartmentID)
5. Salary

Departments:

1. DepartmentID (Primary Key)
2. DepartmentName
You need to enforce the following integrity constraints:

I. An employee must belong to a valid department.
II. The salary of an employee must be greater than 30000.

(A)

ALTER TABLE Employees
ADD CONSTRAINT FK_Department
FOREIGN KEY (DepartmentID)
REFERENCES Employees(DepartmentID);

ALTER TABLE Employees
ADD CONSTRAINT CHK_Salary
CHECK (Salary > 30000);

(B)

ALTER TABLE Employees
ADD CONSTRAINT CHK_Salary
FOREIGN KEY (EmployeeID)
CHECK salary > 30000;

ALTER TABLE Employees
ADD CONSTRAINT FK_Department
REFERENCES Departments(DepartmentID);
 

(C)

ALTER TABLE Employees
ADD CONSTRAINT fk_department
FOREIGN KEY (DepartmentID)
REFERENCES Departments(DepartmentID);
 

ALTER TABLE Employees
ADD CONSTRAINT chk_salary
CHECK (Salary > 30000);

(D)

ALTER TABLE Employees
ADD CONSTRAINT CHK_Salary
CHECK (Salary > = 30000);

ALTER TABLE Employees
ADD CONSTRAINT FK_Department
FOREIGN KEY (DepartmentID)
REFERENCES Departments(DepartmentID);

Answer

Please comment below if you find anything wrong in the above post
Feeling lost in the world of random DSA topics, wasting time without progress? It's time for a change! Join our DSA course, where we'll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!

Last Updated :
Share your thoughts in the comments