Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analysis In Microsoft Excel

Authors: Alex Holloway

1st Edition

B0CCCPKTTX, 979-8852388452

More Books

Students also viewed these Databases questions

Question

The amount of work I am asked to do is reasonable.

Answered: 1 week ago

Question

The company encourages a balance between work and personal life.

Answered: 1 week ago