Anda di halaman 1dari 14

Surname 1





Database Design for Book ‘R’ Us

1. Database

A. Tables: Create at least four tables that will display the data that is important to the store
owners. Identify the primary and foreign keys that are necessary to relate the tables. Include
screenshots that show the tables you created.
Surname 2
Surname 3

B. Import Data: Use SQL statements to import the data into the tables you just created. You will
come up with each of your data sets yourself. You should have at least five records for each
table. Include screenshots that show the populated tables annotated with the SQL statements that
you used.

SELECT * FROM `order history` WHERE 1;
Surname 4

SELECT * FROM `books`;

SELECT * FROM `bookstore`;

SELECT `ordernum`, `customername`, `customeremail`, `phonnumber`, `customerID` FROM`c
Surname 5

SELECT `zipcode`, `order_date`, `employeeName`, `address`, `phonnumber`, `hire_date`, `emp
loyeeID` FROM `employee`;

SELECT `orderamt`, `order_date`, `orderdetails`, `pymmethod`, `order_no` FROM `order_`;
Surname 6

SELECT `productprice`, `productdesc`, `productID`, `productname` FROM `product`;

C. Queries: After you have populated the tables, write queries to extract the data to answer the
owner’s questions. Include screenshots that show each query and the corresponding query

Surname 7

1.How many books are sold monthly by the publisher? This is important due to the fact that

quantity discounts are available from the publisher.

SELECT month(Date) AS month,

COUNT publisher FROM Salesdetail

GROUP BY month(Date) ORDER BY month;

2. Which authors are the most popular sellers of books in the stores? This is important because

the publisher often give discounts for certain authors each month.

SELECT author,

FROM books

WHERE productid IN

(SELECT productid

FROM orderdetail

GROUP BY productid

HAVING SUM(quantity) =


FROM orderdetail

GROUP BY productid));

3. What books are associated with which publisher?

Surname 8

4. What are the most commonly sold products other than books that are sold in each

store? In addition to books, the stores sell magazines, café-specific products like coffee and

pastries, and a slection of gift items.

5. From what region (by ZIP code) do customers visit the stores? This will assist with

future marketing endeavors.

Select Count (CustomerZipCode)

From OrderMaster

Group by CustomerZipCode

2. Report

Although some parts of the report will be completed before or during the creation of the
database, the report as a whole will be written after you have created the database.

A. Overview: Provide a concise overview of the problem you are solving and the database that
you created to address the problem.

For this project, we will design and create a database for Book ‘R’ Us, a small privately

owned bookstore. The store currently relies on a Microsoft Excel spreadsheet. This method was

suitable when there was only one store. Now that the owners have acquired a second store,

Great Books USA, a more efficient method would need to be put in place. Creating an Access

database will assist the owners of the stores in tracking inventory and customers for both stores

in a more efficient and centralized manner. This database would allow the owners to track

buying trends, inventory and also keep track of customer’s order history. This would help the

owners when book publishers offer discounts on a certain quantity of books ordered.

B. Justification: Analyze the business information storage problem you are solving. Why is the
database the appropriate solution to the problem?
Surname 9

The alternative to this would be to continue relying on Microsoft Excel which does not

have the features of an Access database. While it is generally simple to make formulas,

reference cells, copy and paste, link worksheets and spreadsheets together, as the work gets

more intricate, spreadsheets turn out to be harder to alter and oversee. While spreadsheets are

perfect for making one-time analysis, they wind up plainly risky as the data develops and

advances after some time. As new rows and columns get included, summary ranges and

formulas may require some adjustments or new ones made, data and formulas aren't reliably

updates, and these oversights prompt terrible outcomes and choices.

C. Benefits: What benefits in data management does the database you created have over a file
system like the one the stores were previously using? What features and functions does a
database have that a file system does not?

The new database will need to combine two independent bookkeeping and inventory

systems into one master system that will provide the owners with accurate data that will help

their business grow. They would like to keep track of data points for both marketing and

financial reasons. Building a SQL table will allow them to cross-reference tables to get the

information that is needed for their marketing efforts. This would also help them in new

marketing ideas or changes in inventory that could arise in the future.

D. Features: Describe each of the major features of the database you created. Why are these
features required?

This database will include seven tables containing multiple attributes. The first table

with be bookstore with the attributes of store address and id number (primary key). This will

help separate store inventory and sales. The next table will be inventory type. Where the stores

sell more than books, it will be necessary to show what is being sold. The attributes will be Item

category code (primary key), store id number (foreign key) and quantity in inventory. The next
Surname 10

table is the book information table. These attributes include ISBN (primary key), a code for new

or used books, author name, publisher, and price. There should also be a table to keep track of

the General Merchandise items that the bookstores sell. This table would reflect the Product ID

number (primary key), product description and price. To keep up with sales and an upcoming

internet sales campaign, we will create a table for customer information. This table will include

customer ID number (primary key), address, phone number, email address and zip code. There

would also be an Order table. This table will identify sales information. The attributes of this

table will include order ID number (primary key), store ID number (foreign key), customer ID

(foreign key) customer zip code, employee ID (foreign key), and invoice ID. The last table

would be for employees’. This table would show employee id (primary key), employee first

name, last name, phone number, address, e-mail address, zip code and date of hire.

F. Entity-Relationship Diagram (ERD): Develop an entity-relationship diagram that has an

appropriate set of attributes for each entity.
Surname 11


G. Relational Model: Develop a relational model that is logical and complies with the
requirements in your ERD.
Surname 12

Column Name Data Type Allow Nulls Index
ProductId Integer No Primary Key(PK)
Publisher Varchar(50) No
Author Varchar(50) No
Title Varchar(50) No
Description Varchar(50) Yes
PublishDate Date No
Category Varchar(50) No

Column Name Data Type Allow Nulls Index
CustomerNo Integer No Primary Key(PK)
CustomerName Varchar(50) No
CustomerAddress Varchar(50) No
CustomerCity Varchar(50) No
CustomerState Char(2) No
CustomerZip Char(5) Yes
CustomerEmail Varchar(50) No

Column Name Data Type Allow Nulls Index
OrderNo Integer No Primary Key(PK)
CustomerNo Integer No Foreign Key(FK)
OrderDate Date No
ItemsOrdered Varchar(50) No
CustomerDetails_CustomerNo Varchar(50) No
Orders_CustomerDetails Varchar(50) no

Column Name Data Type Allow Nulls Index
SupplierNo Integer No Primary Key(PK)
Name Varchar(50) No
SupplierAddress Varchar(50) No
SupplierCity Varchar(50) No
SupplierState Char(2) No
SupplierZip Char(5) Yes
Title Varchar(50) No Foreign Key(FK)
NumberSupplied Integer No
Surname 13

H. Functional Dependencies Diagram: Based on your ERD, develop a functional dependencies

diagram that accurately normalizes the data into third normal form (3NF).

Dependency Diagram

Data normalization into 3NF


The CustomerCity, CustomerState and CustomerZip are dependent on the address thus a table is
based on the address.

CustomerAddress CustomerCity CustomerState CustomerZip

PRODUCT table:

In the table PRODUCT the PublishDate is dependent on the Publisher so we need a table based
on the publisher

PublisherId PublisherName Title PublishDate DateSold

ORDERS table:
Surname 14

In the table ORDERS CustomerDetails_CustomerNo and ItemsOrdered are dependent on

CustomerNo so we need a table based on CUSTOMERORDERDETAILS

CustomerNo ItemsOrdered CustomerDetails_CustomerNo

I. Functional-Relational Schema: Based on your ERD and dependencies diagram, develop a

relational schema that accurately normalizes the data into 3NF

Relational Schema