EX_01 (5)

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 4

832224399.

doc 1

Company Database

1. Database Company
832224399.doc 2

Table Structure:
 Employee
Field Name Data Type Null
FName varchar(15) NOT NULL
MInit varchar(1) NULL
LName varchar(15) NOT NULL
SSN char(9) NOT NULL
BDate datetime NULL
Address varchar(30) NULL
Sex char(1) NULL
Salary numeric(10, 2) NULL
SuperSSN char(9) NULL
DNo numeric(4, 0) NULL

 Department
Field Name Data Type Null
DName varchar(15) NOT NULL
DNumber numeric(4, 0) NOT NULL
Mgrssn char(9) NULL
MgrStartdate datetime NULL

 Department Location
Field Name Data Type Null
DNumber numeric(4, 0) NOT NULL
DLocation varchar(15) NOT NULL

 Project
Field Name Data Type Null
PName varchar(15) NOT NULL
PNumber numeric(4, 0) NOT NULL
PLocation varchar(15) NULL
DNum numeric(4, 0) NOT NULL

 Works on
Field Name Data Type Null
ESSN char(9) NOT NULL
PNo numeric(4, 0) NOT NULL
Hours numeric(4, 1) NULL

 Dependent
Field Name Data Type Null
ESSN char(9) NOT NULL
Dependent_Name varchar(15) NOT NULL
Sex char(1) NULL
BDate datetime NULL
Relationship varchar(8) NULL
Note: Save to file Company_Tab.sql
832224399.doc 3

2. Insert Data
In 2 tables Employee and Department: when entering data into table, the data is
entered first and other is enterd next. After they can update.
 Employee
FName Minit LName SSN BDate Address Sex Salary Supper_SSN DNo
John B Smith 123456789 01/09/1955 Houston, M 30000 333445555 5
TX
Franklin T Wong 333445555 12/08/1945 Houston, M 40000 888665555 5
TX
Joyce A English 453453453 07/31/1962 Houston, F 25000 333445555 5
TX
Ramesh K Narayan 666884444 09/15/1952 Humble, M 38000 333445555 5
TX
James E Borg 888665555 11/10/1927 Houston, M 55000 NULL 1
TX
Jennifer S Wallace 987654321 06/20/1931 Bellaire, F 43000 888665555 4
TX
Ahmad V Jabbar 987987987 03/29/1959 Houston, M 25000 987654321 4
TX
Alicia J Zelaya 999887777 07/19/1958 Spring, F 25000 987654321 4
TX

 Department
DName DNumber Mgrssn MgrStartdate
Headquarters 1 888665555 06/19/1971
Administration 4 987654321 01/01/1985
Research 5 333445555 05/22/1978

 Department Location
DNumber DLocation
1 Houston
4 Stafford
5 Bellaire
5 Houston
5 Sugarland

 Project
PName PNumber PLocation DNum
ProductX 1 Bellaire 5
ProductY 2 Sugarland 5
ProductZ 3 Houston 5
Computerization 10 Stafford 4
Reorganization 20 Houston 1
Newbenefits 30 Stafford 4
832224399.doc 4

 Works on
ESSN PNo Hours
123456789 1 32.5
123456789 2 7.5
333445555 2 10.0
333445555 3 10.0
333445555 10 10.0
333445555 20 10.0
453453453 1 20.0
453453453 2 20.0
666884444 3 40.0
888665555 20 NULL
987654321 20 15.0
987654321 30 20.0
987987987 10 35.0
987987987 30 5.0
999887777 10 10.0
999887777 30 30.0

 Dependent
ESSN Dependent_Name Sex BDate Relationship
123456789 Alice F 12/31/1978 Daughter
123456789 Elizabeth F 05/05/1957 Spouse
123456789 Michael M 01/01/1978 Son
333445555 Alice F 04/05/1976 Daughter
333445555 Joy F 05/03/1948 Spouse
333445555 Theodore M 10/25/1973 Son
987654321 Abner M 02/29/1932 Spouse

1. Create tables and interity constraints


2. Create triggers to ensure data rules:

a. An employee cannot participate in more than 5 projects


b. The number of working hours of 1 employee for 1 project must not exceed
40

Note: Save to file StudentID_Fullname_EX1.sql

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy