| CCS 2100 | | Comp 310 | | CCS 1300 | | CCS 1200 | | CCS 1100 | | CCS 1000 | | CS 212 | | Email: cpuccs@yahoo.com

Thursday, September 25, 2014

Queries in the Enrayle's Party Planning Lesson

CREATE TABLE Customer
(
CustID int PRIMARY KEY,
Lastname varchar(50) NOT NULL,
Firstname varchar(50) NOT NULL,
Middlename varchar(50) NOT NULL,
CustAddress varchar(50),
ContactNumber varchar(50),
Email varchar(50)
);

CREATE TABLE Party
(
PartyID int PRIMARY KEY,
PartyName varchar(50) NOT NULL,
PartyDate varchar(50) NOT NULL,
Nature_ofParty varchar(50),
PartyAddress varchar(50) NOT NULL,
CustID int NOT NULL
);

CREATE TABLE Food
(
FoodID int PRIMARY KEY,
FoodName varchar(50) NOT NULL,
FoodType varchar(50)
);


CREATE TABLE Menu
(
MenuID int PRIMARY KEY,
PartyID int NOT NULL,
FoodID int NOT NULL,
No_Servings int NOT NULL
);

INSERT INTO Customer
(CustID, Firstname, Lastname, Middlename,
CustAddress, ContactNumber, Email)
VALUES
('1','Jhosalie','Ardena','Uy',
'Pavia','12345','jhosaardena@yahoo.com'),
('2','RK','Astronomia','Eusuya',
'Roxas','54321','RKEusuya@gmail.com'),
('3','Striker','Aspero','Macasio',
'Pasig','67891','strikermacasio@yahoo.com');

INSERT INTO Party
(PartyID, PartyName, PartyDate, Nature_ofParty,
PartyAddress, CustID)
VALUES
('1','Francis 28th

Birthday','11/01/2014','Bday',
'Zarraga','2'),
('2','Death Anniversary','12/24/2014','Burial',
'Leganes','3'),
('3','Jing Jing Bday','1/1/2015','Bday',
'Jaro','2');

INSERT INTO Food
(FoodID, FoodName, FoodType)
VALUES
('1','Solar Dried Fish','Snack'),
('2','KBL','Dish'),
('3','Menudo','Dish');

SELECT * FROM Food;

INSERT INTO Menu
(MenuID, FoodID, PartyID, No_Servings)
VALUES
('1','1','1','200'),
('2','3','2','150'),
('3','3','3','50');

SELECT * FROM Menu;

SELECT Lastname, Firstname, Middlename FROM

Customer;

SELECT FoodName, FoodType FROM Food;

SELECT Food.FoodName, Food.FoodType,

Menu.No_Servings
FROM Party
INNER JOIN Menu
ON Party.PartyID = Menu.PartyID
INNER JOIN Food
ON Menu.FoodID = Food.FoodID
WHERE Party.PartyName = 'Jing Jing Bday'



SELECT Party.PartyName, Party.PartyAddress
FROM Customer
INNER JOIN Party
ON Customer.CustID = Party.CustID
WHERE Customer.Lastname = 'Astronomia';

SELECT Customer.Lastname FROM Food
INNER JOIN Menu
ON Food.FoodID = Menu.FoodID
INNER JOIN Party
ON Menu.PartyID = Party.PartyID
INNER JOIN Customer
ON Party.CustID = Customer.CustID
WHERE Food.FoodName = 'Menudo';

No comments:

Post a Comment