+1(316)4441378

+44-141-628-6690

Archive for the ‘Database design and optimisation’ Category

Visio Assignment

After reviewing Appendix C of Hands-On Database, use Visio to re-create one of the E-R diagrams provided in Appendix F of Database Design for Mere Mortals. Please note that the symbols used in Visio are not identical to those used in Database Design for Mere Mortals. You should create your diagram using symbols with similar meanings.

I will provide the reading material and access to Visio if you do not have access to it

Scenario Activity

Vince Roberts runs a vintage record shop in the University district. His shop sells 45s, LPs, and even old 76 RPM records. Most of his stock is usedhe buys used vinyl from customers or finds them at yard sales and discount storesbut he does sell new albums that are released on vinyl. For a couple of years, he has kept most of his inventory either in his head or in a spiral notebook he keeps behind the sale counter. But his inventory and his business have grown to where that is far from sufficient.

Vince is looking for someone to make him a database. He knows he needs to get a better handle on several aspects of his business: He needs to know the extent and condition of his inventory. He needs to know the relative value of his inventorysome records are worth a fortune; some are nearly worthless. He also needs to track where, from whom, and for how much he purchased his stock. He needs to track his sales. He often is not entirely sure how much money he has spent or how much money

Transaction control procedure

Transaction control***

Create a stored procedure with the following requirements: 

    Accept input that identifies the customer, the ISBN for one book, and the quantity being ordered.  CHALLENGE -- try this for two books instead of one 
    Create an ORDER record that reflects today's date as the OrderDate.   
    Create an OrderItem record for the book(s) being ordered,  reduce the (quantity on hand) appropriately for the ordered book, and either:

        Return an error message if there is not sufficient inventory for the book ordered. 

OR

        Commit the transaction   

    Leave the shipping information null (there will be a separate process for shipping information). 

Remember that the Order#  is a unique, sequential key.

SQL Stored Procedures

Create a stored procedure NEWGUESTBOOKING that adds a booking for a new guest.

The stored procedure NEWGUESTBOOKING receives the following parameters

Input Parameters
Guest name
Guest address
HotelNo
RoomNo
dateFrom
dateTo

Output Parameters
BookingNo int
BookingResult char(40)


The stored procedure
1.  Set autocommit = OFF;
2.  Issue the START TRANSACTION;
3.  Get the max guestNo in the database.
4.  Insert a new guest into the guest table using the max_guestno + 1, and the input parameters of the guest name.
5.  Check if the HotelNo is valid, if not rollback and exit. Code CONTINUE HANDLE Exception for NOT FOUND and set a HOTELINVALID FLAG ON.
6.  Check if the RoomNo  is valid, if not rollback and exit. Code CONTINUE HANDLE Exception for NOT FOUND and set a ROOMINVALID FLAG ON.
7.  Optionally, check if a booking already exist for the hotelno, roomno for the requested sta

Pick A pet

7.1 Output Design Prototypes
7.1.1 Design and implement (with data that is important to the management) 3 reports for management, 1 detailed, 1 exception, and 1 summary (one by each student).
Each report design description & layout:
Title- (Pick a Pet)
Purpose What need does it fulfill
Data Fields list from the database
Calculated fields
Grouping/Sorted (for detailed report) or Exception subset (for Exception report)
Screen-Paper Layout design
Show the sql query that was needed to fetch the data for each report. (not needed for summary report)
Detailed Report
Be sure the detailed one has grouping, and subtotals per each group.
Exception Report
Be sure the exception is not just a smaller version of the detailed report, nor the same as your exception list query.
7.1.2 Design 2 queries for any employee, 1 single query and 1 exception list query
7.1.3 Design 1 output transaction document (e.g. receipt).
7.2 Input Design Prototypes

Design a database in MS-Access(Time line Plan)

PART I Design a database in MS-Access(Time line Plan) Ex) schedule, HR Time line
1. Describe your business environment and why you need a database.
2. Draw your business E-R Model.
3. Create a MS-Access database that reflects to your business needs with:
a. Entities Relationship [Database Tools > Relationships]
b. At least 4 tables
c. At least 3 queries
d. At least 3 forms
e. At least 3 reports
f. Main Screen Menu that loaded on the start-up
Open Form button
Open Report button
Open Searchable Form/Report button Quit button
4. Compact your MS-Access database
a. [Database Tools > Compact and Repair Database]

PART II- Time line Plan Description (PPT or Word)
a. Brief introduction about your business environment and why you need a database for your business
b. Show the content of your database as well as the interaction forms/reports
c. What is the most difficult for this project? 2. Timeline plan
a. Start / End of the

SQL – Creating Views

In this series, we will build and enhance the a hotel booking database.

Series 1 Objectives - Create Views

Create the bookingdb environment by downloading the bookingdb.zip file attached in this Assignment.

Review the base tables that is created.  Code SQL to create a VIEW for each base table.  The viewname should begin with 'v'+basetablename.  The CREATE VIEW statement should code all the existing columns in the SQL portion of the statement.

Review the lesson that created the guestmessage table and create a guestmessage base table in this bookingdb.  Create a VIEW for the guestmessage table.

In this series, we will learn to create views of the base tables, create stored procedures using the views, and create triggers for insert, update and delete events on the booking table.

Upon completion of the above, export the whole database and zip it.  Rename it to bookingdbSeries1.zip and upload

BigQuery Public Data

Student Learning Objectives
After successful completion of this assignment the student will be able to:

Use BigQuery to query public datasets.
Write queries using aggregate functions, grouping, ordering, and subqueries.
Important Notes about Grading
A reminder, any syntax error, including missing semi-colon at the end of even one SQL statement, will result in a grade of 0 for the entire assignment.

Further each question will be graded in a binary fashion.  That is, if it is correct you will get full marks for that question.  If there is any problem with your code (except a syntax error) you will receive a grade of 0 for that question.

Requirements
First there must be no syntax errors in any of the code submitted, that includes missing a semi-colon at the end of any SQL statement.  Any syntax error (even one) will result in a grade of 0 for the entire assignment.
In a file named baby_names.sql, you will put all your SQL code for this

SQL Workbench Work

In this assignment, we will create a view in finhistdb to pick S&P 100 tickers.

S&P100 is an index of ticker symbols that comprise the index.  Create a View named currentSP100Price and include all the Tickers and current prices of the stocks.  The base table to use is pricehist table.

Since there are 100 tickers, not all the tickers might be available in the pricehist table. 

In this assignment, please upload two items:

1.  SQL to create the view currentSP100Price.  Upload your SQL to Blackboard.

2.  Code SQL to select accounts with stock positions that are in the currentSP100Price view results.  In the SQL, show the account name, ticker, no. of shares, price per share and market value.  Upload your SQL to Blackboard.

ER and Queries

- Final product must be sent back as a Word document.

- Queries should be written in MySQL code.

- The diagram can be designed in any software desired, it has to be a ER diagram like this one: https://www.researchgate.net/publication/307110857/figure/fig3/AS:403359166156803@1473179727851/Entity-relationship-ER-diagram-of-Busan-traffic-data.png