Create all of the scripts

Assignment Help Database Management System
Reference no: EM131479709

Database Design & Implementation (Pizza Store)

Task 1 - Database Design

Your first task is to design a database for the scenario detailed on the following pages. Your final database design should comprise of approximately 9 entities.

State any assumptions you have made regarding your database design at the beginning of the database design document. Do not make any assumptions that significantly change the structure of the scenario, as this may make Task 2 of the assignment difficult. Only make assumptions that influence your database design. If you are unsure about an assumption you wish to make, ask your tutor.

Once you feel you have identified the entities, attributes and relationships of the scenario in sufficient depth, you are required to create a logical ER diagram nd a corresponding physical ER diagram to depict your database. Adhere to the distinctions between logical and physical ER diagrams covered in Lecture 3. It is recommended that you draw your diagrams on paper first, in order to find a layout that is clear and can be created in an electronic format.

Lastly, create a data dictionary, with an entry for each entity in your database. The entries should list the name of the entity (table), a description of its purpose, a list of attributes (columns), important information about the attributes (e.g. data type, null/not null, identity, default values...), and details of any constraints applied to attributes. List the entries in your data dictionary in an appropriate table creation order that can be used to create the database. Include any additional information, if any, that may be needed to implement the database. Remember, a data dictionary should contain all the information needed to implement a database. Use the data dictionary in Lecture 4 and the data dictionary of the "company" database (Module 5) as examples. Some marks are also awarded for presentation and notation.

Your complete database design should consist of a list of assumptions, logical and physical ER diagrams and a data dictionary. This should be submitted as a single PDF document. Make sure that your assignment includes the unit code, assignment number/name, year and semester and your name and student number on the first page.

Please ensure that your completed database design is in PDF format, and open the PDF file before submitting it to ensure that your diagrams appear as intended.

Scenario Details

You are required to design and create a database for a pizza store. The database must keep track of the details of staff, orders and pizzas (including the available types of crusts and sauces).

You have the following information about the way the store operates:

- Staff details must be recorded. This includes a staff ID number, first name, last name, date of birth and phone number.
• A staff member may be supervised by another staff member. A staff member may supervise many other staff members. Not all staff members have a supervisor.

- The details of customer orders must be recorded. This includes an order ID number, the date and time that the order was placed, the name and email address of the customer who made the order, and the ID number of the staff member who took the order.
• The store does not record any other customer details, and all orders must be picked up from the store. A customer name is required, but the email address is optional.
• An order can be for multiple pizzas, but must obviously contain at least one.

- The store has divided the types of pizza they offer into ranges, e.g. "traditional", "gourmet", etc. The database must store an ID, name and price for each range.

- The details of the types of pizza available must be recorded. This includes a pizza ID number, the pizza's name, a description and a foreign key identifying the range that the pizza is in.

- The database also needs two tables to store the details of different crust types and sauce types that can be chosen when ordering a pizza.
• These tables must contain an ID number and a name for each crust/sauce.
• Some crusts/sauces result in a surcharge - a column is needed to store this amount.
• When ordering a pizza, a customer must choose which crust and sauce they want.

- The database must track the pizzas ordered in each order. This will involve:
• An auto-incrementing ordered pizza ID number.
• A foreign key identifying the order that this pizza is part of.
• A foreign key identifying which pizza was chosen.
• A foreign key identifying which crust was chosen.
• A foreign key identifying which sauce was chosen.
• A "ready" column containing a "Y" or "N" to indicate whether the pizza has been made and cooked yet (default of "N").

- The store also sells sides such as garlic bread and soft drinks. Details of these sides and their inclusion in orders must be recorded.
• The database must store an ID, name and price for each side.
• The database must keep track of which sides have been ordered in which orders, and the quantity ordered.

General Information and Guidelines
The information above describes all of the entities, attributes and relationships required in the database design. Some minor details, such as the cardinality of some relationships, have been omitted. It is up to you to make (and state) any assumptions you need in order to complete the database design. If you are uncertain about any part of the scenario described above, seek clarification from your tutor.

It is recommended that you use auto-incrementing integers as the primary key for all entities in this scenario, since there are no naturally occurring attributes that are suitable to use as primary keys. A compound primary key (not auto-incrementing) may be suitable for certain intermediary entities.

Be sure to specify the most appropriate data type (and length, where applicable) for each attribute in your data dictionary. Note that when you are storing a date/time, it should be stored as a single column - do not split the date and time into two columns unless there is a very good and necessary reason to do so.

Read the scenario details several times to ensure that your database design incorporates all the elements described. If you desire feedback on your work in progress, send it to your tutor.

Task 2 - Implementation

Once your database has been designed, it is time to implement it in a DBMS, populate the database, and then manipulate the data via queries. The deliverables of this task are three files containing SQL statements. We will be using Microsoft SQL Server 2014 or above - your SQL scripts must run in the same environment used in the unit/labs.

Create your scripts as three ".sql" files, with the filenames listed in the following headings. Templates for the script files are provided with this assignment brief - please use them. Format your code for readability, and use comments for headings and to provide further detail or information about your code if needed .

As each of the script files will contain numerous SQL statements, it is very useful to be aware of a particular feature of SQL Server Management Studio (SSMS): If you have selected some text in a query window, only the selected text will be executed when you press the Execute button.

1055_Queries.jpg

This makes it much easier to test a single statement, or even part of a statement, within a script file.

You are required to create all of the scripts detailed below. Please take note of the file names and use the template files provided with this assignment brief.

Filename: create.sql
This file is a creation script, similar to the "company.sql" file (Module 5) used to create the company database.

Database Creation & Population Script

Produce a script to create the database you designed in Task 1 (incorporating any changes you have made since then). Be sure to give your columns the same data types, properties and constraints specified in your data dictionary, and be sure to name tables and columns consistently. Include any logical and correct default values and any check or unique constraints that you feel are appropriate.

Make sure this script can be run multiple times without resulting in any errors (hint: drop the database if it exists before trying to create it). You can use/adapt the code at the start of the creation scripts of the sample databases available in the unit materials to implement this. You will need to follow an appropriate creation order when creating your tables - you cannot create a table with a foreign key constraint that refers to a table which does not yet exist.

Once you have created your database, it is recommended that you use SSMS to create an ER diagram and use this to verify that your implementation matches your design. This can be done by right clicking on the "Database Diagrams" folder of the database in the Object Explorer in SSMS.

Following the SQL statements to create your database and its tables, you must include statements to populate the database with sufficient test data. You are only required to populate the database with enough data to make sure that all views and queries return meaningful results. You can start working on your views and queries and write INSERT statements as needed for testing as you go.

For example, imagine you are working on a query which joins data from two tables and only displays the rows that meet certain criteria, then orders the results by a certain column. To test this, you will need to insert some data in both of the tables, making sure that some of the rows meet the criteria and others don't, and making sure that the column used for ordering contains a range of different values. Once you have inserted this data, you can test that your query works.

The final create.sql should be able to create your database and populate it with enough data to make all views and queries return meaningful results.

Make sure all referential integrity is observed - you cannot add data to a column with a foreign key constraint if you do not yet have data in the table it refers to. Remember that if you are using an auto-incrementing integer, you cannot specify a value for that column when inserting a row of data. Simply pretend the column does not exist when inserting data - do not try to specify a value for it.

Filename: views.sql
The following page contains some general information and tips regarding views.

Pizza View
Create a view which shows the following details of all pizzas:
- The pizza ID number, pizza name and pizza description.
- The pizza's range ID, range name and range price.

Ordered Sides View
Create a view which shows the order ID number, side ID number, side name, quantity and total cost of all ordered sides. This involves joining the side and ordered side tables and some basic arithmetic.

Ordered Pizzas View
Create a view which shows the following details of all ordered pizzas.
- The ordered pizza ID number, order ID number and "ready" column.
- The pizza ID number and pizza name of the ordered pizza.
- The range ID number and range name of the ordered pizza.
- The crust ID number and crust name of the ordered pizza.
- The sauce ID number and sauce name of the ordered pizza.
- The cost of the pizza (add together the range price, crust surcharge and sauce surcharge)

These views essentially create joined or "flat" versions of significant tables of the database, giving you a convenient way to access related and calculated information that is stored in multiple tables.

You are encouraged to use the views to simplify the queries which follow - You can use a view in a SELECT statement in exactly the same way as you can use a table, often avoiding the need to write the same joins and calculations over and over.

When writing a view, it is easiest to write the SELECT statement first, and only add the CREATE VIEW statement to the beginning once you have confirmed that the SELECT statement is working correctly. If you wish to create additional views to use in the queries which follow, include them in this file.

Filename: queries.sql
Write SELECT statements to complete the following queries. If you do not understand or are not sure about exactly what a query requires, contact your tutor. Marks will be lost if your query does not do what is required, even if that is due to misunderstanding the requirements.

Query 1 - Customer Email List
Write a query that concatenates customer names and email addresses from the customer order table to form a single column with the following format:
"[customer_name] <[customer_email]>", e.g. "Dom <[email protected]>"

If there are multiple orders with the same customer name and email address, it should only appear once in the results. Orders where the email address is NULL should not be included in the results.

Query 2 - Unready Pizzas
Write a query that shows the order date, pizza name, crust name and sauce name of any ordered pizzas which are not ready (ready column contains "N"). Order the results by the order date.
Using the Ordered Pizzas View in this query is recommended.

Query 3 - Staff Search
Write a query that shows the staff ID number and full name (e.g. "John Smith") and date of birth of staff members who do not have a supervisor and are less than 21 years old (calculated using the current date). Order the results by the first name column.

Query 4 - Staff Supervision
Write a query that selects the ID number and full name of all staff, as well as the ID number and full name of their supervisor. All staff should appear in the results, even if they don't have a supervisor.

Query 5 - Side Statistics
Write a query that selects the following details about the sides that have been ordered in orders:
- The side ID number and side name.
- How many orders the side has been ordered in (regardless of quantity).
- The average quantity in which the side is ordered (cast the quantity column to a FLOAT before averaging it for greater accuracy).
- The total sale cost of the side (remember to take the quantity into account).

Give all columns appropriate aliases, and order the results by the total sale cost in descending order. Using the Ordered Sides View in this query is recommended.

Query 6 - Pizza 2's Most Popular Crust/Sauce Combinations
Write a query that identifies the three most popular combinations of crust and sauce chosen for the pizza with an ID of 2. The query should select the pizza name, crust name, sauce name, cost (including crust/sauce surcharge) and the number of times that the combination has been ordered. Using the Ordered Pizzas View in this query is recommended.

Query 7 - Under-Average Ordered Pizza Costs
Write a query that shows the pizza name and average cost of ordered pizzas that have an average cost which is less than the average cost of all ordered pizzas. Order the results by the average cost, in descending order.
Using the Ordered Pizzas View in this query is recommended.

Query 8 - Customer Order Summary
Write a query that selects the following information for all customer orders:
- The order ID number, order date and customer name.
- The staff ID number and full name of the staff member who took the order.
- The total cost of pizzas in the order, total cost of sides in the order, and total cost of the order as a whole (i.e. the cost of all pizzas and all sides in the order).

Order the results by order date, and make sure that the total order cost is calculated correctly even if an order did not contain any sides or any pizzas.
Using the Ordered Pizzas View and Ordered Sides View in this query is recommended.

Presentation, Notation and Formatting
A small amount of marks are awarded for presentation, notation and formatting. This includes:
- Presentation and appearance of word processed PDF document for Task 1
- Appropriateness and consistency of notation used for diagrams/data dictionary in Task 1
- Appropriate commenting and formatting of scripts in Task 2

Attachment:- database design.zip

Reference no: EM131479709

Questions Cloud

Examine service categories commonly provided by nursing home : Determine two specific service categories that you believe are common factors of competition among nursing homes. Justify your response.
Compare the healthcare-based factors in the issues : Compare the healthcare-based factors in the issues that you reviewed that, in your opinion, cause the cost curve of healthcare to shift.
How supply chains are structured and logistics innovation : Explain how supply chains are structured and also discuss logistics innovation.
Define the use of export subsidies : To improve national welfare, a large country would do better to implement an export subsidy rather than an import tariff. Is this true or false? Explain why.
Create all of the scripts : CSG1207/CSI5135 Systems and Database Design - Your first task is to design a database for the scenario detailed on the pages.
A defined retirement plan and a contributory plan : Most employee benefits we receive from our employers are provided "tax free." Why?
Mentoring skills in a diverse workplace : Provide best practices for effectively using communication skills and/or mentoring skills in a diverse workplace.
Identify the major components of the application : Prepare a design for an application your organization might produce. Include appropriate diagrams to identify the major components of the application.
Health insurance payers may use to monitor : Compare the primary available economic resources that health insurance payers may use to monitor, assess, and regulate health care providers' behavior.

Reviews

len1479709

5/1/2017 2:07:47 AM

Task 2 (Implementation) - Marks Allocation Criteria All scripts are judged on correctness, appropriateness and readability of SQL code. Marks Database Creation & Population Script 7 Pizza View 2 Ordered Sides View 2 Ordered Pizzas View 4 Query 1 2 Query 2 2 Query 3 2 Query 4 3 Query 5 3 Query 6 3 Query 7 4 Query 8 4 Formatting – Scripts are well formatted and use appropriate formatting. 2

len1479709

5/1/2017 2:07:39 AM

Task 1 (Database Design) - Marks Allocation Criteria Marks Assumptions All/Any assumptions that influence the database design clearly stated. 2 Logical ER Diagram Diagram accurately depicts the scenario and includes all elements specified in the brief. 4 Physical ER Diagram Accurately depicts the scenario and is a correct translation of the logical ER diagram. 5 Data Dictionary Includes all entities and details of attributes as specified in brief and correct creation order used. 7 Presentation and Notation Assignment is well presented, uses consistent and appropriate notation. 2

len1479709

5/1/2017 2:07:27 AM

You may work in pairs (maximum of 2 people) to complete this assignment, or choose to work alone. If you wish to work in a pair, you must inform your tutor (by email) of the names and student numbers of both members at least one week before the due date of Task 1. If you choose to work alone, be aware that there are no extra marks to compensate for the heavier workload. If working in a pair, work through the whole assignment together, rather than dividing it and completing sections individually. This will help to ensure that both people learn the content and contribute evenly. The assignment consists of two tasks. The first task, Database Design, requires a word processed document in PDF format detailing the design of your database. The second task, Implementation, is a collection of SQL scripts which create and populate the database designed in the first task, and then query the data it contains. A small amount of marks are dedicated to presentation, notation and formatting.

len1479709

5/1/2017 2:07:18 AM

Before a database can be implemented and used, it must be designed in a way that ensures it is appropriate for the task at hand. Tools such as Entity-Relationship Diagrams and Data Dictionaries assist in designing and communicating the structure of a database. Once a design has been finalised, the database can be implemented in a DBMS. The Data Definition Language commands of SQL are used to create the database and its tables, attributes and constraints, after which the Data Manipulation Language commands can be used to manipulate data within the database. This assignment takes you through the design and implementation process, using Microsoft SQL Server

Write a Review

Database Management System Questions & Answers

  Create microsoft access database for doc-n-the-box pharmacy

Create a Microsoft Access database for the Doc-n-the-Box pharmacy. Create the table(s), field(s), data type(s), primary key(s), etc. for the database

  Create series of different users-administering privileges

You will be creating a series of different users, administering various privileges to those users, and exploring how roles help provide additional functionality to the user picture.

  Optimistic concurrency control sets few locks on the data

Optimistic concurrency control sets few locks on the data in the database, lowering the isolation level that you use in an application. This allows more applications to run concurrently and potentially increases the throughput of the applications. Th..

  Write sql code that will list all attributes for a job code

Write the SQL code that will create the table structure for a table named EMP 1. This table is a subset of the EMPLOYEE table -  write the SQL code that will list all attributes for a job code of 502.

  Create naming conventions for each entity and attributes

Create naming conventions for each entity and attributes. Propose an efficient data structure that may hold the tour operator's data using a normalization process. Describe each step of the process that will enable you to have a 2nd Normal Form da..

  Assignment- database administrator for department store

Assignment: Database Administrator for Department Store, The Strayer Oracle Server may be used to test and compile the SQL Queries developed for this assignment. Your instructor will provide you with login credentials to a Strayer University maint..

  What tables and columns would you create in relational data

You need to store information on the business's employees, inventory, and completed sales. You also need to account for the fact that each salesperson receives a different percentage of their sales in commission. What tables and columns would you ..

  Write one page about xml format

Write one page connecting the following issues as discussed in chapter Plumbing and XML format.

  Design an entity-relationship diagram for a database

Identify clients who regularly make appointments that they do not keep and to provide reports and make ad hoc queries from all the data stored in the database of the hospital registration system - design an Entity-Relationship diagram for a databas..

  What is system r and what are its two major subsystems

What is System R? What are its two major subsystems? How is the data structure of System R different from the relational structure? What is Data Independence?

  Explain the problems associated with data redundancy

Assignment 5: Logical Design, Part II, Explain the problems associated with data redundancy as it pertains to effectively using information for reporting and analysis.

  Database application improvements question

Submit an Executive Memo addressed to the CIO and the board of directors. Last week, the CIO reviewed your presentation and has decided to move forward with your recommendations for improvements.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd