0% found this document useful (0 votes)
3 views1 page

Database

The document outlines the SQL commands to create a database named 'company_9011123' and its associated tables, including 'employee', 'department', 'dept_locations', 'project', 'works_on', and 'dependents'. Each table is defined with specific fields, data types, and primary/foreign key constraints to establish relationships between them. Additionally, an alteration is made to the 'employee' table to include a foreign key reference to the 'department' table.

Uploaded by

ekpehope19
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Database

The document outlines the SQL commands to create a database named 'company_9011123' and its associated tables, including 'employee', 'department', 'dept_locations', 'project', 'works_on', and 'dependents'. Each table is defined with specific fields, data types, and primary/foreign key constraints to establish relationships between them. Additionally, an alteration is made to the 'employee' table to include a foreign key reference to the 'department' table.

Uploaded by

ekpehope19
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

create database company_9011123;

use company_9011123;
create table employee(
Fname varchar(20) not null,
Minit varchar(1),
Lname varchar(20) not null,
ssn varchar(9),
Bdate date,
address varchar(50),
sex char,
salary decimal(10,2),
superssn varchar(9),
dno int,
primary key(ssn),
foreign key (superssn) references employee(ssn)
--foreign key (dno) references department(dno)
)
create table department(
Dname varchar(20) unique not null,
dnumber int primary key,
mgrssn varchar(9),
mgrstartdate date,
foreign key (mgrssn) references employee(ssn)
)
create table dept_locations(
dnumber int,
dlocations varchar(30),
primary key (dnumber, dlocations),
foreign key (dnumber) references department(dnumber)
)
create table project(
pname varchar(30) unique not null,
pnumber int primary key,
plocation varchar(30),
dnum int,
foreign key (dnum) references department(dnumber)
)
create table works_on(
essn varchar(9),
pno int,
hours decimal(4,2),
primary key (essn, pno),
foreign key (pno) references project(pnumber)
)
create table dependents(
essn varchar(9),
dependent_name varchar(30) not null,
sex char,
bdate date,
relationship varchar(20)
primary key (essn, dependent_name),
foreign key (essn) references employee(ssn)
)

alter table employee


add foreign key (dno) references department(dnumber)

You might also like