Database PetersPan
Idea : To be better to setup and request information of a database.
Background : The exercise of PetersPan see: DomainER.htm
See: : https://www.w3schools.com/sql/ | https://www.codecademy.com/learn/learn-sql | http://sqlzoo.net/wiki/Main_Page
Step 1: Setup the system i.e. the Database
So before you start this exercise you need to run these two scripts:
- Create tables MSSQL | Create tables MySQL
- Insert values into the tables
When you have run these two scripts you should a database like this:
Step 2 - select from one table
- List all information from MenuItem
- List all information from MenuItem for Drinking only
- List all information from MenuItem
for Drinking only in ascending order of the price (or try descending)
- List Name and Price of MenuItems
- List all drinks of coffee of the MenuItems
- LIst all Bookings
- List all Bookings of the 16/feb 2018
- List all Bookings for Lunch time i.e. between 11-14 (11AM-2PM)
- LIst all Bookings of today
- List all the different customers who have a booking i.e. no duplicates
Hint: Dates
Get the actuale date from system - use getdate()
Get the month etc. from a date use DATEPART(MONTH, <<the date>>) -- 1st parameter Year, Month, Day, Hour, Minute, Second
Get the actuale date from system - use now()
Get the month etc. from a date use MONTH(<<the date>>)-- Year, Month, Day, Hour, Minute, Second
Step 3 - Aggregate-functions
- List the number of drinking menuItems
- List the minimum,maximum and average price of all Menuitems
- List the minimum,maximum and average price of all Menuitems with naming columns
- List the minimum,maximum and average price of all Menuitems with naming columns
For each of the menuCards
- List the minimum,maximum and average price of all Menuitems with naming columns
For each of the menuCards in a descending order of MenuCard names
- List the minimum and maximum price of all Menuitems with naming columns
For each of the TypeOfItems
- List the minimum and maximum price of all Menuitems with naming columns
For each of the TypeOfItems - But only for the Drinkings
- List the number of tables and the number of seats which have a window site.