Question: Hello, I need assistance with the SQL questions in BOLD. I have also provided all my relevant code so far This star schema represents groups
Hello, I need assistance with the SQL questions in BOLD. I have also provided all my relevant code so far

This star schema represents groups of people (parties) eating meals at restaurants. The schema is grained to each individual menu item selection for each meal. The schema is incomplete in that it does not represent all significant information that would be included for a complete picture. The following business rules help capture the restaurants workings.
- Parties of one or more people eat meals at restaurants.
- The restaurants ask each party to give a name associated with the party, in addition to the number of people in the party, when the party arrives (or when the party makes the reservation).
- Each party selects one or more items from the menu for their meal; the same item might be selected multiple times at the same meal if different people want to eat the same item.
- Every menu item has a category (such as Entre, Side, Dessert, and so on).
- There are many restaurants, and each restaurant has their own name, location, and address.
- A waitperson serves a party.
_______________________________________________________________________
DROP TABLE Menu_item_selection; DROP TABLE Party; DROP TABLE Meal_date; DROP TABLE Menu_item;
CREATE TABLE Party ( party_id DECIMAL(12) NOT NULL PRIMARY KEY, number_in_party DECIMAL(3) NOT NULL, party_name VARCHAR(64));
CREATE TABLE Meal_date ( meal_date_id DECIMAL(12) NOT NULL PRIMARY KEY, meal_date DATE NOT NULL, year DECIMAL(4) NOT NULL, month DECIMAL(2) NOT NULL, day_of_month DECIMAL(2) NOT NULL);
CREATE TABLE Menu_item ( menu_item_id DECIMAL(12) NOT NULL PRIMARY KEY, item_category VARCHAR(32) NOT NULL, item_name VARCHAR(32) NOT NULL, item_price DECIMAL(6,2));
CREATE TABLE Menu_item_selection ( party_id DECIMAL(12) NOT NULL, meal_date_id DECIMAL(12) NOT NULL, menu_item_id DECIMAL(12) NOT NULL, FOREIGN KEY (party_id) REFERENCES Party(party_id), FOREIGN KEY (meal_date_id) REFERENCES Meal_date(meal_date_id), FOREIGN KEY (menu_item_id) REFERENCES Menu_item(menu_item_id));
CREATE TABLE Restaurants( restaurant_id DECIMAL(12) NOT NULL PRIMARY KEY, restaurant_name VARCHAR(64) NOT NULL, restaurant_location VARCHAR(100) NOT NULL, restaurant_address VARCHAR(100) NOT NULL);
ALTER TABLE Menu_item_selection ADD restaurant_id DECIMAL(12) NOT NULL;
ALTER TABLE Menu_item_selection ADD FOREIGN KEY (restaurant_id) REFERENCES Restaurants(restaurant_id);
ALTER TABLE Menu_item_selection ADD price_charged DECIMAL(8,2) NOT NULL;
________________________________________________________________________
- Next, identify and make use of a useful measure by completing the following.
- As there are no measures in the schema, identify a useful one that could be added, and explain what it measures
A useful measure would be the price charged for total menu item selections
- In SQL, add the measure to the fact table.
(is this a good example?)
ALTER TABLE Menu_item_selection ADD price_charged DECIMAL(8,2) NOT NULL;
- In SQL, insert 10 rows of data into the fact table, along with the corresponding dimension rows. Make sure the data has some variety.
- Write a query that uses the ROLLUP extension to GROUP BY, along with an aggregate function on the measure, to analyze some important aspect of the business. Explain what the results mean.
Imagine that an organization uses a data mart to record restaurants' transactions worldwide, and offer services such as reports and performance analysis to help optimize restaurants' profitability. To capture the information, the organization provides an application the integrates with the restaurants' point of sales systems, which then transmits the data back to the organization in near real time. This information is stored in the star schema below. Party party_id:DECIMAL(12) {PK} number_in_party:DECIMAL(3) party_name:VARCHAR(64) 1..1 0..* Menu_item_selection party_id:DECIMAL(12) {FK1} meal_date_id:DECIMAL(12) {FK2} menu_item_id:DECIMAL(12) {FK3} 1..1 Meal_date meal_date_id:DECIMAL(12) {PK} meal_date:DATE year:DECIMAL(4) month:DECIMAL(2) day_of_month:DECIMAL (2) 0..* 0..* 1..1 Menu_item menu_item_id:DECIMAL(12) {PK} item_category:VARCHAR(32) item_name:VARCHAR(32) item_price:DECIMAL(6,2)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
