Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions