Question: Need help creating constraints for the followuing SQL program SPOOL ddl.out SET ECHO ON /* Homework on SQL/DDL Author: < < >> */ -- --

Need help creating constraints for the followuing SQL program SPOOL ddl.out SET ECHO ON /* Homework on SQL/DDL Author: <<>> */ 

--

  • -- IMPORTANT: use the names IC1, IC2, etc. as given below.

  • -- -------------------------------------------------------------------- /*The following DROP command is inserted for convenience so that if you need to recompile

    your code, it will drop the table (if it already exists). */ DROP TABLE Employee CASCADE CONSTRAINTS; DROP TABLE Dependent CASCADE CONSTRAINTS;

    -- CREATE TABLE Employee ( 

id INTEGER PRIMARY KEY, name CHAR(10) NOT NULL, rank CHAR(10) NOT NULL, salary INTEGER NOT NULL, /* IC1: The rank is one of: 'DB guru', 'DB expert', or 'DB rookie' */ <<>>, /* IC2: The salary of a 'DB guru' is above 200. */ <<>>, /* IC3: The salary of a 'DB expert' is between 80 and 220 (inclusive). */ <<>>, /* IC4: The salary of a 'DB rookie' is less than 100. */ <<>> ); -- -- CREATE TABLE Dependent ( empID dependentName relationship PRIMARY KEY (empID, dependentName), /* IC5: empID must refer to an employee in the company. Also: if an employee is deleted then his/her dependents must be deleted. IMPORTANT: DO NOT declare this IC as DEFERRABLE. */ <<>> ); -- -- ---------------------------------------------------------------- -- TESTING THE SCHEMA -- ---------------------------------------------------------------- INSERT INTO Employee VALUES (10, 'Gray', 'DB guru', 240); INSERT INTO Employee VALUES (20, 'Garland', 'DB guru', 190); INSERT INTO Employee VALUES (30, 'Edison', 'DB expert', 210); INSERT INTO Employee VALUES (40, 'Eckerd', 'DB expert', 70); INSERT INTO Employee VALUES (50, 'Roberts', 'DB rookie', 110); INSERT INTO Employee VALUES (60, 'Rush', 'DB rookie', 90); SELECT * from Employee; -- ---------------------------------------------------------------- INSERT INTO Dependent VALUES (10, 'Grace', 'daughter'); INSERT INTO Dependent VALUES (10, 'George', 'son'); INSERT INTO Dependent VALUES (60, 'Reba', 'daughter'); INSERT INTO Dependent VALUES (15, 'Dustin', 'son'); SELECT * FROM Dependent; -- DELETE FROM Employee WHERE id = 10; SELECT * From Employee; SELECT * FROM Dependent; -- SET ECHO OFF SPOOL OFF

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!