database management system quiz 1. a company needs to store information about: the employees...

4
Database Management System Quiz 1

Upload: terence-briggs

Post on 04-Jan-2016

216 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Database Management System Quiz 1. A company needs to store information about: the employees identified by EmpNo, Name, Salary and Phone; departments

Database Management System

Quiz 1

Page 2: Database Management System Quiz 1. A company needs to store information about: the employees identified by EmpNo, Name, Salary and Phone; departments

• A company needs to store information about: the employees identified by EmpNo, Name, Salary and Phone; departments identified by DeptNo, Name, and Budget; the children of an employee with name and age.

• Each employee works in only one department; each department is managed by an employee; a child must be identified uniquely by name when the parent (who is an employee; assume that only one parent works for the company and the employee may has more than one child) is known. We are not interested in information about a child once the parent leaves the company.

1. Draw an ER diagram that captures this information2. Translate the ER into relational model.

Page 3: Database Management System Quiz 1. A company needs to store information about: the employees identified by EmpNo, Name, Salary and Phone; departments

Employee

EmpNoName

Salary

Department

DeptNoName

Budegt

Child

Name Age

Works in M 1

has

M

1

1 1Manage

Page 4: Database Management System Quiz 1. A company needs to store information about: the employees identified by EmpNo, Name, Salary and Phone; departments

Create table EMPLOYEES( EMPNO integer, NAME char(20), SALARY float,DeptNo Integer,Primary Key (EMPNO),Foreign key (Deptno) References Departments)

Create table DEPARTMENTS(DEPTNO integer,NAME char(20),BUDGET integer,Primary Key (DEPTNO))

Create table CHILD( EMPNO integer, NAME char(20), Primary Key (EMPNO,NAME),Foreign Key (EMPNO) References EMPLOYEESOn Delete CASCADE)

Create table MANAGE(EMPNO integer,DEPTNO integer,Primary Key (EMPNO, DEPTNO),Foreign Key (EMPNO) References EMPLOYEES,Foreign Key (DEPTNO) References DEPARTMENTs)