Anda di halaman 1dari 14

Surname 1

Surname:

Instructor:

Course:

Date:

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.

1.

SELECT * FROM `order history` WHERE 1;


Surname 4

2.
SELECT * FROM `books`;

3.
SELECT * FROM `bookstore`;
Surname 5

4.
SELECT `ordernum`, `customername`, `customeremail`, `phonnumber`, `customerID` FROM`c
ustomer`;

5.
SELECT `zipcode`, `order_date`, `employeeName`, `address`, `phonnumber`, `hire_date`, `emp
loyeeID` FROM `employee`;
Surname 6

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

7.
SELECT `productprice`, `productdesc`, `productID`, `productname` FROM `product`;
Surname 7

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
results.

List of Proposed queries

a. How many books are sold each month by the publisher?


SELECT PublisherName, COUNT (*)
FROM OrderHistory OH JOIN Books B
ON OH.BookID = B.BookID
GROUP BY PublisherName;

b. Who authors are the biggest sellers of books in our stores?


SELECT BookAuthor FROM Books
WHERE BookID = (SELECT TOP 1 COUNT (*) FROM OrderHistory);

c. What books are associated with each publisher?


SELECT PublisherName, BookTitle FROM Books;

d. Which are the most popular products besides books that are sold in each store?
SELECT ProductID
FROM OrderHistory
WHERE ProductID NOT IN (SELECT BookID FROM Books);

e. From what region s by zipcode do customers visit our store?


SELECT CustZipcode FROM Customer
WHERE CustomerID IN (SELECT CustomerID FROM Order);
Surname 8

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.

In this particular project what is required is to design and create a database for Book ‘R’

Us, which is a small private bookstore. The current system available is using Microsoft Excel

spreadsheets which are not convenient to the store data storage and input due to the fact that the

store has expanded its branches. The store owner has opened a second store known as Great

Books USA hence a more efficient method is required. Access database will be the best solution

to the store owner, which will provide inventory tracking system and customers records serving

both stores and also avail a centralized management system to the store directors. The

mechanism will be of useful during book publisher discount are on offer to certain ordered

books.

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

Microsoft excel has different features compared to database access. For instance data

input in access is more efficient as it offers convenient platform to key in more details in orders,

customers, and inventory update which will help the management keep track on them. And the

storage issue will be addressed also as access provide a wider range of data storage compared to

Microsoft excel. Access will proved the store managers with store details on every activity at a

one glance unlike excel you will have to go through every data input
Surname 9

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 designed Microsoft access will combine all the related store record that the

management need into one master system providing with an ease management strategy for the

stores. The data entry will have relationships that will accumulate to one functional system that

provides accurate and definite results hence the store will grow. Furthermore the SQL tables

will aid in cross checking the tables for which can be useful in marketing efforts.

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

The database will have seven related tables which includes;

Books- this table will consist of ISBN as the primary key while the attributes are

<product_id>, < Author>, <Publisher>, and <price>

Inventory- Item category code is the primary key, and the attributes include <store_id>,

<quantity>

Book store- store_id is the primary key and the attribute is <address>

Order details- order_id is the primary key attributes are <store_id>, <customer_id>,

<employee_id>, and <product_id>

Order master- customer_id is the primary key while the attributes include <address>,

<phone>, <email> and < zip>

Employee- the primary key is employee_id, and the attributes are, <fname>, <lname>,

<phone>, <address>, <email>, <zip>, <date_of_hiring>

Merchandise- product_id as the primary key, while <product_desc>, and <price> as the

attributes in this table.


Surname 10

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


appropriate set of attributes for each entity.

ERD
Surname 11

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

Product
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

Customer
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

Order
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

Supplier
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

CUSTOMER table:

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

Table C_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

Table: 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

Table: 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

Anda mungkin juga menyukai