company.sql - CREATE DATABASE COMPANY; USE COMPANY; CREATE...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 CREATE DATABASE COMPANY USE COMPANY CREATE TABLE EMPLOYEE ( FNAMEVARCHAR(15)NOT NULL, MINITCHAR, LNAMEVARCHAR(15)NOT NULL, SSNCHAR(9)NOT NULL, BDATEDATE, ADDRESSVARCHAR(30), SEXCHAR, SALARYDECIMAL(10,2), SUPERSSNCHAR(9), DNOINTNOT NULL, PRIMARY KEY (SSN), FOREIGN KEY (SUPERSSN) REFERENCES EMPLOYEE(SSN), FOREIGN KEY (DNO) REFERENCES DEPARTMENT(DNUMBER) ) CREATE TABLE DEPARTMENT ( DNAMEVARCHAR(15)NOT NULL, DNUMBERINTNOT NULL, MGRSSNCHAR(9)NOT NULL, MGRSTARTDATEDATE, PRIMARYKEY (DNUMBER), UNIQUE(DNAME), FOREIGN KEY (MGRSSN) REFERENCES EMPLOYEE(SSN) ) CREATE TABLE DEPT_LOCATIONS ( DNUMBERINTNOT NULL, DLOCATIONVARCHAR(15)NOT NULL, PRIMARY KEY (DNUMBER, DLOCATION), FOREIGN KEY (DNUMBER) REFERENCES DEPARTMENT(DNUMBER) ) CREATE TABLE PROJECT ( PNAMEVARCHAR(15)NOT NULL, PNUMBERINTNOT NULL, PLOCATIONVARCHAR(15), DNUMINTNOT NULL, PRIMARY KEY (PNUMBER), UNIQUE(PNAME), FOREIGN KEY (DNUM) REFERENCES DEPARTMENT(DNUMBER) ) CREATE TABLE WORKS_ON ( ESSNCHAR(9)NOT NULL, PNOINTNOT NULL, HOURSDECIMAL(3,1)NOT NULL, PRIMARY KEY(ESSN, PNO), FOREIGN KEY(ESSN) REFERENCES EMPLOYEE(SSN),
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Sheet1 Page 2 FOREIGN KEY(PNO) REFERENCES PROJECT(PNUMBER) ) CREATE TABLE DEPENDENT (
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/07/2011 for the course MIS unknown taught by Professor Unknown during the Fall '09 term at New York Institute of Technology-Westbury.

Page1 / 3

company.sql - CREATE DATABASE COMPANY; USE COMPANY; CREATE...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online