Question: Given two relation schema with referential integrity constraints as follows, Schema: EMPLOYEE (SSN, NAME, AGE, SALARY, SUPERSSN, DNO) DEPARTMENT (DNUMBER, DNAME, MGRSSN, MGRSTARTDATE) Referential Integrity

Given two relation schema with referential integrity constraints as follows,

Schema:

EMPLOYEE(SSN, NAME, AGE, SALARY, SUPERSSN, DNO)

DEPARTMENT(DNUMBER, DNAME, MGRSSN, MGRSTARTDATE)

Referential Integrity Constraints:

EMPLOYEE.SUPERSSN references to EMPLOYEE.SSN

EMPLOYEE.DNUMBER references to DEPARTMENT.DNUMBER

DEPARTMENT.MGRSSN references to EMPLOYEE.SSN

Please select the correct set of SQL statements to create these two database tables and enforce these referential integrity constraints correctly.

A) 1. Create table EMPLOYEE:

create table EMPLOYEE

(name varchar2(19) not null,

ssn char (9),

bdate date,

sex char(3),

salary number(8,2),

superssn char(9),

dno varchar(8),

constraint empPK primary key (ssn),

constraint empsuperFRK foreign key (superssn)

references employee (ssn) disable)

2. Create table DEPARTMENT:

create table DEPARTMENT

(dname varchar2(15) not null,

dnumber varchar(8),

mgrssn char(9),

mgrstartdate date,

constraint departPK primary key (dnumber),

constraint departUK unique (dname),

constraint departFRK foreign key (mgrssn)

references employee (ssn) disable)

3. Add constraint to EMPLOYEE table

alter table employee

add (constraint empdnoFRK foreign key (dno)

references department(dnumber))

4. Enable the constraints:

alter table EMPLOYEE enable constraint empsuperFRK;

alter table DEPARTMENT enable constraint departFRK;

B) 1. Create table DEPARTMENT:

create table DEPARTMENT

(dname varchar2(15) not null,

dnumber varchar(8),

mgrssn char(9),

mgrstartdate date,

constraint departPK primary key (dnumber),

constraint departUK unique (dname))

2. Create table EMPLOYEE:

create table EMPLOYEE

(name varchar2(19) not null,

ssn char (9),

bdate date,

sex char(3),

salary number(8,2),

superssn char(9),

dno varchar(8),

constraint empPK primary key (ssn),

constraint empsuperFRK foreign key (superssn)

references employee (ssn),

constraint empdnoFRK foreign key (dno)

references department(dnumber) disable)

3. Add constraint to DEPARTMENT table

alter table DEPARTMENT

add (constraint departFRK foreign key (mgrssn)

references employee(ssn))

4. Enable the constraints:

alter table EMPLOYEE enable constraint empsuperFRK;

alter table EMPLOYEE enable constraint empdnoFRK;

C) 1. Create table DEPARTMENT:

create table DEPARTMENT

(dname varchar2(15) not null,

dnumber varchar(8),

mgrssn char(9),

mgrstartdate date,

constraint departPK primary key (dnumber),

constraint departUK unique (dname) disable)

2. Create table EMPLOYEE:

create table EMPLOYEE

(name varchar2(19) not null,

ssn char (9),

bdate date,

sex char(3),

salary number(8,2),

superssn char(9),

dno varchar(8),

constraint empPK primary key (ssn),

constraint empsuperFRK foreign key (superssn)

references employee (ssn));

3. Add constraint to DEPARTMENT table

alter table DEPARTMENT

add (constraint departFRK foreign key (mgrssn)

references employee(ssn))

4. Add constraint to EMPLOYEE table

alter table EMPLOYEE

add (constraint empdnoFRK foreign key (dno)

references department(dnumber))

.

D) 1. Create table DEPARTMENT:

create table DEPARTMENT

(dname varchar2(15) not null,

dnumber varchar(8),

mgrssn char(9),

mgrstartdate date,

constraint departPK primary key (dnumber),

constraint departUK unique (dname),

constraint departFRK foreign key (mgrssn)

references employee (ssn) disable)

2. Create table EMPLOYEE:

create table EMPLOYEE

(name varchar2(19) not null,

ssn char (9),

bdate date,

sex char(3),

salary number(8,2),

superssn char(9),

dno varchar(8),

constraint empPK primary key (ssn),

constraint empsuperFRK foreign key (superssn)

references employee (ssn),

constraint empdnoFRK foreign key (dnodisable)

3. Add constraint to EMPLOYEE table

alter table employee

add (constraint empdnoFRK foreign key (dno)

references department(dnumber))

4. Enable the constraints:

alter table EMPLOYEE enable constraint empsuperFRK;

alter table DEPARTMENT enable constraint departFRK;

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!