Reference no: EM132317422
Database Design and Development Assignment -
For all the SQL queries in this assignment, need to submit their SQL statements constructed directly, that is, not to generate the SQL script for you by the GUI, as this would defeat the purpose of practicing how to formulate SQL queries directly.
Q1. Selected Exercises
i. Describe a simple database of your choice or design, along with the table/s representing the data, and illustrate the Insertion Anomaly through the real data or records there. Your database should be different from those already covered in the lectures or practicals.
ii. For database along with its inserted records prac8data.sql, do any 2 of the following database queries. For each query, take a screenshot for the query result and the screenshot is to include the SQL script window as well. Before finalising your answers, refresh your database by reloading prac8tables.sql and prac8data.sql, if necessary, so that the results are uniform across the board.
a. List P_DESCRIPT and P_PRICE for a product and the name V_NAME of the vendor who can supply the product. The output should be sorted according to P_DESCRIPT and then the V_NAME, all in the alphabetic order.
b. For the customer Phan Wang, list the names (i.e. PDESCRIPT) of all the products ever ordered by this customer. Do not repeat the product names in the result.
c. List all the customer order (ORDER_CODE), the fullname of the customer, and the corresponding total cost for each order.
Q2. Database modelling
In this part, you are asked to design a database to support an Accommodation Booking System for HappyHolidays (HH), which is a mid-size online reservation company. The major business requirements are summarised below in the Mini Case:
HH receives booking requests from prospective visitors for accommodation in various locations. Accommodation can be of different types; for example, house, apartment, motel room, cabin, etc. Each type is uniquely identified by a code (H = house, Ap = apartment). Each type could also have specific information such as rate, size (1 bed, 2, bed, 3 bed, etc.), location and minimum and maximum number of required stay (in days). Visitors details are recorded, at least their full name, telephone number, address, and postcode.
Additionally, each type can have various conditions or restrictions: for example, a visitor is allowed up to 2 pets if they rent a house, but they can't have any pets if they rent any other type of accommodation. Pet type, breed and name also need to be recorded.
If visitors take a pet, HH needs to be notified at the time of booking the accommodation, and the visitor is charged an additional fee for each pet. Pets are given a kennel each. Each pet is identified by name and collar ID. Also kennels are labelled to identify the pet in it at any time.
You are asked to develop a detailed Entity-Relationship model (ER) for this mini case. Your ER model should consist of a detailed ER diagram integrated with itemised discussions on the features of the entities and relationships and all the assumptions you made where applicable.
The ER diagram and the accompanying document should identify keys, constraints, entity types, relationship types, specialisation/generalisation if any, etc.
You must use the same notation scheme for the ER diagram as the textbook (use UML notations as shown in the last page of the textbook, and don't use Crow Foot notations), and the ER diagram should be strictly in the way shown or used in the textbook - using any other notations other than UML will result in loss of marks. ER can be drawn in draw.io, or even Microsoft PowerPoint. A screenshot of the ER can then be placed as an object in your assignment Word document.
i. The ER diagram should include, among others, representative attributes for all entity types, proper subclassing if any, and correct participation multiplicities for the relationship types. It should be meaningful and well designed, and should also include all relevant and necessary aspects, and indicate any supplementary business rules if you decide to introduce.
ii. Map the above ER diagram into a global relation diagram (GRD). The GRD should be in a form similar to Figure 17.9 (page 554, or 516 for edition 5) of the textbook, but all the attributes should be kept there too. Include in the diagram all the primary keys, foreign keys, and the multiplicity constraints.
Please note that an ERD is the artefact of the conceptual database design phase, while a GRD is the artefact of the logical database design phase which relates to the relational models. As such, a good ERD should be conceptually more concise and the relationships there should in general remain so rather than becoming extra entities as in a relational model.
Below is the given mini case for you to design your database for the ER and GRD as the instructions given above.
Q3. More analysis and SQL
i. Create the database tables in SQL (runnable on Microsoft SQL Server) for all the relations in your relation diagram, and enforce there all the relevant constraints including primary keys and foreign keys. It is expected to have at least 3-6 attributes in each table.
Adding records: Fill the tables with sufficient realistic data - generally around 3 tuples or more per table. For example you may assume a visitor made at least 3 bookings on different dates. Your data should be sufficient to illustrate meaningfully the working of the general queries to be completed below:
ii. In the most appropriate table (say visitor) add a tuple with meaningful data about your own details (your student name and ID + ... etc.): do the same for your group member's details in another tuple if you have a group member.
List the content of your tables with screenshots. Screenshots of active windows (under Microsoft Windows) can be obtained by pressing CTRL-ALT-PRTSC keys together (or you may use the snipping tool). Your screenshots must contain your username as in the below example, and you may list several tables on a single screenshot if you wish.
iii. Write in SQL the commands to complete the following queries, and show your results in screenshots. Where parameters for the queries below are not completely specified, the parameters should be chosen so as to generate non-trivial (non-empty) results for the queries (meaning you must update the tables above to ensure you can answer the questions).
(a) For a given visitor and a given date, list all the names of those who have made a booking within a date (ie: from 6/11/2018 to 20/11/2018), along with the type of accommodation they booked and the location of the accommodation.
(b) Show the number of times a visitor had made a booking. List the visitor's full name and contact along with the booking date.
(c) List all the visitors who have also booked with a pet, showing the visitor ID and the Pet name in your results.
(d) For a given type of accommodation, say 3 bedroom house, show what is still available (have not been booked) and the location/address of these still available.
Attachment:- Assignment Files.rar