MADRIDANO Lab-1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Name: Madridano, Charlyn H.

Subject: Information Management

Lab 1 Building a Database

Task 1.1

Script: CREATE DATABASE Themeparkdb;

Task 1.2

Script: SHOW DATABASES;

Task 1.3

Script: USE themeparkdb;

Task 1.4

Script: CREATE TABLE Themepark( ParkCode VarChar(100) NOT NULL,


ParkName VarChar(100) NOT NULL, ParkCity VarChar(100),ParkCountry
VarChar(100),Primary Key(ParkCode) );
Script: CREATE TABLE attraction(attNum int NOT NULL,ParkCode VarChar(100) NOT
Null, attName VarChar(100), attAge int, attCapacity int,
Primary Key(attNum),
Foreign Key(ParkCode) REFERENCES themepark(ParkCode));

Script: CREATE TABLE sales (salesNum int NOT NULL, ParkCode VarChar(100) NOT
NULL, salesDate DATE,
Primary Key(salesNum),
Foreign Key(ParkCode) REFERENCES themepark(ParkCode));

Script: CREATE TABLE employee( empNum int NOT NULL, ParkCode VarChar(100) NOT NUll,
empTitle VarChar(100),empLName VarChar(100), empFName VarChar(100), empDateOfBirth
DATE, empHireDate DATE, empAreaCode int, empPhoneNum VarChar(100),
Primary Key(empNum),
Foreign Key(ParkCode) REFERENCES themepark(ParkCode));

Script: CREATE TABLE ticket(ticketNum int NOT NULL, ParkCode VarChar(100) NOT
NULL, ticketPrice DOUBLE, tikcetType VarChar(100),
Primary Key(ticketNum),
Foreign Key(ParkCode) REFERENCES themepark(ParkCode));
Script: CREATE TABLE sales_line(lineNum int NOT NULL, salesNum int NOT NULL, ticketNum
int NOT NULL, lineQty VarChar(100), linePrice DOUBLE,
Primary Key(lineNum),
Foreign Key(salesNum) REFERENCES sales(salesNum),
Foreign Key(ticketNum) REFERENCES ticket(ticketNum)

);

Script: CREATE TABLE hours( hrNum int NOT NULL, attNum int NOT NULL, empNum int NOT
NULL, hrsPerAttract TIME, hrRate DOUBLE, hrDateWorked DATETIME, Primary Key(hrNum),
Foreign Key(attNum) REFERENCES attraction(attNum),
Foreign Key(empNum) REFERENCES employee(empNum));
Task 1.5

Script: SHOW TABLES;


Task 1.6

Script: Desc themepark;

Script: Desc ticket;

Script: Desc attraction;


Script: Desc employee;

Script: Desc hours;

Script: Desc sales;

Script: Desc sales_line

Task 1.7

Script: CREATE INDEX empLNameIndex ON Employee(empLName);

Task 1.8

Script: ALTER TABLE attraction MODIFY attCapacity NUMERIC(4);


Task 1.9

Script: DROP TABLE hours;

Task 1.10

Script: CREATE TABLE hours( hrNum int NOT NULL,attNum int NOT NULL, empNum int NOT
NULL, hrsPerAttract TIME, hrRate DOUBLE, hrDateWorked DATETIME,
Primary Key(hrNum),
Foreign Key(attNum) REFERENCES attraction(attNum),
Foreign Key(empNum) REFERENCES employee(empNum));

You might also like