SlideShare a Scribd company logo
1 of 4
Download to read offline
-- Table `Region`
-- -----------------------------------------------------
CREATE DATABASE tourista_db;
USE tourista_db;
SET AUTOCOMMIT = 0;
SET FOREIGN_KEY_CHECKS=0;
START TRANSACTION;
-- START TRANSACTION;
DROP TABLE IF EXISTS `Booking` ;
DROP TABLE IF EXISTS `Cottage_Facility` ;
DROP TABLE IF EXISTS `Facility` ;
DROP TABLE IF EXISTS `Cottage` ;
DROP TABLE IF EXISTS `Customer` ;
DROP TABLE IF EXISTS `Region` ;
CREATE TABLE IF NOT EXISTS `Region` (
`Region_Code` INT NOT NULL,
`Region_Name` VARCHAR(45) NOT NULL,
PRIMARY KEY (`Region_Code`)
);
-- -----------------------------------------------------
-- Table `Customer`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Customer` (
`Customer_ID` INT NOT NULL,
`Customer_LName` VARCHAR(45) NOT NULL,
`Customer_FName` VARCHAR(45) NOT NULL,
`Customer_MInitial` VARCHAR(5) NULL,
`Customer_Email` VARCHAR(45) NULL,
`Customer_Phone` VARCHAR(15) NULL,
PRIMARY KEY (`Customer_ID`)
);
-- -----------------------------------------------------
-- Table `Facility`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Facility` (
`Facility_ID` INT NOT NULL,
`Facility_Name` VARCHAR(45) NOT NULL,
`Facility_IsShared` TINYINT(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`Facility_ID`)
);
-- -----------------------------------------------------
-- Table `Cottage`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Cottage` (
`Cottage_ID` INT NOT NULL,
`Cottage_Name` VARCHAR(45) NOT NULL,
`Cottage_NumRooms` INT NOT NULL,
`Region_Code` INT NOT NULL,
PRIMARY KEY (`Cottage_ID`),
CONSTRAINT `fk_Cottage_Region`
FOREIGN KEY (`Region_Code`)
REFERENCES `Region` (`Region_Code`)
);
-- -----------------------------------------------------
-- Table `Cottage_Facility`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Cottage_Facility` (
`CF_Num` INT NOT NULL,
`Facility_ID` INT NOT NULL,
`Cottage_ID` INT NOT NULL,
PRIMARY KEY (`CF_Num`),
CONSTRAINT `fk_Cottage_Facility_Facility1`
FOREIGN KEY (`Facility_ID`)
REFERENCES `Facility` (`Facility_ID`),
CONSTRAINT `fk_Cottage_Facility_Cottage1`
FOREIGN KEY (`Cottage_ID`)
REFERENCES `Cottage` (`Cottage_ID`)
);
-- -----------------------------------------------------
-- Table `Booking`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Booking` (
`Booking_ID` INT NOT NULL,
`Booking_Date` DATE NOT NULL,
`Booking_Price` INT NOT NULL,
`Customer_ID` INT NOT NULL,
`Cottage_ID` INT NOT NULL,
PRIMARY KEY (`Booking_ID`),
CONSTRAINT `fk_Booking_Customer1`
FOREIGN KEY (`Customer_ID`)
REFERENCES `Customer` (`Customer_ID`),
CONSTRAINT `fk_Booking_Cottage1`
FOREIGN KEY (`Cottage_ID`)
REFERENCES `Cottage` (`Cottage_ID`)
);
-- -----------------------------------------------------
-- Data Insertion
-- -----------------------------------------------------
insert into Region values (7821,'Halifax');
insert into Region values (7822,'Bear River');
insert into Region values (7823,'Pictou');
insert into Region values (9021,'Sherbrooke');
insert into Region values (9022,'Digby');
insert into Region values (9023,'Kingston');
insert into Region values (9024,'Shelburne');
insert into Cottage values (1,'Atlantic Beach Resort Cottage 1',4,9021);
insert into Cottage values (2,'Atlantic Beach Resort Cottage 2',3,9021);
insert into Cottage values (3,'Atlantic Beach Resort Cottage 3',2,9021);
insert into Cottage values (4,'Green Ocean Cottage 20',3,9024);
insert into Cottage values (5,'Green Ocean Cottage 30',2,9024);
insert into Cottage values (6,'Green Ocean Cottage 40',1,9024);
insert into Cottage values (7,'Surf Cottage 1',2,7821);
insert into Cottage values (8,'Surf Cottage 2',3,7821);
insert into Cottage values (9,'Lagoona',4,7823);
insert into Cottage values (10,'Pine Resort A',1,9021);
insert into Customer values (10010,'DalFCS','Student','','myemail@mymail.com','9021234567');
insert into Customer values (10011,'Perkins','Bob','','bob@whatmail.ca','5901293456');
insert into Customer values (10012,'Oscar','Charlie','','coscar@nomail.org','6222257079');
insert into Customer values (10013,'Sybil','Dave','G','devensy007@mymail.com','4140069876');
insert into Customer values (10014,'Evenfield','Eve','S.Y','eve@whymail.ca','2121129987');
insert into Customer values (10015,'Mitchell','Frank','','frankmitchell@nomail.org','2134567890');
insert into Customer values (10016,'Damon','Grace','K','gracep@mymail.com','9024346565');
insert into Customer values (10017,'Singh','Robin','C','rsingh@yahoo.com ','9011237745');
insert into Facility values (1,'Coffee Machine',0);
insert into Facility values (2,'Refrigerator',0);
insert into Facility values (3,'Air Conditioner',0);
insert into Facility values (4,'Stove',0);
insert into Facility values (5,'Parking',0);
insert into Facility values (6,'Pool',1);
insert into Facility values (7,'Playground',1);
insert into Facility values (8,'Gym',1);
insert into Facility values (9,'Sauna',1);
insert into Facility values (10,'Beach',1);
insert into Cottage_Facility values (1,1,1);
insert into Cottage_Facility values (2,2,1);
insert into Cottage_Facility values (3,3,1);
insert into Cottage_Facility values (4,1,2);
insert into Cottage_Facility values (5,2,2);
insert into Cottage_Facility values (6,3,2);
insert into Cottage_Facility values (7,1,3);
insert into Cottage_Facility values (8,2,3);
insert into Cottage_Facility values (9,3,3);
insert into Cottage_Facility values (10,6,3);
insert into Cottage_Facility values (11,7,3);
insert into Cottage_Facility values (12,10,3);
insert into Cottage_Facility values (13,1,9);
insert into Cottage_Facility values (14,6,9);
insert into Cottage_Facility values (15,10,9);
insert into Cottage_Facility values (16,1,10);
insert into Cottage_Facility values (17,10,10);
insert into Cottage_Facility values (18,2,4);
insert into Cottage_Facility values (19,5,4);
insert into Booking values (1,'2018/01/15',594,10010,9);
insert into Booking values (2,'2018/01/15',384,10015,1);
insert into Booking values (3,'2018/01/15',1176,10012,4);
insert into Booking values (4,'2018/01/10',300,10010,3);
insert into Booking values (5,'2018/01/10',144,10011,3);
insert into Booking values (6,'2018/01/01',144,10016,3);
insert into Booking values (7,'2017/12/24',654,10010,9);
insert into Booking values (8,'2017/12/22',654,10014,9);
insert into Booking values (9,'2017/12/20',588,10012,7);
insert into Booking values (10,'2017/12/15',180,10010,10);
Q1)
Alice also wants to see how many times each of Touristas cottages have been booked. This will
help her to separate popular cottages from the not-so-popular ones. She wants you to provide a
list with the names of all cottages, the number of times they have been booked (0 if never booked)
and their average booking price. It would make more sense to her if the output is sorted by
number of bookings in descending order and then by cottage name in ascending order.
You also decide to use the alias Booked for the number of times a cottage has been booked, and
Average Price for the average booking price output column.
Q2) Touristas CEO is also concerned that cottages in some regions are not very profitable. She
wants a list of all region names where none of the cottages were ever booked for a price over 500.
(Note: Your list should exclude Regions with no cottages).

More Related Content

More from ajay1317

0 Suppose that a subsidy plan is introduced for lowincome .pdf
0 Suppose that a subsidy plan is introduced for lowincome .pdf0 Suppose that a subsidy plan is introduced for lowincome .pdf
0 Suppose that a subsidy plan is introduced for lowincome .pdfajay1317
 
+ 1D 1W1M3M1Y5Y Your position Shares Market value 15 145.pdf
+ 1D 1W1M3M1Y5Y Your position Shares Market value 15 145.pdf+ 1D 1W1M3M1Y5Y Your position Shares Market value 15 145.pdf
+ 1D 1W1M3M1Y5Y Your position Shares Market value 15 145.pdfajay1317
 
proxyc CSAPP Web proxy NAME IMPORTANT Giv.pdf
  proxyc  CSAPP Web proxy   NAME    IMPORTANT Giv.pdf  proxyc  CSAPP Web proxy   NAME    IMPORTANT Giv.pdf
proxyc CSAPP Web proxy NAME IMPORTANT Giv.pdfajay1317
 
AIDS is a diagnostic term applied to HIVinfected persons .pdf
 AIDS is a diagnostic term applied to HIVinfected persons .pdf AIDS is a diagnostic term applied to HIVinfected persons .pdf
AIDS is a diagnostic term applied to HIVinfected persons .pdfajay1317
 
Three Theories of DNA Replication Who were the two scien.pdf
 Three Theories of DNA Replication  Who were the two scien.pdf Three Theories of DNA Replication  Who were the two scien.pdf
Three Theories of DNA Replication Who were the two scien.pdfajay1317
 
The lemonade stands are perfectly competitive because A t.pdf
 The lemonade stands are perfectly competitive because A t.pdf The lemonade stands are perfectly competitive because A t.pdf
The lemonade stands are perfectly competitive because A t.pdfajay1317
 
This program reads a decimal array and outputs each numb.pdf
 This program reads a decimal array and outputs each  numb.pdf This program reads a decimal array and outputs each  numb.pdf
This program reads a decimal array and outputs each numb.pdfajay1317
 
Two novice business students come to their professor and a.pdf
 Two novice business students come to their professor and a.pdf Two novice business students come to their professor and a.pdf
Two novice business students come to their professor and a.pdfajay1317
 
Un mtodo operativo para administrar el inventario es la i.pdf
 Un mtodo operativo para administrar el inventario es la i.pdf Un mtodo operativo para administrar el inventario es la i.pdf
Un mtodo operativo para administrar el inventario es la i.pdfajay1317
 
Supongamos que la Tierra gir hacia atrs pero an orbita.pdf
 Supongamos que la Tierra gir hacia atrs pero an orbita.pdf Supongamos que la Tierra gir hacia atrs pero an orbita.pdf
Supongamos que la Tierra gir hacia atrs pero an orbita.pdfajay1317
 
Synthesizes the new DNA strands in the 5 3 direction .pdf
 Synthesizes the new DNA strands in the 5 3 direction  .pdf Synthesizes the new DNA strands in the 5 3 direction  .pdf
Synthesizes the new DNA strands in the 5 3 direction .pdfajay1317
 
returns a new copy of the LinkedList It creates a copy .pdf
 returns a new copy of the LinkedList It creates a copy .pdf returns a new copy of the LinkedList It creates a copy .pdf
returns a new copy of the LinkedList It creates a copy .pdfajay1317
 
Sony Ericsson is a global company that was established in .pdf
 Sony Ericsson is a global company that was established in .pdf Sony Ericsson is a global company that was established in .pdf
Sony Ericsson is a global company that was established in .pdfajay1317
 
11 ST segment depression may indicate Ischemia Normal fin.pdf
 11 ST segment depression may indicate Ischemia Normal fin.pdf 11 ST segment depression may indicate Ischemia Normal fin.pdf
11 ST segment depression may indicate Ischemia Normal fin.pdfajay1317
 
Realice una investigacin adicional para obtener ms infor.pdf
 Realice una investigacin adicional para obtener ms infor.pdf Realice una investigacin adicional para obtener ms infor.pdf
Realice una investigacin adicional para obtener ms infor.pdfajay1317
 
Elvira es una pintora abstracta con un talento increble p.pdf
 Elvira es una pintora abstracta con un talento increble p.pdf Elvira es una pintora abstracta con un talento increble p.pdf
Elvira es una pintora abstracta con un talento increble p.pdfajay1317
 
Programming Assignment 4 Calculate the first 16 Fib.pdf
 Programming Assignment 4  Calculate the first 16 Fib.pdf Programming Assignment 4  Calculate the first 16 Fib.pdf
Programming Assignment 4 Calculate the first 16 Fib.pdfajay1317
 
El sndrome X frgil es un trastorno dominante ligado al s.pdf
 El sndrome X frgil es un trastorno dominante ligado al s.pdf El sndrome X frgil es un trastorno dominante ligado al s.pdf
El sndrome X frgil es un trastorno dominante ligado al s.pdfajay1317
 
In grading eggs into small medium and large the Nancy F.pdf
 In grading eggs into small medium and large the Nancy F.pdf In grading eggs into small medium and large the Nancy F.pdf
In grading eggs into small medium and large the Nancy F.pdfajay1317
 
M 0 1 2 3 4 5 6 7 0.pdf
 M  0  1  2  3  4  5  6  7    0.pdf M  0  1  2  3  4  5  6  7    0.pdf
M 0 1 2 3 4 5 6 7 0.pdfajay1317
 

More from ajay1317 (20)

0 Suppose that a subsidy plan is introduced for lowincome .pdf
0 Suppose that a subsidy plan is introduced for lowincome .pdf0 Suppose that a subsidy plan is introduced for lowincome .pdf
0 Suppose that a subsidy plan is introduced for lowincome .pdf
 
+ 1D 1W1M3M1Y5Y Your position Shares Market value 15 145.pdf
+ 1D 1W1M3M1Y5Y Your position Shares Market value 15 145.pdf+ 1D 1W1M3M1Y5Y Your position Shares Market value 15 145.pdf
+ 1D 1W1M3M1Y5Y Your position Shares Market value 15 145.pdf
 
proxyc CSAPP Web proxy NAME IMPORTANT Giv.pdf
  proxyc  CSAPP Web proxy   NAME    IMPORTANT Giv.pdf  proxyc  CSAPP Web proxy   NAME    IMPORTANT Giv.pdf
proxyc CSAPP Web proxy NAME IMPORTANT Giv.pdf
 
AIDS is a diagnostic term applied to HIVinfected persons .pdf
 AIDS is a diagnostic term applied to HIVinfected persons .pdf AIDS is a diagnostic term applied to HIVinfected persons .pdf
AIDS is a diagnostic term applied to HIVinfected persons .pdf
 
Three Theories of DNA Replication Who were the two scien.pdf
 Three Theories of DNA Replication  Who were the two scien.pdf Three Theories of DNA Replication  Who were the two scien.pdf
Three Theories of DNA Replication Who were the two scien.pdf
 
The lemonade stands are perfectly competitive because A t.pdf
 The lemonade stands are perfectly competitive because A t.pdf The lemonade stands are perfectly competitive because A t.pdf
The lemonade stands are perfectly competitive because A t.pdf
 
This program reads a decimal array and outputs each numb.pdf
 This program reads a decimal array and outputs each  numb.pdf This program reads a decimal array and outputs each  numb.pdf
This program reads a decimal array and outputs each numb.pdf
 
Two novice business students come to their professor and a.pdf
 Two novice business students come to their professor and a.pdf Two novice business students come to their professor and a.pdf
Two novice business students come to their professor and a.pdf
 
Un mtodo operativo para administrar el inventario es la i.pdf
 Un mtodo operativo para administrar el inventario es la i.pdf Un mtodo operativo para administrar el inventario es la i.pdf
Un mtodo operativo para administrar el inventario es la i.pdf
 
Supongamos que la Tierra gir hacia atrs pero an orbita.pdf
 Supongamos que la Tierra gir hacia atrs pero an orbita.pdf Supongamos que la Tierra gir hacia atrs pero an orbita.pdf
Supongamos que la Tierra gir hacia atrs pero an orbita.pdf
 
Synthesizes the new DNA strands in the 5 3 direction .pdf
 Synthesizes the new DNA strands in the 5 3 direction  .pdf Synthesizes the new DNA strands in the 5 3 direction  .pdf
Synthesizes the new DNA strands in the 5 3 direction .pdf
 
returns a new copy of the LinkedList It creates a copy .pdf
 returns a new copy of the LinkedList It creates a copy .pdf returns a new copy of the LinkedList It creates a copy .pdf
returns a new copy of the LinkedList It creates a copy .pdf
 
Sony Ericsson is a global company that was established in .pdf
 Sony Ericsson is a global company that was established in .pdf Sony Ericsson is a global company that was established in .pdf
Sony Ericsson is a global company that was established in .pdf
 
11 ST segment depression may indicate Ischemia Normal fin.pdf
 11 ST segment depression may indicate Ischemia Normal fin.pdf 11 ST segment depression may indicate Ischemia Normal fin.pdf
11 ST segment depression may indicate Ischemia Normal fin.pdf
 
Realice una investigacin adicional para obtener ms infor.pdf
 Realice una investigacin adicional para obtener ms infor.pdf Realice una investigacin adicional para obtener ms infor.pdf
Realice una investigacin adicional para obtener ms infor.pdf
 
Elvira es una pintora abstracta con un talento increble p.pdf
 Elvira es una pintora abstracta con un talento increble p.pdf Elvira es una pintora abstracta con un talento increble p.pdf
Elvira es una pintora abstracta con un talento increble p.pdf
 
Programming Assignment 4 Calculate the first 16 Fib.pdf
 Programming Assignment 4  Calculate the first 16 Fib.pdf Programming Assignment 4  Calculate the first 16 Fib.pdf
Programming Assignment 4 Calculate the first 16 Fib.pdf
 
El sndrome X frgil es un trastorno dominante ligado al s.pdf
 El sndrome X frgil es un trastorno dominante ligado al s.pdf El sndrome X frgil es un trastorno dominante ligado al s.pdf
El sndrome X frgil es un trastorno dominante ligado al s.pdf
 
In grading eggs into small medium and large the Nancy F.pdf
 In grading eggs into small medium and large the Nancy F.pdf In grading eggs into small medium and large the Nancy F.pdf
In grading eggs into small medium and large the Nancy F.pdf
 
M 0 1 2 3 4 5 6 7 0.pdf
 M  0  1  2  3  4  5  6  7    0.pdf M  0  1  2  3  4  5  6  7    0.pdf
M 0 1 2 3 4 5 6 7 0.pdf
 

Recently uploaded

Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 

Recently uploaded (20)

Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 

Table Region .pdf

  • 1. -- Table `Region` -- ----------------------------------------------------- CREATE DATABASE tourista_db; USE tourista_db; SET AUTOCOMMIT = 0; SET FOREIGN_KEY_CHECKS=0; START TRANSACTION; -- START TRANSACTION; DROP TABLE IF EXISTS `Booking` ; DROP TABLE IF EXISTS `Cottage_Facility` ; DROP TABLE IF EXISTS `Facility` ; DROP TABLE IF EXISTS `Cottage` ; DROP TABLE IF EXISTS `Customer` ; DROP TABLE IF EXISTS `Region` ; CREATE TABLE IF NOT EXISTS `Region` ( `Region_Code` INT NOT NULL, `Region_Name` VARCHAR(45) NOT NULL, PRIMARY KEY (`Region_Code`) ); -- ----------------------------------------------------- -- Table `Customer` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `Customer` ( `Customer_ID` INT NOT NULL, `Customer_LName` VARCHAR(45) NOT NULL, `Customer_FName` VARCHAR(45) NOT NULL, `Customer_MInitial` VARCHAR(5) NULL, `Customer_Email` VARCHAR(45) NULL, `Customer_Phone` VARCHAR(15) NULL, PRIMARY KEY (`Customer_ID`) ); -- ----------------------------------------------------- -- Table `Facility` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `Facility` ( `Facility_ID` INT NOT NULL, `Facility_Name` VARCHAR(45) NOT NULL, `Facility_IsShared` TINYINT(1) NOT NULL DEFAULT 0, PRIMARY KEY (`Facility_ID`) ); -- ----------------------------------------------------- -- Table `Cottage`
  • 2. -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `Cottage` ( `Cottage_ID` INT NOT NULL, `Cottage_Name` VARCHAR(45) NOT NULL, `Cottage_NumRooms` INT NOT NULL, `Region_Code` INT NOT NULL, PRIMARY KEY (`Cottage_ID`), CONSTRAINT `fk_Cottage_Region` FOREIGN KEY (`Region_Code`) REFERENCES `Region` (`Region_Code`) ); -- ----------------------------------------------------- -- Table `Cottage_Facility` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `Cottage_Facility` ( `CF_Num` INT NOT NULL, `Facility_ID` INT NOT NULL, `Cottage_ID` INT NOT NULL, PRIMARY KEY (`CF_Num`), CONSTRAINT `fk_Cottage_Facility_Facility1` FOREIGN KEY (`Facility_ID`) REFERENCES `Facility` (`Facility_ID`), CONSTRAINT `fk_Cottage_Facility_Cottage1` FOREIGN KEY (`Cottage_ID`) REFERENCES `Cottage` (`Cottage_ID`) ); -- ----------------------------------------------------- -- Table `Booking` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `Booking` ( `Booking_ID` INT NOT NULL, `Booking_Date` DATE NOT NULL, `Booking_Price` INT NOT NULL, `Customer_ID` INT NOT NULL, `Cottage_ID` INT NOT NULL, PRIMARY KEY (`Booking_ID`), CONSTRAINT `fk_Booking_Customer1` FOREIGN KEY (`Customer_ID`) REFERENCES `Customer` (`Customer_ID`), CONSTRAINT `fk_Booking_Cottage1` FOREIGN KEY (`Cottage_ID`) REFERENCES `Cottage` (`Cottage_ID`)
  • 3. ); -- ----------------------------------------------------- -- Data Insertion -- ----------------------------------------------------- insert into Region values (7821,'Halifax'); insert into Region values (7822,'Bear River'); insert into Region values (7823,'Pictou'); insert into Region values (9021,'Sherbrooke'); insert into Region values (9022,'Digby'); insert into Region values (9023,'Kingston'); insert into Region values (9024,'Shelburne'); insert into Cottage values (1,'Atlantic Beach Resort Cottage 1',4,9021); insert into Cottage values (2,'Atlantic Beach Resort Cottage 2',3,9021); insert into Cottage values (3,'Atlantic Beach Resort Cottage 3',2,9021); insert into Cottage values (4,'Green Ocean Cottage 20',3,9024); insert into Cottage values (5,'Green Ocean Cottage 30',2,9024); insert into Cottage values (6,'Green Ocean Cottage 40',1,9024); insert into Cottage values (7,'Surf Cottage 1',2,7821); insert into Cottage values (8,'Surf Cottage 2',3,7821); insert into Cottage values (9,'Lagoona',4,7823); insert into Cottage values (10,'Pine Resort A',1,9021); insert into Customer values (10010,'DalFCS','Student','','myemail@mymail.com','9021234567'); insert into Customer values (10011,'Perkins','Bob','','bob@whatmail.ca','5901293456'); insert into Customer values (10012,'Oscar','Charlie','','coscar@nomail.org','6222257079'); insert into Customer values (10013,'Sybil','Dave','G','devensy007@mymail.com','4140069876'); insert into Customer values (10014,'Evenfield','Eve','S.Y','eve@whymail.ca','2121129987'); insert into Customer values (10015,'Mitchell','Frank','','frankmitchell@nomail.org','2134567890'); insert into Customer values (10016,'Damon','Grace','K','gracep@mymail.com','9024346565'); insert into Customer values (10017,'Singh','Robin','C','rsingh@yahoo.com ','9011237745'); insert into Facility values (1,'Coffee Machine',0); insert into Facility values (2,'Refrigerator',0); insert into Facility values (3,'Air Conditioner',0); insert into Facility values (4,'Stove',0); insert into Facility values (5,'Parking',0); insert into Facility values (6,'Pool',1); insert into Facility values (7,'Playground',1); insert into Facility values (8,'Gym',1); insert into Facility values (9,'Sauna',1); insert into Facility values (10,'Beach',1); insert into Cottage_Facility values (1,1,1); insert into Cottage_Facility values (2,2,1); insert into Cottage_Facility values (3,3,1); insert into Cottage_Facility values (4,1,2);
  • 4. insert into Cottage_Facility values (5,2,2); insert into Cottage_Facility values (6,3,2); insert into Cottage_Facility values (7,1,3); insert into Cottage_Facility values (8,2,3); insert into Cottage_Facility values (9,3,3); insert into Cottage_Facility values (10,6,3); insert into Cottage_Facility values (11,7,3); insert into Cottage_Facility values (12,10,3); insert into Cottage_Facility values (13,1,9); insert into Cottage_Facility values (14,6,9); insert into Cottage_Facility values (15,10,9); insert into Cottage_Facility values (16,1,10); insert into Cottage_Facility values (17,10,10); insert into Cottage_Facility values (18,2,4); insert into Cottage_Facility values (19,5,4); insert into Booking values (1,'2018/01/15',594,10010,9); insert into Booking values (2,'2018/01/15',384,10015,1); insert into Booking values (3,'2018/01/15',1176,10012,4); insert into Booking values (4,'2018/01/10',300,10010,3); insert into Booking values (5,'2018/01/10',144,10011,3); insert into Booking values (6,'2018/01/01',144,10016,3); insert into Booking values (7,'2017/12/24',654,10010,9); insert into Booking values (8,'2017/12/22',654,10014,9); insert into Booking values (9,'2017/12/20',588,10012,7); insert into Booking values (10,'2017/12/15',180,10010,10); Q1) Alice also wants to see how many times each of Touristas cottages have been booked. This will help her to separate popular cottages from the not-so-popular ones. She wants you to provide a list with the names of all cottages, the number of times they have been booked (0 if never booked) and their average booking price. It would make more sense to her if the output is sorted by number of bookings in descending order and then by cottage name in ascending order. You also decide to use the alias Booked for the number of times a cottage has been booked, and Average Price for the average booking price output column. Q2) Touristas CEO is also concerned that cottages in some regions are not very profitable. She wants a list of all region names where none of the cottages were ever booked for a price over 500. (Note: Your list should exclude Regions with no cottages).