SlideShare a Scribd company logo
AAZ Books
Table of Contents:
1. Executive Summary
2. Contextual ER Diagram
3. Fully Attributed Diagram
4. Table diagram
5. Overview tables
6. TableDataDictionary
7. User Manual
8. Execution Manual
9. Overview of Views
10.View Code
11.Trigger Code
12. Stored Procedure Code
13.Table Creation Code
14.Execute/ Insert Statements
Executive Summary
In our database we track Customers as they add books to a shopping cart
and purchase them and all the additional data required. In the books table we
track the name, ISBN, quantity, Copyright Date, Cost, Publisher and genre.
Customers are tracked by their CustomerID, Billing Address, Shipping Address,
Credit Card, First Name, Last Name, age, gender, Email, Home phone and work
phone. Whenever a customer would like to purchase a book they add it to their
shopping cart using their email. To actually purchase a book the customer finishes
the transaction and then the data from the purchase is added to purchases. In
addition to the other features of the data base a customer can change their email
address and their hash and salt and many others.
Our assumptions were that a customer can have only one billing address
and one shipping address because this will force them to have an accurate
address that will prevent them from having any reoccurring accidents. We
assumed a book can have more than one author and more than one genre, and
we also assumed that a customer can only have one credit card.
Contextual ER Diagram
CUSTOMER
CUSTOMER_DATASHOPPING_CART
TRANSACTIONS
BOOK_DATA
AUTHOR
GENRE
PUBLISHER
ADMINISTRATOR
BILLING_ADDRESS
SHIPPING_ADDRESS
DISCOUNT
PURCHASES
Fully Attributed ER Diagram
CUSTOMER
ADMINISTRATOR
SHOPPING_CART
CUSTOMER_DATA
TRANSACTIONS
BILLING_ADDRESS
SHIPPING_ADDRESS
BOOK_DATA
DISCOUNT
PUBLISHER
GENRE
AUTHOR
PURCHASES
CustomerIDPK
Salt
Hash
AdminIDPK
Salt
Hash
ShoppingCartIDPK
TransactionIDFK
CustomerDataIDFK
CustomerDataIDPK
CustomerIDFK
BillingAddressIDFK
TransactionIDPK
ShoppingCartIDFK
BookDataIDFK
BillingAddressIDPK
Street
ShippingAddressIDPK
Street
BookDataIDPK
AuthorIDFK
PurchaseIDFK
DiscountIDPK
DiscountPercent
PublisherIDPK
PublisherName
GenreIDPK
GenreName
AuthorIDPK
AuthorName
PurchaseIDPK
DatePurchased
ShippingAddressIDFK
City
Zip
Street2
State
FirstName
Age
Gender
EMail
Street2
State
Zip
City
PublisherIDFK
GenreIDFK
SellingPrice
ISBN
Quantity
Cost
LastName
Total
CopyrightDate
CreditCardNumber
HomePhone
WorkPhone
Phone
ContactName
Address
Table Diagram
CUSTOMER
ADMINISTRATOR
SHOPPING_CART
CUSTOMER_DATA
TRANSACTIONS
BILLING_ADDRESS
SHIPPING_ADDRESS
BOOK_DATA
DISCOUNT
PUBLISHER_CONTACTS
GENRE
AUTHOR
PURCHASES
PUBLISHER
GENRE_INTERSECTION
AUTHOR_INTERSECTION
CREDIT_CARD
CustomerIDPK
Salt
Hash
AdminIDPK
Salt
Hash
ShoppingCartIDPK
CustomerDataIDFK
CustomerDataIDPK
CustomerIDFK
BillingAddressIDFK
TransactionIDPK
ShoppingCartIDFK
BookDataIDFK
BillingAddressIDPK
Street
ShippingAddressIDPK
Street
BookDataIDPK
DiscountIDPK
DiscountPercent
PublisherIDFKPublisherName
GenreIDPK
GenreName
AuthorIDPK
AuthorName
PurchaseIDPK
PurchaseDateTime
ShippingAddressIDFK
City
Zip
Street2
Region
FirstName
Age
Gender
EMail
Street2
Zip
City
PublisherIDFK
SellingPrice
ISBN
Quantity
Cost
LastName
Total
CopyrightDate
HomePhone
WorkPhone
Phone
ContactNameStreet
PublisherIDPK
GenreIDFKPK
BookDataIDFKPK
AuthorIDFKPK
BookDataIDFKPK
Name
CreditCardIDPK
CreditCardNumber
Name
ExpirationDate
SecurityCode
CreditCardIDFK
City
Region
Zip
ContactIDPK
Name
CreditCardType
TransactionDateTime
Username
AdminAccess
Country
Region
Country
Country
BookDataIDFK
Overview of Tables
ADMINISTRATOR – A table that holds administrator information such as username and login
information. The password is stored as a hash and salt from the algorithm in the
code behind. Also tells what admins can add others and which ones cannot.
DISCOUNT – A table will have values that we can pull from in a stored procedure using a
DiscountID to put a discount on the total of a finished shopping cart.
CUSTOMER – A table that holds customer information such as username and login information.
The password is stored as a hash and salt from the algorithm in the code behind.
AUTHOR – A table that holds a surrogate key for an author and their name.
AUTHOR_INTERSECTION – Since a book can have many authors and an author can have many
books, for normalization purposes, we need an intersection table. This table links
authors and books together.
BILLING_ADDRESS - A table that will hold customer's billing address information. A customer
must have a billing address and can have multiple.
CUSTOMER_DATA - A table that will hold information about the customer.
SHIPPING_ADDRESS - A table that will hold the customer's shipping address. A customer must
have a shipping address and can have multiple.
BOOK_DATA - This table will hold all of our information about our books.
PURCHASES - This table will
PUBLISHER - This table will hold all information about the publishers. It holds the name and
address of the publishers.
PUBLISHER_CONTACTS - This table will hold the phone numbers and the names of the
publishers
CREDIT_CARD - This table will hold all credit card information for a user. The expiration date
must be greater than the current date.
SHOPPING_CART - This table will hold the items that the user will buy.
TRANSACTIONS - This is an intersection table for the SHOPPING_CART and BOOK_DATA tables.
GENRE_INTERSECTION – This is an intersection table to join BOOK_DATA and GENRE
GENRE – This is a table to store the different genre names
Table Data Dictionary
ADMINISTRATOR
Attribute Data Type Description
AdministratorID Integer (PK) Unique key for Administrator
Username Varchar(20) Login username for Administrator
Hash Varchar(45) Auto-Generated Value from password
Salt VarChar(45) Auto-Generated Value added to Hash
AdminAccess Bit 0 = Cannot add new admins 1 = Can add new admins
CUSTOMER
Attribute Data Type Description
CustomerID Integer (PK) Unique key for Customer
Hash Varchar(45) Auto-Generated Value from password
Salt VarChar(45) Auto-Generated Value added to Hash
BILLING_ADDRESS
Attribute Data Type Description
BillingAddressID Integer(PK) Unique key for Billing Address
Street Varchar(25) Customer Billing Address
Street2 Varchar(25) If customer has a PO Box
City Varchar(25) Customers city that they wish to be billed at.
Zip Varchar(6) Customers zip that they wish to be billed at
Region Varchar(25) Customers region that they wish to be billed at
Country Varchar(25) Customers country that they wish to be billed at
Discount
Attribute Data Type Description
DiscountID Integer(PK) Unique key for Discount
Name Varchar(25) Name of discount
DiscountPercent Numeric(2,2) The percentage that is be to discounted
AUTHOR_INTERSECTION
Attribute Data Type Description
AuthoerID Integer(PK) Unique key for Author Intersection
BookDataID Integer(PK) Unique key for Author Intersection
AUTHOR
Attribute Data Type Description
AuthorID Integer(PK) Unique key for Author
AuthorName Varchar(20) The name of the author
Customer_DATA
Attribute Data Type Description
CustomerDataID Integer(PK) Unique key for Customer Data
CustomerID Integer(FK) Foreign key from Customer
BillingAddressID Integer(FK) Foreign key from Billing Address
ShippingAddressID Integer(FK) Foreign key from Shipping Address
CreditCardID Integer(FK) Foreign key from Credit Card
FirstName Varchar(25) Customers First Name
LastName Varchar(25) Customers Last Name
Age Integer Customers age
Gender Char(1) Customers gender
Email Varchar(40) Customers Email
HomePhone Varchar(25) Customers Homephone
WorkPhone Varchar(25) Customers Workphone
CREDIT_CARD
Attribute Data Type Description
CreditCardID Integer(PK) Unique key for CREDIT_CARD
Name Varchar(25) Name of the credit card holder
ExpirationDate DateTime2 The month and year when the credit card expires
CreditCardNumber Numeric(16) 16-digit number on the credit card
CreditCardType Varchar(25) The type of credit card
SecurityCode Integer 3-digit code on the back of the credit card
SHOPPING_CART
Attribute Data Type Description
ShoppingCartID Integer(PK) Unique key for SHOPPING_CART
TransactionID Integer(FK) Unique key for TRANSACTIONS
CustomerDataID Integer(FK) Unique key for CUSTOMER_DATA
TransactionDateTime DateTime2 Time that the transaction took place
Total Money Total dollar amount of the transaction
TRANSACTIONS
Attribute Data Type Description
TransactionID Integer(PK) Unique key for TRANSACTIONS
ShoppingCartID Integer(FK) Unique key for SHOPPING_CART
BookDataID Integer(FK) Unique key for BOOK_DATA
GENRE_INTERSECTION
Attribute Data Type Description
GenreID Integer(PK) Unique key for GENRE
BookDataID Integer(PK) Unique key for BOOK_DATA
GENRE
Attribute Data Type Description
GenreID Integer(PK) Unique key for GENRE
GenreName VarChar(25) Name of the type of genre
Publisher
Attribute Data Type Description
PublisherID Integre(PK) Unique key for Publisher
PublisherName Varchar(30) The publishers name that they go by
Street Varchar(30) The publisher's street that they work at
City Varchar(30) The publisher's city that they work in
Region Varchar(25) The publisher's regioin that they work in
Country Varchar(25) The publisher's country that they work in
Zip Varchar(6) The publisher's zip that they work in
BOOK_DATA
Attribute Data Type Description
BookDataID Integer (PK) Unique key for Book Data
PurchaseID Integer(FK) Foreign key for Purchases
PublisherID Integer(FK) Foreign key for Publisher
Name Varchar(45) The name of the Book
ISBN Varchar(13) The ISBN for the book
Quantity Integer How many books are on stock
CopyrightDate Date The year that the book was written
Cost Numeric(5,2) The cost of the book
PURCHASES
Attribute Data Type Description
PurchaseID Integer(PK) Unique key for Purchases
PurchaseDateTime DateTime2 The time that the item was purchased
SellingPrice Money The selling price of the item or items
SHIPPING_ADDRESS
Attribute Data Type Description
ShippingAddressID Integer(PK) Unique key for Shipping Address
Street Varchar(25) Customer's address where they receive mail
Street2 Varchar(20) Customer's PO box
City Varchar(25) Customer's city that the shipping address is in
Zip Varchar(5) Customer's zip that the shipping address is in
Region Varchar(25) Customer's region that the shipping address is in
Country Varchar(25) Customer's country that the shipping address is in
PUBLISHER_CONTACTS
Attribute Data Type Description
ConatctID Integer Unique key for Publisher_Contacts
PublisherID Integer Foreign key for Publisher
ContactName VARCHAR(20) The name of the person from the publishing company
Phone Numeric(11) The phone number to contact the publisher
User Manual
Overview of Stored Procedures
uspAddCustomer
Accepts: Hash, Salt, StreetBa, Street2Ba, CityBa, ZipBa, RegionBa, CountryBa, Name,
ExpirationDate, CreditCardNumber, CreditCardType, SecurityCode, StreetSa, Street2Sa, CitySa,
ZipSa, RegionSa, CountrySa, FirstName, LastName, Age, Gender, Email, Homephone, WorkPhone
Description: This procedure adds a new customer with their shipping address, billing address,
and credit card
uspAddAministrator
Accepts: CurrentAdministrator, CurrentSalt, Username, Hash, Salt, AdminAccess
Description: This procedure allows a current administrator to add a new administrator. First, it
checks if the current administrator has permission to add a new administrator, then it checks if
the current administrator user name is exists. If the administrator does have permission and the
administrator's user name exists, then it add the new administrator's user name, hash, salt, and
admin access. Otherwise it will print an error message.
uspAddAuthor
Accepts: AuthorName, CurrentAdministrator, CurrentSalt
Description This procedure allows an administrator to add a new author,
uspAddAuthorToBook
Accepts: AuthorName, ISBN, CurrentAdministrator, CurrentSalt
Description This procedure allow an administrator to link an author to a book.
uspAddBookData
Accepts: CurrentAdministrator, CurrentSalt, Name, ISBN, Quantity, CopyrightDate, Cost,
PublisherName
Description: This procedure allows a current administrator to insert a new book into the
book_data table given the administrator’s name, and salt, and the book’s title, ISBN number,
quantity, copyright date, cost, and the publisher’s name.
uspAddBookToShoppingCart
Accepts: ISBN, Email
Description: This procedure allows link a shopping cart to a book.
uspAddGenre
Accepts: GenreName
Description: This procedure allows a user to insert a type of genre
uspAddGenreToBook
Accepts: GenreName, ISBN, CurrentAdministrator, CurrentSalt
Description: This procedure allows a user to link a book to a type of genre.
uspAddPublisher
Accepts: PubName, PubStreet, PubCity, PubRegion, PubCountry, PubZip
Description: This procedure allows a user to create a new publisher contact with all of their
contact information.
uspAddPublisherContact
Accepts: CurrentAdministrator, CurrentSalt, PublisherName, ContactName, Phone
Description: This procedure allows an administrator to create another publisher contact from
the same publishing company.
uspFinishTransaction
Accepts: Email
Description: This procedure allows a user to checkout and saves what they selected to purchase.
This also checks if the customer is eligible for a discount.
uspGetAuthorID
Accepts: Author
Description: This procedure returns an authorID given the author’s name.
uspGetBookID
Accepts: ISBN
Description: This procedure returns the bookDataID given an ISBN.
uspGetCustomerDataID
Accepts: Email
Description Accepts the customer’s Email and returns the CustomerID for that customer.
uspGetCustomerID
Accepts: Email, CurrentSalt
Description Same as uspGetCustomerDataID, but it requires the customer’s salt.
uspGetGenreID
Accepts: GenreName
Description: This procedure returns the genreID given a genre name.
uspGetPublisherID
Accepts: PublisherName
Description: This procedure returns the publisherID given the publisher’s name.
uspGetShoppingCartID
Accepts: Email
Description: This procedure returns the shoppingCartID given the customer’s email address.
uspRemoveBookFromShoppingCart
Accepts: Email, ISBN
Description: This procedure.
uspShowPopularBooksByUnitSold
Accepts:
Description: This procedure displays the most popular books by the number of them that has
been sold.
uspShowPopularBooksByVolume
Accepts:
Description: This procedure displays the most popular books by the total dollar amount of them
that has been sold.
uspTotalRevenueTimeFrame
Accepts: BeginDate, EndDate
Description: This procedure allows a user to view the revenue of a specific time frame given a
beginning and end date.
uspUpdateAdminAccess
Accepts: CurrentAdministrator, CurrentSalt, UserStatusChange, ChangeAccess
Description: This procedure allows a current administrator to update and change an
administrator’s access level.
uspUpdateAdminHashSalt
Accepts: CurrentAdministrator, CurrentSalt, NewSalt, NewHash
Description: This procedure allows a current administrator to update his or her salt and hash
given their current administrator name and their current salt.
uspUpdateBillingAddress
Accepts: CurrentAdministrator, CurrentSalt, Email, Street1, Street2, City, Zip, Region/State,
Country
Description: This procedure allows an administrator to update the customer’s billing address
given the administrator’s username and salt, and the customer’s email address.
uspUpdateBookInformation
Accepts: CurrentAdministrator, currentSalt, ISBN, Name, NewISBN, Quantity, CopyrightDate,
Cost
Description: This procedure allows an administrator to update a book’s general information
given the administrator’s username and salt, and the book’s ISBN.
uspUpdateCustomerEmail
Accepts: CurrentAdministrator, AdminSalt, CurrentSalt, Email, NewEmail
Description: This procedure allows a current administrator to update and change a customer’s
email address given the current administrator’s name, the administrator’s salt, the customer’s
salt, and the customer’s new email address and old email address.
uspUpdateCustomerHashSalt
Accepts: CurrentAdministrator, CurrentSalt, Email, NewCustomerSalt, NewCustomerHash
Description: This procedure allows a current administrator to update and change a customer’s
hash and salt given the current administrator’s name, salt, the customer’s email, and the
customer’s new salt and hash.
uspUpdateCustomerInformation
Accepts: CurrentAdministrator, CurrentSalt, Email, FirstName, LastName, Age, Gender,
NewEmail, HomePhone, and WorkPhone
Description: This procedure allows an administrator to update the customer’s general I
nformation give the current administrator’s name and salt, and the customer’s current email.
uspUpdateShippingAddress
Accepts: CurrentAdministrator, CurrentSalt, Email, Street1, Street2, City, Zip, Region/State,
Country
Description: This procedure allows an administrator to update a customer’s shipping address
given the administrator’s username and salt, and the customer’s email address.
uspVerifyAdministrator
Accepts: CurrentAdministrator, CurrentSalt
Description: This procedure checks that the current administrator exists in the administrator
table. If the administrator exists in the table then it returns 1, otherwise it will print
'Administrator username or salt is incorrect' and return 0.
UspVerifyPublisher
Accepts: PublisherName
Description: This procedure allows a user to verify that a given publisher name exists with the
publisher table.
Execution Manual
Because database’s require certain information before it can have other information
there is a certain way the stored procedures have to be executed. We take an outside inside
approach when we execute them meaning that data that has no prerequisites gets executed
first.
First we will execute uspAddAministrator, that way we have an administrator to be able
to create other things. Next we can execute, uspAddAuthor, uspAddBookData, uspAdd
Customer, uspAddGenre, and uspAddPublisher. Next we can execute uspAddAuthorToBook,
uspAddGenreToBook, and uspAddPublisherContact. After that we are able to execute
uspAddBookToShoppingCart. Finally we are able to execute FinishTransaction.
Once those are all executed any stored procedure is able to be executed at any time.
Overview of Views
TotalInventoryByGenre
Description: Allows the user to view the total amount of books in each genre.
AvgTrans
Description: Allows the user to view the average transaction price from all of the transactions.
ValueInventoryByPublisher
Description: Allows the user to see the value of the total inventory of each publisher.
PublisherRevenuePerDay
Description: Allows the user to see the revenue made by the different publishers on a particular
day.
View Code
TotalInventoryByGenre
CREATE VIEW TotalInventoryByGenre AS
--sum and group by
SELECT g.GenreName, SUM (bd.Quantity) AS 'Total Inventory'
FROM BOOK_DATA bd
JOIN GENRE_INTERSECTION gi
ON bd.BookDataID = gi.BookDataID
JOIN GENRE g ON gi.GenreID = g.GenreID
WHERE bd.BookDataID = gi.BookDataID
AND gi.GenreID = g.GenreID
GROUP BY GenreName
AvgTrans
CREATE VIEW AvgTrans as
SELECT CONCAT ('$',AVG(SellingPrice)) AS 'Average Transaction Amount'
FROM PURCHASES
ValueInventoryByPublisher
CREATE VIEW ValueInventoryByPublisher AS
SELECT CONCAT('$', SUM(COST * Quantity)) AS 'Value of Inventory', PublisherName AS
'Publisher Name'
FROM BOOK_DATA bd
JOIN Publisher p on p.PublisherID = bd.PublisherID
GROUP BY PublisherName
PublisherRevenuePerDay
CREATE VIEW PublisherRevenuePerDay AS
SELECT PublisherName as 'Publisher', sum(SellingPrice) as 'Revenue',
CONVERT(date,PurchaseDateTime,10) as 'Date'
FROM PUBLISHER
JOIN BOOK_DATA AS BK ON PUBLISHER.PublisherID = BK.PublisherID
JOIN PURCHASES AS PK ON BK.BookDataID = PK.BookDataID
GROUP BY PublisherName, CONVERT(date,PurchaseDateTime,10);
Trigger
ustPrintAdmistratorCreated
Occurs: After Insert
Description: Prints out that an administrator was created after an administrator has been
inserted.’
Code
CREATE TRIGGER ustPrintAdministratorCreated ON dbo.ADMINISTRATOR
AFTER INSERT
AS
BEGIN
PRINT '******************************'
PRINT 'Administrator has been created'
PRINT '******************************'
END;
Stored Procedure Code
/* Adds a Administrator to database*/
CREATE PROCEDURE uspAddAdministrator
(
@CurrentAdministrator VARCHAR(20),
@CurrentSalt VARCHAR(45),
@Username VARCHAR(20),
@Hash VARCHAR(45),
@Salt VARCHAR(45),
@AdminAccess BIT
)
AS
BEGIN
DECLARE @RowCount INT
DECLARE @AdminRowCount INT
/*Check if current administrator can add a admin*/
SELECT @AdminRowCount = COUNT(*)
FROM ADMINISTRATOR
WHERE Username = @CurrentAdministrator
AND Salt = @CurrentSalt
AND AdminAccess = 1
/*Check if username already exist*/
SELECT @RowCount = COUNT(*)
FROM dbo.ADMINISTRATOR
WHERE Username = @Username
IF @AdminRowCount = 1
IF @RowCount = 0
INSERT INTO ADMINISTRATOR(Username, [Hash], Salt, AdminAccess)
VALUES (@Username, @Hash, @Salt, @AdminAccess)
ELSE
PRINT 'UserName Already Exists'
ELSE
PRINT 'Current Administrator Invalid'
END
CREATE PROCEDURE uspAddAuthor (
@AuthorName VARCHAR(20),
@CurrentAdministrator VARCHAR(20),
@CurrentSalt VARCHAR(45)
)
AS
BEGIN
DECLARE @RowCount INT
DECLARE @Admin BIT
/*Verify the admin*/
EXEC @Admin = uspVerifyAdministrator @CurrentAdministrator, @CurrentSalt
IF @Admin <> 1
PRINT 'Author not inserted'
ELSE
BEGIN
/*See if the author name exists already*/
SELECT @RowCount = COUNT(*)
FROM Author
WHERE AuthorName = @AuthorName
IF @RowCount = 0
INSERT INTO AUTHOR (AuthorName) VALUES (@AuthorName)
ELSE
PRINT 'AuthorName Already Exists'
END
END
CREATE PROCEDURE uspAddAuthorToBook (
@AuthorName VARCHAR(20),
@ISBN VARCHAR(13),
@CurrentAdministrator VARCHAR(20),
@CurrentSalt VARCHAR(45)
)
AS
BEGIN
DECLARE @RowCount INT
DECLARE @Admin BIT
DECLARE @GAuthorID INT
DECLARE @GBookID INT
/*Verify the admin*/
EXEC @Admin = uspVerifyAdministrator @CurrentAdministrator, @CurrentSalt
IF @Admin <> 1
PRINT 'Author not connected with book'
ELSE
BEGIN
/*See if the author is already connected*/
EXEC @GAuthorID = uspGetAuthorID @AuthorName
EXEC @GBookID = uspGetBookID @ISBN
SELECT @RowCount = COUNT(*)
FROM AUTHOR_INTERSECTION
WHERE AuthorID = @GAuthorID
AND BookDataID = @GBookID
IF @RowCount = 0
INSERT INTO AUTHOR_INTERSECTION (AuthorID, BookDataID) VALUES
(@GAuthorID, @GBookID)
ELSE
PRINT 'Connection already exists'
END
END
CREATE PROCEDURE uspAddBookData
@CurrentAdministrator VARCHAR(20),
@CurrentSalt VARCHAR(45),
@Name VARCHAR(45),
@ISBN VARCHAR(13),
@Quantity INT,
@CopyrightDate DATE,
@Cost NUMERIC(5,2),
@PublisherName VARCHAR(30)
AS
BEGIN
DECLARE @Admin BIT
DECLARE @PublisherID INT
DECLARE @Publisher BIT
/*Verify the Admin*/
EXEC @Admin = uspVerifyAdministrator @CurrentAdministrator, @CurrentSalt
IF @Admin <> 1
PRINT 'User does not have permission to edit'
ELSE
BEGIN
EXEC @Publisher = uspVerifyPublisher @PublisherName
IF @Publisher <> 1
PRINT 'Publisher Name is not valid'
ELSE
BEGIN
EXEC @PublisherID = uspGetPublisherID @PublisherName
INSERT INTO BOOK_DATA
(
Name,
ISBN,
Quantity,
CopyrightDate,
Cost,
PublisherID
)
VALUES
(
@Name,
@ISBN,
@Quantity,
@CopyrightDate,
@Cost,
@PublisherID
)
END
END
END;
CREATE PROCEDURE uspAddBookToShoppingCart
(
@ISBN VARCHAR(13),
@Email VARCHAR(40)
)
AS
BEGIN
Declare @previousTotal MONEY
Declare @rowCount INT
Declare @rowCountEmail INT
Declare @ShoppingCartID INT
Declare @BookDataID INT
Declare @NewTotal MONEY
Declare @Cost NUMERIC(5,2)
Declare @FinalTotal MONEY
Declare @CustomerDataID INT
SELECT @rowCountEmail = COUNT (*)
FROM CUSTOMER_DATA
WHERE Email = @Email
IF @rowCountEmail IS NULL
PRINT 'The email does not exist'
ELSE
BEGIN
SELECT @CustomerDataID = CustomerDataID
FROM CUSTOMER_DATA
WHERE Email = @Email
/*See if customer has a shopping cart w/o date*/
/*select ShoppingCart where customerID = @CustomerID*/
SELECT @rowCount = COUNT(*)
FROM SHOPPING_CART AS SC
WHERE SC.CustomerDataID = @CustomerDataID
AND SC.TransactionDateTime IS NULL;
/*if tdt == null add one to hasShoppingCartDate*/
IF @rowCount = 1 BEGIN
/*if so*/
/*Insert into transaction table ShoppingCartID and BookDateID*/
SELECT @ShoppingCartID = ShoppingCartID
FROM SHOPPING_CART AS SC1
WHERE SC1.CustomerDataID = @CustomerDataID
AND SC1.TransactionDateTime IS NULL;
--get the book data ID
SELECT @BookDataID = BookDataID
FROM BOOK_DATA
WHERE ISBN = @ISBN
INSERT INTO TRANSACTIONS(ShoppingCartID,BookDataID)
VALUES(@ShoppingCartID, @BookDataID)
/*Update total*/
/*Grab book cost and and to total*/
SELECT @previousTotal= Total
FROM SHOPPING_CART
WHERE ShoppingCartID = @ShoppingCartID
--get cost of the book
SELECT @COST = COST
FROM BOOK_DATA
WHERE BookDataID = @BookDataID
Select @FinalTotal = @previousTotal + @Cost
/*Update the quantity of the bookdata*/
UPDATE SHOPPING_CART
SET Total = @FinalTotal
WHERE ShoppingCartID = @ShoppingCartID
AND TransactionDateTime IS NULL;
END
/*if tdt != null add zero to hasShoppingCartDate*/
ELSE
BEGIN
/*if not*/
/*use @@IDENTITY TO GET id FROM SHOPPING CART*/
INSERT INTO SHOPPING_CART (CustomerDataID)
VALUES (@CustomerDataID)
SELECT @ShoppingCartID = @@IDENTITY
--get the book data ID
SELECT @BookDataID = BookDataID
FROM BOOK_DATA
WHERE ISBN = @ISBN
INSERT INTO TRANSACTIONS(ShoppingCartID,BookDataID)
VALUES(@ShoppingCartID, @BookDataID)
--get cost of the book
SELECT @COST = COST
FROM BOOK_DATA
WHERE BookDataID = @BookDataID
UPDATE SHOPPING_CART
SET Total = @Cost
WHERE ShoppingCartID = @ShoppingCartID
END
END
END
CREATE PROCEDURE uspAddGenre (
@GenreName VARCHAR(25)
)
AS
BEGIN
DECLARE @RowCount INT
SELECT @RowCount = COUNT(*)
FROM GENRE
WHERE GenreName = @GenreName
IF @RowCount = 0
INSERT INTO GENRE (GenreName) VALUES (@GenreName)
ELSE
PRINT 'GenreName Already Exists'
END
CREATE PROCEDURE uspAddGenreToBook
(
@GenreName VARCHAR(30),
@ISBN VARCHAR(13),
@CurrentAdministrator VARCHAR(20),
@CurrentSalt VARCHAR(45)
)
AS
BEGIN
DECLARE @RowCount INT
DECLARE @Admin BIT
DECLARE @GgenreID INT
DECLARE @GBookID INT
/*Verify the Admin*/
Exec @Admin = uspVerifyAdminister (@CurrentAdministrator, @CurrentSalt)
IF @ADMIN <> 1
PRINT 'Genre not connected with book'
ELSE
BEGIN
/*See if the Genre is already connected*/
EXEC @GgenreID = uspGetGenreID @GgenreName
EXEC @GBookID = uspGetBookID @ISBN
SELECT @RowCount = Count(*)
FROM GENRE_INTERSECTION
WHERE GenreID = @GenreID
AND BookDataID = @GBookID
IF @RowCount = 0
INSERT INTO GENRE_INTERSECTION (GenreID, BookDataID)
VALUES (@GgenreID, @GBookID)
ELSE
PRINT 'Connection already exists'
END
END;
CREATE PROCEDURE uspAddPublisher
@PubName VARCHAR(30),
@PubStreet VARCHAR(30),
@PubCity VARCHAR(30),
@PubRegion VARCHAR(30),
@PubCountry VARCHAR(30),
@PubZip VARCHAR(6)
AS
BEGIN
DECLARE @RowCount INT
SELECT @RowCount = COUNT(*)
FROM PUBLISHER
WHERE PublisherName = @PubName
IF @RowCount > 0
PRINT 'The publisher already exists in the database'
ELSE
INSERT INTO PUBLISHER
(
PublisherName,
Street,
City,
Region,
Country,
Zip
)
VALUES
(
@PubName,
@PubStreet,
@PubCity,
@PubRegion,
@PubCountry,
@PubZip
)
END;
CREATE PROCEDURE uspAddPublisherContact
@CurrentAdministrator VARCHAR(20),
@CurrentSalt VARCHAR(45),
@PublisherName VARCHAR(30),
@ContactName VARCHAR(20),
@Phone NUMERIC(11)
AS
BEGIN
DECLARE @PublisherID INT
DECLARE @Admin BIT
DECLARE @Publisher BIT
/*Verify the Admin*/
EXEC @Admin = uspVerifyAdministrator @CurrentAdministrator, @CurrentSalt
IF @Admin <> 1
PRINT 'User does not have permission to edit'
ELSE
BEGIN
/*Verify the publisher name*/
EXEC @Publisher = uspVerifyPublisher @PublisherName
IF @Publisher <> 1
PRINT 'Publisher name is not valid'
ElSE
BEGIN
/*Get the publisherID*/
EXEC @PublisherID = uspGetPublisherID @PublisherName
INSERT INTO PUBLISHER_CONTACTS
(
PublisherID,
ContactName,
Phone
)
VALUES
(
@PublisherID,
@ContactName,
@Phone
)
END
END
END;
CREATE PROCEDURE uspFinishTransaction
/*get stuff*/
@Email VARCHAR(40)
AS
BEGIN
/*create table to store shopping cart books*/
-- DECLARE @MyArray table(ShoppingCartID INT, TransactionDateTime DATETIME2, Total
MONEY)
DECLARE @ShoppingCartID INT
DECLARE @TransactionDateTime DATETIME2
DECLARE @Total MONEY
DECLARE @BookDataID INT
DECLARE @Counter INT
DECLARE @DiscountPercent NUMERIC(2,2)
DECLARE @CustomerDataID INT
DECLARE @TransactionID INT
DECLARE @PreviousTransactionID INT
DECLARE @Cost NUMERIC (5,2)
DECLARE @Quantity INT
--get the customer data ID
EXEC @CustomerDataID = uspGetCustomerDataID @Email
--get the shopping Cart ID
SELECT @ShoppingCartID = ShoppingCartID
FROM SHOPPING_CART
WHERE CustomerDataID = @CustomerDataID
AND TransactionDateTime IS NULL
SET @Counter = 0
--count the rows that have the same customerDataID's
-- count the books in the shopping cart
DECLARE @RowCount INT
SELECT @RowCount = COUNT(*)
FROM TRANSACTIONS
WHERE ShoppingCartID = @ShoppingCartID
SET @TransactionDateTime = CURRENT_TIMESTAMP
-- get the last transactionID of that customer where transactionDateTime is not
null
/*
SELECT TOP 1 @PreviousTransactionID = TransactionID
FROM TRANSACTIONS
JOIN SHOPPING_CART
ON SHOPPING_CART.ShoppingCartID = TRANSACTIONS.ShoppingCartID
WHERE TRANSACTIONS.ShoppingCartID = @ShoppingCartID
AND SHOPPING_CART.TransactionDateTime IS NOT NULL
ORDER BY TransactionID ASC
*/
SET @PreviousTransactionID = 0
/*fill table*/
WHILE @Counter < @RowCount
BEGIN
SELECT TOP 1 @TransactionID = TransactionID
FROM TRANSACTIONS
WHERE ShoppingCartID = @ShoppingCartID
AND TransactionID > @PreviousTransactionID
ORDER BY TransactionID ASC
SELECT @BookDataID = BookDataID
FROM TRANSACTIONS
WHERE TransactionID = @TransactionID
-- get the price of the book
SELECT @Cost = Cost
FROM BOOK_DATA
WHERE BookDataID = @BookDataID
-- insert purchaseDateTime, sellingPrince(of book), and BookDataID into
purchases
INSERT INTO PURCHASES (PurchaseDateTime, SellingPrice, BookDataID)
VALUES (@TransactionDateTime, @Cost, @BookDataID)
SET @PreviousTransactionID = @TransactionID
--decrement quantity of book by 1
SELECT @Quantity = Quantity
FROM BOOK_DATA
WHERE BookDataID = @BookDataID
UPDATE BOOK_DATA
SET Quantity = @Quantity - 1
WHERE BookDataID = @BookDataID
-- increment the counter
SET @Counter = @Counter + 1
END
-- get the Total from ShoppingCart
SELECT @Total = Total
FROM SHOPPING_CART
WHERE ShoppingCartID = @ShoppingCartID
/*check if they are eligible for a discount*/
IF @Total > 75
BEGIN
SELECT @DiscountPercent = DiscountPercent
FROM DISCOUNT
WHERE DiscountID = 1
IF @DiscountPercent = NULL
PRINT 'No discount available'
ELSE
SET @Total = @Total * (1 - @DiscountPercent)
END
UPDATE SHOPPING_CART
SET TransactionDateTime = @TransactionDateTime,
Total = @Total
WHERE ShoppingCartID = @ShoppingCartID
END;
CREATE PROCEDURE uspGetAuthorID (
@Author VARCHAR(20)
)
AS
BEGIN
DECLARE @AuthorID INT
SELECT @AuthorID = AuthorID
FROM AUTHOR
WHERE AuthorName = @Author
IF @AuthorID = NULL
BEGIN
PRINT 'Author does not exist'
RETURN 0
END
ELSE
RETURN @AuthorID
END;
CREATE PROCEDURE uspGetBookID (
@ISBN VARCHAR(13)
)
AS
BEGIN
DECLARE @BookID INT
SELECT @BookID = BookDataID
FROM BOOK_DATA
WHERE ISBN = @ISBN
IF @BookID = NULL
PRINT 'ISBN does not exist'
ELSE
RETURN @BookID
END;
CREATE PROCEDURE uspGetCustomerDataID
@Email VARCHAR(200)
AS
BEGIN
DECLARE @CustomerDataID INT
--get the customerDataID
SELECT @CustomerDataID = CustomerDataID
FROM CUSTOMER_DATA
WHERE Email = @Email
-- if the email was not found
IF @CustomerDataID = NULL
PRINT 'Invalid Email'
ELSE
RETURN @CustomerDataID
END;
Create PROCEDURE uspGetCustomerID
@Email VARCHAR(200),
@CurrentSalt VARCHAR(45)
AS
BEGIN
/*Check if email exists*/
DECLARE @CustomerID INT
DECLARE @RowCount INT
SELECT @CustomerID = CustomerID
FROM CUSTOMER_DATA
WHERE Email = @Email
/*if email does not exist*/
IF @CustomerID = NULL
PRINT 'The email does not exist'
ELSE
BEGIN
/*Check that the customer salt matches with the customerID*/
SELECT @RowCount = COUNT(*)
FROM CUSTOMER
JOIN CUSTOMER_DATA
ON CUSTOMER.CustomerID = CUSTOMER_DATA.CustomerID
WHERE @CustomerID = CUSTOMER.CustomerID
AND @CurrentSalt = Salt
If @RowCount <> 1
PRINT 'Input invalid customer salt'
ELSE
RETURN @CustomerID
END
END;
CREATE PROCEDURE uspGetGenreID (
@GenreName VARCHAR(30)
)
AS
BEGIN
/*Check if the genre exists*/
DECLARE @GenreID INT
SELECT @GenreID = GenreID
FROM GENRE
WHERE GenreName = @GenreName
/*Return the genreid if the name exists*/
IF @GenreID = NULL
PRINT 'Name does not exist'
ELSE
RETURN @GenreID
END;
CREATE PROCEDURE uspGetPublisherID (
@PublisherName VARCHAR(30)
)
AS
BEGIN
DECLARE @PublisherID INT
SELECT @PublisherID = PublisherID
FROM PUBLISHER
WHERE PublisherName = @PublisherName
IF @PublisherID = NULL
PRINT 'Name does not exist'
ELSE
RETURN @PublisherID
END;
CREATE PROCEDURE uspGetShoppingCartID
@Email VARCHAR(200)
AS
BEGIN
DECLARE @ShoppingCartID INT
DECLARE @CustomerDataID INT
EXEC @CustomerDataID = uspGetCustomerDataID @Email
SELECT @ShoppingCartID = ShoppingCartID
FROM SHOPPING_CART
WHERE CustomerDataID = @CustomerDataID
IF @ShoppingCartID = NULL
PRINT 'A shoppingCartID was not found'
ELSE
RETURN @ShoppingCartID
END;
CREATE PROCEDURE uspRemoveBookFromShoppingCart (
@Email VARCHAR(40),
@ISBN VARCHAR(13)
)
AS
BEGIN
DECLARE @RowCount INT
DECLARE @CustomerID INT
DECLARE @BookDataID INT
DECLARE @ShoppingCartID INT
DECLARE @BookCost NUMERIC(5,2)
DECLARE @OldTotal NUMERIC(5,2)
DECLARE @NewTotal NUMERIC(5,2)
--See if book is in shopping cart
EXEC @CustomerID = uspGetCustomerDataID @Email
SELECT @RowCount = COUNT(*)
FROM SHOPPING_CART sc
JOIN TRANSACTIONS tc ON sc.ShoppingCartID = tc.ShoppingCartID
JOIN BOOK_DATA bd ON tc.BookDataID = bd.BookDataID
WHERE ISBN = @ISBN
AND sc.CustomerDataID = @CustomerID
AND sc.TransactionDateTime IS NULL
--If there is a book or books
IF @RowCount > 1
BEGIN
--Lower the total
EXEC @ShoppingCartID = uspGetShoppingCartID @Email
SELECT @BookCost = Cost
FROM BOOK_DATA
WHERE BookDataID = @BookDataID
SELECT @OldTotal = Total
FROM SHOPPING_CART
WHERE ShoppingCartID = @ShoppingCartID
SELECT @NewTotal = @OldTotal - @BookCost
UPDATE SHOPPING_CART
SET Total = @NewTotal
WHERE ShoppingCartID = @ShoppingCartID
AND TransactionDateTime IS NULL
--Remove from transactions
DELETE FROM TRANSACTIONS
WHERE ShoppingCartID = @ShoppingCartID
AND BookDataID = @BookDataID
END
ELSE
BEGIN
PRINT 'There is no such book in the shopping cart'
END
END
CREATE PROCEDURE uspVerifyPublisher (
@PublisherName VARCHAR(30)
)
AS
BEGIN
DECLARE @PublisherID INT
SELECT @PublisherID = PublisherID
FROM PUBLISHER
WHERE PublisherName = @PublisherName
/*If publisher is null then return 0 for false*/
IF @PublisherID = NULL
Return 0
ELSE
/*If publisher is not null then return 1 for true*/
Return 1
END;
CREATE PROCEDURE uspShowPopularBooksByVolume
AS
BEGIN
SELECT TOP 10 Name, SUM(SellingPrice) AS 'Volume Sold'
FROM PURCHASES AS P JOIN BOOK_DATA AS BD
ON BD.BookDataID = P.BookDataID
GROUP BY Name
ORDER BY SUM(SellingPrice) DESC
END
CREATE PROCEDURE uspShowPopularBooksByUnitSold
AS
BEGIN
SELECT Name, COUNT (PURCHASES.BookDataID) AS UnitsSold
FROM PURCHASES
JOIN BOOK_DATA ON BOOK_DATA.BookDataID = PURCHASES.BookDataID
GROUP BY Name
ORDER BY UnitsSold DESC
END
CREATE PROCEDURE uspTotalRevenueTimeFrame
@BeginDate DATE,
@EndDate DATE
AS
BEGIN
/*get the beginning and end dates
check that beginning is earlier than end date
Add all the totals between those 2 dates
*/
IF @BeginDate > @EndDate
PRINT 'Begin Date must be earlier than End Date'
ELSE
SELECT SUM (SellingPrice) AS 'Total Sales During Period'
FROM PURCHASES
WHERE PurchaseDateTime >= @BeginDate
AND PurchaseDateTime <= @EndDate
END
CREATE PROCEDURE uspUpdateAdminHashSalt
@CurrentAdministrator VARCHAR(20),
@CurrentSalt VARCHAR(45),
@NewSalt VARCHAR(20),
@NewHash VARCHAR(45)
AS
BEGIN
DECLARE @AdminCheck BIT
/*Verify the administrator*/
EXEC @AdminCheck = uspVerifyAdministrator @CurrentAdministrator, @CurrentSalt
IF @AdminCheck <> 1
PRINT 'User does not have permission to edit'
ELSE
BEGIN
/*Update the old hash and salt with the new hash and salt*/
UPDATE ADMINISTRATOR
SET Hash = @NewHash,
Salt = @NewSalt
WHERE Username = @CurrentAdministrator
END
END;
CREATE PROCEDURE uspUpdateBillingAddress
@CurrentAdmin VARCHAR(20),
@CurrentSalt VARCHAR(45),
@Email VARCHAR(40),
@Street1 VARCHAR(25),
@Street2 VARCHAR(25),
@City VARCHAR(25),
@Zip VARCHAR(6),
@Region VARCHAR(25),
@Country VARCHAR(25)
AS
BEGIN
DECLARE @Admin BIT
DECLARE @EmailCount INT
DECLARE @BillingAddressID INT
--check that the current administrator has permission to update
EXEC @Admin = uspVerifyAdministrator @CurrentAdmin, @CurrentSalt
IF @Admin <> 1
PRINT 'User does not have permission to edit'
ELSE
BEGIN
--Verify the email
SELECT @EmailCount = COUNT(*)
FROM CUSTOMER_DATA
WHERE Email = @Email
IF @EmailCount < 1
PRINT 'The email does not exist'
ELSE
BEGIN
--get the BillingAdressID
SELECT @BillingAddressID = BillingAddressID
FROM CUSTOMER_DATA
WHERE Email = @Email
UPDATE BILLING_ADDRESS
SET Street = @Street1,
Street2 = @Street2,
City = @City,
Zip = @Zip,
Region = @Region,
Country = @Country
WHERE BillingAddressID = @BillingAddressID
END
END
END;
CREATE PROCEDURE uspUpdateBookInformation
@CurrentAdmin VARCHAR(20),
@CurrentSalt VARCHAR(40),
@ISBN VARCHAR(13),
@Name VARCHAR(45),
@NewISBN VARCHAR(13),
@Quantity INT,
@CopyrightDate DATE,
@Cost NUMERIC(5,2)
AS
BEGIN
DECLARE @Admin BIT
DECLARE @ISBNCount INT
DECLARE @BookDataID INT
--check that the current administrator has permission to update
EXEC @Admin = uspVerifyAdministrator @CurrentAdmin, @CurrentSalt
IF @Admin <> 1
PRINT 'User does not have permission to edit'
ELSE
BEGIN
--check that the ISBN exists in the table
SELECT @ISBNCount = COUNT(*)
FROM BOOK_DATA
WHERE ISBN = @ISBN
IF @ISBNCount < 1
PRINT 'The ISBN does not exist in the table'
ELSE
BEGIN
--get bookDataID
SELECT @BookDataID = BookDataID
FROM BOOK_DATA
WHERE ISBN = @ISBN
--insert new information
UPDATE BOOK_DATA
SET Name = @Name,
ISBN = @NewISBN,
Quantity = @Quantity,
CopyrightDate = @CopyrightDate,
Cost = @Cost
WHERE BookDataID = @BookDataID
END
END
END;
CREATE PROCEDURE uspUpdateCustomerHashSalt
@CurrentAdministrator VARCHAR(20),
@CurrentSalt VARCHAR(45),
@Email VARCHAR(30),
@NewCustomerSalt VARCHAR(45),
@NewCustomerHash VARCHAR(45)
AS
BEGIN
DECLARE @AdminCheck BIT
DECLARE @CustomerID INT
/*Verify the administrator*/
EXEC @AdminCheck = uspVerifyAdministrator @CurrentAdministrator, @CurrentSalt
IF @AdminCheck <> 1
PRINT 'User does not have permission to edit'
ELSE
BEGIN
EXEC @CustomerID = uspGetCustomerID @CurrentSalt, @Email
/*Update the old customer hash and salt with the new hash and salt*/
UPDATE CUSTOMER
SET Hash = @NewCustomerHash,
Salt = @NewCustomerSalt
WHERE CustomerID = @CustomerID
END
END;
CREATE procedure uspUpdateCustomerEmail
(
@CurrentAdministrator Varchar(20),
@AdminSalt Varchar(45),
@CurrentSalt Varchar(45),
@Email varchar(200),
@NewEmail varchar(30)
)
AS
BEGIN
DECLARE @CurrentAdmin int
/*Check to see if user is admin*/
DECLARE @AdminCheck BIT
DECLARE @CustomerID INT
/*Verify the administrator*/
EXEC @AdminCheck = uspVerifyAdministrator @CurrentAdministrator, @AdminSalt
IF @AdminCheck <> 1
PRINT 'User does not have permission to edit'
ELSE
/*If user is admin*/
BEGIN
EXEC @CustomerID = uspGetCustomerID @Email,@CurrentSalt
/*Update the old customer email*/
UPDATE CUSTOMER_DATA
SET Email = @NewEmail
WHERE CustomerID = @CustomerID
END
END;
CREATE PROCEDURE uspUpdateCustomerInformation
@CurrentAdmin VARCHAR(20),
@CurrentSalt VARCHAR(45),
@Email VARCHAR(40),
@FirstName VARCHAR(25),
@LastName VARCHAR(25),
@Age INT,
@Gender CHAR(1),
@NewEmail VARCHAR(40),
@HomePhone VARCHAR(15),
@WorkPhone VARCHAR(15)
AS
BEGIN
DECLARE @Admin BIT
DECLARE @EmailCount INT
DECLARE @CustomerDataID INT
--check that the current administrator has permission to update
EXEC @Admin = uspVerifyAdministrator @CurrentAdmin, @CurrentSalt
IF @Admin <> 1
PRINT 'User does not have permission to edit'
ELSE
BEGIN
--Verify the email
SELECT @EmailCount = COUNT(*)
FROM CUSTOMER_DATA
WHERE Email = @Email
IF @EmailCount < 1
PRINT 'The email does not exist'
ELSE
BEGIN
--get customerDataID
SELECT @CustomerDataID = CustomerDataID
FROM CUSTOMER_DATA
WHERE Email = @Email
UPDATE CUSTOMER_DATA
SET FirstName = @FirstName,
LastName = @LastName,
Age = @Age,
Gender = @Gender,
Email = @NewEmail,
HomePhone = @HomePhone,
WorkPhone = @WorkPhone
WHERE CustomerDataID = @CustomerDataID
END
END
END;
CREATE PROCEDURE uspUpdateShippingAddress
@CurrentAdmin VARCHAR(20),
@CurrentSalt VARCHAR(45),
@Email VARCHAR(40),
@Street1 VARCHAR(25),
@Street2 VARCHAR(25),
@City VARCHAR(25),
@Zip VARCHAR(6),
@Region VARCHAR(25),
@Country VARCHAR(25)
AS
BEGIN
DECLARE @Admin BIT
DECLARE @EmailCount INT
DECLARE @ShippingAddressID INT
--check that the current administrator has permission to update
EXEC @Admin = uspVerifyAdministrator @CurrentAdmin, @CurrentSalt
IF @Admin <> 1
PRINT 'User does not have permission to edit'
ELSE
BEGIN
--Verify the email
SELECT @EmailCount = COUNT(*)
FROM CUSTOMER_DATA
WHERE Email = @Email
IF @EmailCount < 1
PRINT 'The email does not exist'
ELSE
BEGIN
--get the shippingAddressID
SELECT @ShippingAddressID = ShippingAddressID
FROM CUSTOMER_DATA
WHERE Email = @Email
UPDATE SHIPPING_ADDRESS
SET Street = @Street1,
Street2 = @Street2,
City = @City,
Zip = @Zip,
Region = @Region,
Country = @Country
WHERE ShippingAddressID = @ShippingAddressID
END
END
END;
CREATE PROCEDURE uspUpdateAdminAccess
(
@CurrentAdministrator VARCHAR(45),
@CurrentSalt VARCHAR(45),
@UserStatusChange VARCHAR(45),
@ChangeAccess bit
)
AS
BEGIN
DECLARE @AdminCheck BIT
/*See if current user is an admin*/
EXEC @AdminCheck = uspVerifyAdministrator @CurrentAdministrator, @CurrentSalt
IF @AdminCheck <> 1
PRINT 'User does not have permission to edit'
ELSE
BEGIN
UPDATE ADMINISTRATOR
SET AdminAccess = @ChangeAccess
WHERE UserName = @UserStatusChange
END
END
Table Creation Code
CREATE TABLE ADMINISTRATOR (
AdministratorID INT NOT NULL IDENTITY (1000,1),
Username VARCHAR(20) NOT NULL,
Hash VARCHAR(45) NOT NULL,
Salt VARCHAR(45) NOT NULL,
AdminAccess BIT NOT NULL,
CONSTRAINT Admin_PK PRIMARY KEY(AdminID)
);
CREATE TABLE DISCOUNT (
DiscountID INT NOT NULL IDENTITY (1,1),
Name VARCHAR(25) NOT NULL,
DiscountPercent NUMERIC(2,3) NOT NULL,
CONSTRAINT Discount_PK PRIMARY KEY(DiscountID)
);
CREATE TABLE CUSTOMER (
CustomerID INT NOT NULL IDENTITY(1000,1),
Hash VARCHAR(45) NOT NULL,
Salt VARCHAR(45) NOT NULL,
CONSTRAINT Customer_PK PRIMARY KEY(CustomerID)
);
CREATE TABLE AUTHOR_INTERSECTION (
AuthorID INT NOT NULL,
BookDataID INT NOT NULL,
CONSTRAINT AInter_PK PRIMARY KEY(AuthorID, BookDataID)
);
CREATE TABLE AUTHOR (
AuthorID INT NOT NULL IDENTITY (1000,1),
AuthorName VARCHAR(20) NOT NULL,
CONSTRAINT Author_PK PRIMARY KEY(AuthorID)
);
CREATE TABLE BILLING_ADDRESS (
BillingAddressID INT NOT NULL IDENTITY (1000,1),
Street VARCHAR(25) NOT NULL,
Street2 VARCHAR(25) NULL,
City VARCHAR(25) NOT NULL,
Zip VARCHAR(6) NULL,
Region VARCHAR(25) NOT NULL,
Country VARCHAR(25) NOT NULL,
CONSTRAINT Billing_PK PRIMARY KEY(BillingAddressID),
CONSTRAINT Region_check CHECK(Region='Alabama' or Region='Alaska' or
Region='Arizona' or Region='California' or Region='Colorado' or Region='Connecticut' or
Region='Delaware' or Region='Florida' or Region='Georgia' or Region='Hawaii' or
Region='Idaho' or Region='Illinois' or Region='Indiana' or Region='Iowa' or
Region='Kansas' or Region='Kentucky' or Region='Louisiana' or Region='Maine' or
Region='Maryland' or Region='Massachusetts' or Region='Michigan' or Region='Minnesota' or
Region='Mississippi' or Region='Missouri' or Region='Montana' or Region='Nebraska' or
Region='Nevada' or Region='New Hampshire' or Region='New Jersey' or Region='New Mexico'
or Region='New York' or Region='North Carolina' or Region='North Dakota' or Region='Ohio'
or Region='Oklahoma' or Region='Oregon' or Region='Pennsylvania' or Region='Rhode Island'
or Region='South Carolina' or Region='South Dakota' or Region='Tennessee' or
Region='Texas' or Region='Utah' or Region='Vermont' or Region='Virginia' or
Region='Washington' or Region='West Virginia' or Region='Wisconsin' or Region='Wyoming'
or Region='Pacific Coast' or Region='Gulf of Mexico' or Region='Baja' or Region='Central'
or Region='Northern' or Region='Alberta' or Region='British Columbia' or
Region='Manitoba' or Region='New Brunswick' or Region='Newfoundland and labrador' or
Region='Northwest Territories' or Region='Nova Scotia' or Region='Nunavut' or
Region='Ontario' or Region='Prince Edward Island' or Region='Quebec' or
Region='Saskatchewan' or Region='Yukon'),
CONSTRAINT Country_Check Check(Country='United States' or
Country='Mexico' or Country='Canada')
);
CREATE TABLE CUSTOMER_DATA (
CustomerDataID INT NOT NULL IDENTITY(1000,1),
CustomerID INT NOT NULL,
BillingAddressID INT NOT NULL,
ShippingAddressID INT NOT NULL,
ShoppingCartID INT NOT NULL,
CreditCardID INT NOT NULL,
FirstName VARCHAR(25) NOT NULL,
LastName VARCHAR(25) NOT NULL,
Age INT NOT NULL,
Gender CHAR(1) NOT NULL,
EMail VARCHAR(40) NOT NULL,
HomePhone VARCHAR(15) NOT NULL,
WorkPhone VARCHAR(15) NULL,
CONSTRAINT CustomerData_PK PRIMARY KEY(CustomerDataID),
CONSTRAINT CustomerID_FK FOREIGN KEY(CustomerID) REFERENCES
CUSTOMER(CustomerID),
CONSTRAINT BillingAddressID_FK FOREIGN KEY(BillingAddressID) REFERENCES
BILLING_ADDRESS(BillingAddressID),
CONSTRAINT ShippingAddressID_FK FOREIGN KEY(ShippingAddressID) REFERENCES
SHIPPING_ADDRESS(ShoppingAddressID),
CONSTRAINT ShoppingCartID_FK FOREIGN KEY(ShoppingCartID) REFERENCES
SHOPPING_CART(ShoppingCartID),
CONSTRAINT CreditCardID_FK FOREIGN KEY(CreditCardID) REFERENCES
CREDIT_CARD(CreditCardID),
CONSTRAINT Gender_check Check ('U' or 'F' or 'M' )
);
CREATE TABLE SHIPPING_ADDRESS (
ShippingAddressID INT NOT NULL IDENTITY(1000,1),
Street VARCHAR(25) NOT NULL,
Street2 VARCHAR(20) NULL,
City VARCHAR(25) NOT NULL,
Zip VARCHAR(5) NULL,
Region VARCHAR(25) NOT NULL,
Country VARCHAR(25) NOT NULL,
CONSTRAINT ship_address_pk PRIMARY KEY(shippingAddressID),
CONSTRAINT Region_check CHECK(Region='Alabama' or Region='Alaska' or
Region='Arkansas' or Region='Arizona' or Region='California' or Region='Colorado' or
Region='Connecticut' or Region='Delaware' or Region='Florida' or Region='Georgia' or
Region='Hawaii' or Region='Idaho' or Region='Illinois' or Region='Indiana' or
Region='Iowa' or Region='Kansas' or Region='Kentucky' or Region='Louisiana' or
Region='Maine' or Region='Maryland' or Region='Massachusetts' or Region='Michigan' or
Region='Minnesota' or Region='Mississippi' or Region='Missouri' or Region='Montana' or
Region='Nebraska' or Region='Nevada' or Region='New Hampshire' or Region='New Jersey' or
Region='New Mexico' or Region='New York' or Region='North Carolina' or Region='North
Dakota' or Region='Ohio' or Region='Oklahoma' or Region='Oregon' or Region='Pennsylvania'
or Region='Rhode Island' or Region='South Carolina' or Region='South Dakota' or
Region='Tennessee' or Region='Texas' or Region='Utah' or Region='Vermont' or
Region='Virginia' or Region='Washington' or Region='West Virginia' or Region='Wisconsin'
or Region='Wyoming' or Region='Pacific Coast' or Region='Gulf of Mexico' or Region='Baja'
or Region='Central' or Region='Northern' or Region='Alberta' or Region='British Columbia'
or Region='Manitoba' or Region='New Brunswick' or Region='Newfoundland and labrador' or
Region='Northwest Territories' or Region='Nova Scotia' or Region='Nunavut' or
Region='Ontario' or Region='Prince Edward Island' or Region='Quebec' or
Region='Saskatchewan' or Region='Yukon'),
CONSTRAINT Country_Check Check('United States' or 'Mexico' or 'Canada')
);
CREATE TABLE PURCHASES (
PurchaseID INT NOT NULL IDENTITY(1000,1),
BookDataID INT NOT NULL,
PurchaseDateTime DATETIME2 NOT NULL,
SellingPrice Money NOT NULL,
Constraint Purchase_PK PRIMARY KEY(PurchaseID),
Constraint Book_Data_FK FOREIGN KEY(BookDataID)
);
CREATE TABLE BOOK_DATA (
BookDataID INT NOT NULL IDENTITY(1000,1),
PublisherID INT NOT NULL,
Name VARCHAR(25) NOT NULL,
ISBN VARCHAR(13) NOT NULL,
Quantity INT NOT NULL,
CopyrightDate DATE NULL,
Cost NUMERIC(5,2) NOT NULL,
Constraint BookData_PK PRIMARY KEY(BookDataID),
Constraint Author_FK FOREIGN KEY(AuthorID) REFERENCES AUTHOR
(AuthorID),
Constraint Publisher_FK FOREIGN KEY(PublisherID)REFERENCES
PUBLISHER (PublisherID),
Constraint Genre_FK FOREIGN KEY(GenreID)REFERENCES GENRE
(GenreID),
Constraint Cost_Check CHECK (COST >= 0)
);
CREATE TABLE PUBLISHER (
PublisherID INT NOT NULL IDENTITY(1000,1),
PublisherName VARCHAR(30) NOT NULL,
Street VARCHAR(30) NOT NULL,
City VARCHAR(30) NOT NULL,
Region VARCHAR(25) NOT NULL,
Country VARCHAR(25) NOT NULL,
Zip VARCHAR(6) NULL,
CONSTRAINT Publisher_PK PRIMARY KEY(PublisherID),
CONSTRAINT Region_check CHECK(Region='Alabama' or Region='Alaska' or
Region='Arkansas' or Region='Arizona' or Region='California' or Region='Colorado' or
Region='Connecticut' or Region='Delaware' or Region='Florida' or Region='Georgia' or
Region='Hawaii' or Region='Idaho' or Region='Illinois' or Region='Indiana' or
Region='Iowa' or Region='Kansas' or Region='Kentucky' or Region='Louisiana' or
Region='Maine' or Region='Maryland' or Region='Massachusetts' or Region='Michigan' or
Region='Minnesota' or Region='Mississippi' or Region='Missouri' or Region='Montana' or
Region='Nebraska' or Region='Nevada' or Region='New Hampshire' or Region='New Jersey' or
Region='New Mexico' or Region='New York' or Region='North Carolina' or Region='North
Dakota' or Region='Ohio' or Region='Oklahoma' or Region='Oregon' or Region='Pennsylvania'
or Region='Rhode Island' or Region='South Carolina' or Region='South Dakota' or
Region='Tennessee' or Region='Texas' or Region='Utah' or Region='Vermont' or
Region='Virginia' or Region='Washington' or Region='West Virginia' or Region='Wisconsin'
or Region='Wyoming' or Region='Pacific Coast' or Region='Gulf of Mexico' or Region='Baja'
or Region='Central' or Region='Northern' or Region='Alberta' or Region='British Columbia'
or Region='Manitoba' or Region='New Brunswick' or Region='Newfoundland and labrador' or
Region='Northwest Territories' or Region='Nova Scotia' or Region='Nunavut' or
Region='Ontario' or Region='Prince Edward Island' or Region='Quebec' or
Region='Saskatchewan' or Region='Yukon'),
CONSTRAINT Country_Check Check(Country='United States' or
Country='Mexico' or Country='Canada')
);
CREATE TABLE PUBLISHER_CONTACTS (
ContactID INT NOT NULL IDENTITY(1000,1),
PublisherID INT NOT NULL,
ContactName VARCHAR(20) NULL,
Phone NUMERIC(11) NULL,
CONSTRAINT PublisherCON_PK PRIMARY KEY(ContactID),
CONSTRAINT PublisherID_FK FOREIGN KEY (PublisherID)REFERENCES
PUBLISHER(PublisherID)
);
CREATE TABLE CREDIT_CARD (
CreditCardID INT NOT NULL IDENTITY(1000,1),
Name VARCHAR(25) NOT NULL,
ExpirationDate DATETIME2(4) NOT NULL,
CreditCardNumber NUMERIC(16) NOT NULL,
CreditCardType VARCHAR(25) NOT NULL,
SecurityCode INT NOT NULL,
CONSTRAINT CreditCardID_PK PRIMARY KEY(CreditCardID),
CONSTRAINT CardType_Check CHECK(CreditCardType = 'VISA' OR CreditCardType
='American Express' OR CreditCardType ='MasterCard' OR CreditCardType ='Discover'),
);
CREATE TABLE SHOPPING CART (
ShoppingCartID INT NOT NULL IDENTITY(1000,1),
CustomerDataID INT NOT NULL,
TransactionDateTime DATETIME2 NULL,
Total MONEY NULL,
CONSTRAINT ShoppingCartID_PK PRIMARY KEY(ShoppingCartID),
CONSTRAINT TransactionID_FK FOREIGN KEY(TransactionID) REFERENCES
TRANSACTIONS(TransactionID),
CONSTRAINT CustomerDataID_FK FOREIGN KEY(CustomerDataID) REFERENCES
CUSTOMER_DATA(CustomerDataID),
);
CREATE TABLE TRANSACTIONS (
TransactionID INT NOT NULL IDENTITY(1000,1),
ShoppingCartID INT NOT NULL,
BookDataID INT NOT NULL,
CONSTRAINT TransactionID_PK PRIMARY KEY(TransactionID),
CONSTRAINT ShoppingCartID_FK FOREIGN KEY(ShoppingCartID) REFERENCES
SHOPPING_CART(ShoppingCartID),
CONSTRAINT BookDataID_FK FOREIGN KEY(BookDataID) REFERENCES BOOK_DATA
(BookDataID)
);
CREATE TABLE GENRE_INTERSECTION (
GenreID INT NOT NULL,
BookDataID INT NOT NULL,
CONSTRAINT GenreID_BookDataID_PK PRIMARY KEY(GenreID, BookDataID)
);
CREATE TABLE GENRE (
GenreID INT NOT NULL IDENTITY(1000,1),
GenreName VARCHAR(25) NULL,
CONSTRAINT GenreID_PK PRIMARY KEY(GenreID)
);
ALTER TABLE GENRE_INTERSECTION
ADD FOREIGN KEY (GenreID)
REFERENCES GENRE(GenreID);
ALTER TABLE GENRE_INTERSECTION
ADD FOREIGN KEY (BookDataID)
REFERENCES BOOK_DATA(BookDataID);
ALTER TABLE AUTHOR_INTERSECTION
ADD FOREIGN KEY (BookDataID)
REFERENCES BOOK_DATA(BookDataID);
ALTER TABLE AUTHOR_INTERSECTION
ADD FOREIGN KEY (AuthorID)
REFERENCES AUTHOR(AuthorID);
Execute/Insert Statements
Insert Genre
EXEC uspAddGenre 'Computer Science';
EXEC uspAddGenre 'Classic';
EXEC uspAddGenre 'Comic';
EXEC uspAddGenre 'Crime';
EXEC uspAddGenre 'Fable';
EXEC uspAddGenre 'Fairy Tale';
EXEC uspAddGenre 'Christian';
EXEC uspAddGenre 'Christian Fiction';
EXEC uspAddGenre 'Fantasy';
EXEC uspAddGenre 'Historical Fiction';
EXEC uspAddGenre 'Horror';
EXEC uspAddGenre 'Legend';
EXEC uspAddGenre 'Mystery';
EXEC uspAddGenre 'Science Fiction';
EXEC uspAddGenre 'Short Story';
EXEC uspAddGenre 'Thriller';
EXEC uspAddGenre 'Tall Tale';
EXEC uspAddGenre 'Western';
EXEC uspAddGenre 'Autobiography';
EXEC uspAddGenre 'Biography';
EXEC uspAddGenre 'Essay';
EXEC uspAddGenre 'Textbook';
EXEC uspAddGenre 'Mathematics';
EXEC uspAddGenre 'Reference';
EXEC uspAddGenre 'Childrens';
EXEC uspAddGenre 'Womens Fiction';
Insert Book_data
exec uspAddBookData
'Zach','25604dc1079c9137d26925da85a22b6b','Forgotten Snake','9781234567897',21,'10-27-
1993','33','Andrews McMeel';
exec uspAddBookData
'Zach','25604dc1079c9137d26925da85a22b6b','The Hot
Streams','1990259367631',10,'2/29/2000','2','Andrews McMeel';
exec uspAddBookData
'Zach','25604dc1079c9137d26925da85a22b6b','Men of
Sorcerer','0445986518916',213,'5/12/2000','34','Andrews McMeel';
exec uspAddBookData
'Zach','25604dc1079c9137d26925da85a22b6b','The Voyages
Shard','7374569404550',344,'5/30/2001','12','Andrews McMeel';
exec uspAddBookData
'Zach','25604dc1079c9137d26925da85a22b6b','The Stone of the
Word','8744533136741',22,'6/21/2001','10','Andrews McMeel';
exec uspAddBookData
'Zach','25604dc1079c9137d26925da85a22b6b','Child in the
Tears','7650816020495',66,'7/9/2002','32','Andrews McMeel';
exec uspAddBookData
'Zach','25604dc1079c9137d26925da85a22b6b','Last
Children','1884709673002',77,'6/29/2004','12','Andrews McMeel';
exec uspAddBookData
'Zach','25604dc1079c9137d26925da85a22b6b','The Bold
Stars','8445987218589',212,'12/22/2005','14','Andrews McMeel';
exec uspAddBookData
'Zach','25604dc1079c9137d26925da85a22b6b','Dying of
Someone','1099727848738',212,'2/16/2006','15','Andrews McMeel';
exec uspAddBookData
'Zach','25604dc1079c9137d26925da85a22b6b','The Ships
Obsession','9474622227365',211,'5/10/2006','23','Andrews McMeel';
exec uspAddBookData
'Zach','25604dc1079c9137d26925da85a22b6b','The Years of the
Witches','8441155925360',32,'5/12/2006','21','Andrews McMeel';
exec uspAddBookData
'Zach','25604dc1079c9137d26925da85a22b6b','Boy in the
Dreamer','5813272132446',45,'8/7/2006','32','Andrews McMeel';
exec uspAddBookData
'Zach','25604dc1079c9137d26925da85a22b6b','Cracked
Willow','1609190566464',23,'10/4/2006','45','Andrews McMeel';
exec uspAddBookData
'Zach','25604dc1079c9137d26925da85a22b6b','The Hot
Waves','2135040972828',254,'2/16/2007','12','Andrews McMeel';
exec uspAddBookData
'Zach','25604dc1079c9137d26925da85a22b6b','Bridge of
Women','8668364422722',153,'2/27/2007','32','Andrews McMeel';
exec uspAddBookData
'Zach','25604dc1079c9137d26925da85a22b6b','The Snakes Spark','0090060335185',22,'10-27-
1993','45','Andrews McMeel';
exec uspAddBookData
'Zach','25604dc1079c9137d26925da85a22b6b','The Roses of the
Swords','9781234567897',67,'12/10/2007','11','Andrews McMeel';
exec uspAddBookData
'Zach','25604dc1079c9137d26925da85a22b6b','Dreamer in the
Dreams','9419905884520',1,'8/11/2008','16','Andrews McMeel';
exec uspAddBookData
'Zach','25604dc1079c9137d26925da85a22b6b','Only
Emerald','0162911639327',232,'11/11/2008','32','Andrews McMeel';
exec uspAddBookData
'Zach','25604dc1079c9137d26925da85a22b6b','The Final
Destruction','4659766372122',243,'1/28/2011','15','Andrews McMeel';
exec uspAddBookData
'Zach','25604dc1079c9137d26925da85a22b6b','Dream of
Touch','7962192512153',67,'8/29/2011','32','Andrews McMeel';
exec uspAddBookData
'Zach','25604dc1079c9137d26925da85a22b6b','The Lordss
Lights','2879060597570',99,'12/8/2011','29','Andrews McMeel';
exec uspAddBookData
'Zach','25604dc1079c9137d26925da85a22b6b','The Boyfriend of the
Secrets','1888859649381',787,'3/19/2013','13','Andrews McMeel';
exec uspAddBookData
'Zach','25604dc1079c9137d26925da85a22b6b','Willow in the
Husband','0272223960105',245,'3/4/2014','12','Andrews McMeel';
exec uspAddBookData
'Zach','25604dc1079c9137d26925da85a22b6b','Trembling
Dying','3190084542284',342,'12/2/2014','12','Andrews McMeel';
Insert Author
exec uspAddAuthor 'Joan Griffith','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthor 'Johanna Allison','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthor 'Rick Andrews','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthor 'Glenda Greer','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthor 'Sadie Holloway','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthor 'Lee Sanchez','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthor 'Ann Mack','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthor 'Marion Chavez','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthor 'Lucas Salazar','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthor 'Edmund Bridges','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthor 'Anita Berry','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthor 'Sophia Lyons','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthor 'Kathaleen Anthony','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthor 'Arlena Ashcraft','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthor 'Blossom Lenz','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthor 'Richelle Hindman','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthor 'Carmine Ives','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthor 'Janita Hamrick','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthor 'Elina Koonce','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthor 'Arianna Minor','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthor 'Minna Couture','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthor 'Bari Sanborn','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthor 'Marcela Brinkman','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthor 'Tamar Ferrara','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthor 'Tonita Jefferies','Zach','25604dc1079c9137d26925da85a22b6b';
Insert AuthorToBook
exec uspAddAuthorToBook 'Joan
Griffith','9781234567897','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthorToBook 'Johanna
Allison','1990259367631','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthorToBook 'Rick
Andrews','0445986518916','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthorToBook 'Glenda
Greer','7374569404550','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthorToBook 'Sadie
Holloway','8744533136741','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthorToBook 'Lee
Sanchez','7650816020495','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthorToBook 'Ann
Mack','1884709673002','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthorToBook 'Marion
Chavez','8445987218589','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthorToBook 'Lucas
Salazar','1099727848738','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthorToBook 'Edmund
Bridges','9474622227365','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthorToBook 'Anita
Berry','8441155925360','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthorToBook 'Sophia
Lyons','5813272132446','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthorToBook 'Kathaleen
Anthony','1609190566464','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthorToBook 'Arlena
Ashcraft','2135040972828','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthorToBook 'Blossom
Lenz','8668364422722','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthorToBook 'Richelle
Hindman','0090060335185','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthorToBook 'Carmine
Ives','9781234567897','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthorToBook 'Janita
Hamrick','9419905884520','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthorToBook 'Elina
Koonce','0162911639327','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthorToBook 'Arianna
Minor','4659766372122','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthorToBook 'Minna
Couture','7962192512153','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthorToBook 'Bari
Sanborn','2879060597570','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthorToBook 'Marcela
Brinkman','1888859649381','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthorToBook 'Tamar
Ferrara','0272223960105','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddAuthorToBook 'Tonita
Jefferies','3190084542284','Zach','25604dc1079c9137d26925da85a22b6b';
Insert AddGenreToBook
exec uspAddGenreToBook
'Horror','9781234567897','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddGenreToBook
'Legend','1990259367631','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddGenreToBook 'Historical
Fiction','0445986518916','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddGenreToBook
'Christian','7374569404550','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddGenreToBook 'Christian
Fiction','8744533136741','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddGenreToBook 'Fairy
Tale','7650816020495','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddGenreToBook 'Fable','1884709673002','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddGenreToBook
'Thriller','8445987218589','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddGenreToBook 'Tall
Tale','1099727848738','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddGenreToBook
'Western','9474622227365','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddGenreToBook
'AutoBiography','8441155925360','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddGenreToBook 'Essay','5813272132446','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddGenreToBook
'Textbook','1609190566464','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddGenreToBook
'Mathematics','2135040972828','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddGenreToBook
'Reference','8668364422722','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddGenreToBook
'Childrens','0090060335185','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddGenreToBook 'Womens
Fiction','9781234567897','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddGenreToBook
'Fantasy','9419905884520','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddGenreToBook 'Computer
Science','0162911639327','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddGenreToBook
'Classic','4659766372122','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddGenreToBook 'Comic','7962192512153','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddGenreToBook 'Crime','2879060597570','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddGenreToBook 'Fable','1888859649381','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddGenreToBook
'Fantasy','0272223960105','Zach','25604dc1079c9137d26925da85a22b6b';
exec uspAddGenreToBook
'Legend','3190084542284','Zach','25604dc1079c9137d26925da85a22b6b';
Insert CustomerData
exec uspAddCustomer
'3aeb68512873517780de26e7d5c2c797','f74373bfb971478ff39bbc2f63e23738','2521 Foggy
Quay','none','Smacker','06271',
'Connecticut','United States','Kaitlin Gonzales','2016-01-
01','bdbc5e32c5093be0c980fd5bf44f07f3','Visa',
'8bbff5ca15840b768e54d0af6dcbe923','2521 Foggy
Quay','none','Smacker','06271','Connecticut','United States',
'Kaitlin','Gonzales',21,'F','TheSupremeProgrammer@gmail.com','8330029333','8557295452'
exec uspAddCustomer
'7a910465674a172f8d2bda6ebd0fef13','806d6f4364da918d09a9d0a78a8a7003','1485 Rustic
Island','none','Elk Point',
'74341','Oklahoma','United States','Reba
Johns','12/01/2016','bdbc5e32c5093be0c980fd5bf44f07f3','Visa',
'6c6bf61764f0ebc6e7963f0f97e263ad','1485 Rustic Island','none','Elk
Point','74341','Oklahoma','United States',
'Reba','Johns',34,'F','duraku@hotmail.com','8995139294','8995906995';
exec uspAddCustomer
'7a910465674a172f8d2bda6ebd0fef13','806d6f4364da918d09a9d0a78a8a7003','1485 Rustic
Island','none','Elk Point',
'74341','Oklahoma','United States','Reba
Johns','12/01/2016','bdbc5e32c5093be0c980fd5bf44f07f3','Visa',
'6c6bf61764f0ebc6e7963f0f97e263ad','1485 Rustic Island','none','Elk
Point','74341','Oklahoma','United States',
'Reba','Johns',34,'F','duraku@hotmail.com','8995139294','8995906995';
exec uspAddCustomer
'50a0e3908bfe7aab476e8ff239aa8f46','5e68b18886ea516c4157a8bff3ae14e1','1198 Easy
Concession','none','Half Day',
'64483','Missouri','United States','Francis
Winters','5/01/2018','540c729845d43a49dcc3b3cdb4030f48','Visa',
'fdeae4c723b97cad80bd0068de4f850a','1198 Easy Concession','none','Half
Day','64483','Missouri','United States',
'Francis','Winters',24,'M','cichon@yahoo.com','8330834977','8332498010';
exec uspAddCustomer
'59fb2bb4a6394193c861d83d5dad3eec','88e632b10bffef59036ab9d4eaf8d415','4027 Green
Key','none','Spackenkill',
'74386','Oklahoma','United States','Daryl
Burt','2/01/2017','8a3d8fa5561018d0226c28109aeeb4f5','Visa',
'53f43e021295e1e573d0bc1f25ee83f8','4027 Green
Key','none','Spackenkill','74386','Oklahoma','United States','Daryl',
'Burt','67',M,'quastad@gmail.com','8442141998','8114419861';
exec uspAddCustomer
'1a329016def2b1cbe3464f096e23883b','9b7edb63f3524969bdb89a3509a70952','3580 Stony Zephyr
Via','none','Hog Back',
'64109','Missouri','United States','Dana
Marsh','3/01/2016','852a392b297e3f25e082401a24eb014c','MasterCard',
'ae4f856688cb91a255afa4695745cbba','3580 Stony Zephyr Via','none','Hog
Back','64109','Missouri','United States',
'Dana','Marsh',65,'F','ewton@rocketmail.com','8999002333','8554494340';
exec uspAddCustomer
'82a02ea479d46a709507e88fdd30b51c','be6eeda2f9c517a011138ad921e83a48','5978 Velvet
Grove','none','Montague',
'44189','Ohio','United States','Mindi
Andrews','10/01/2017','4e40386beae17a6dce432c3970f6f3a4','MasterCard',
'2e997169635e3ba4fd9e51017a34daa1','5978 Velvet
Grove','none','Montague','44189','Ohio','United States','Mindi',
'Andrews',45,'F','ewton@gmail.com','8115698543','8338113644';
exec uspAddCustomer
'c7f11753b8b15ca9349774b564fdc3d6','d84e4aed20d6a4065fc95c420a4f53cf','6873 Silver
Circle','none','Trojan',
'56485','Minnesota','United States','Teddy
Howe','11/01/2016','fcfcd793f55d8c55ba24c9ad6baa9fba','MasterCard',
'07da5ae6ef692ac3f2867ad5f383d1d9','6873 Silver
Circle','none','Trojan','56485','Minnesota','United States',
'Teddy','Howe',88,'M','lineman@outlook.com','8332702587','8339949158';
exec uspAddCustomer
'772cca0799a1d81bef8ec25feb752235','e3aae19a4883ef6cf99afa3d102bfb2a','268 Dewy Fawn
Limits','none','Asylum',
'64229','Missouri','United States','Lynne
Man','8/01/2016','ca610302309c3aec8cad43ebb0258a06','MasterCard',
'd2eb358097c89edce0549f4914436d3f','268 Dewy Fawn
Limits','none','Asylum','64229','Missouri','United States',
'Lynne','Man',56,'F','knape@rocketmail.com','8229199079','8330059665';
exec uspAddCustomer
'f3f08106d7435e850892ddb924c36ef4','d9cf20819661467e71c50940b3874842','8572 Iron Bear
Cape','none','Hampton',
'44661','Ohio','United States','Thomas
Klein','7/01/2017','eb6ba83fab3d29a405d3b8198174102c','American Express',
'46cb321738b4ca43df57f1ed95acda2d','8572 Iron Bear
Cape','none','Hampton','44661','Ohio','United States','Thomas',
'Klein',26,'M','younger@hotmail.com','8997921351','8337794237';
exec uspAddCustomer
'd906346ea26c1afe021cbd679e5bf497','5d360c0be0e6f6b6c649edec6c8f1ee8','9593 Emerald
Parade','none','Baptist',
'43797','Ohio','United States','Shirley
Herrera','6/01/2017','4c82d70cea65cef6613877a99b377470','American Express',
'995bad8eab9179020182e534aa7d15a8','9593 Emerald
Parade','none','Baptist','43797','Ohio','United States','Shirley',
'Herrera',90,'F','means@hotmail.com','8112178503','8227611128';
exec uspAddCustomer
'a340ddccff49cf444671ea54042ee853','18d12cf3c0a8a451e0aa7f9f71119eda','5562 Amber
Heights','none','Scotland',
'56300','Minnesota','United States','Deon
Doyle','4/01/2016','31cce9ba84673d591a676d6cd35a1b5c','American Express',
'd4c27c37d7bc600779bf6f1f7957f76c','5562 Amber
Heights','none','Scotland','56300','Minnesota','United States','Deon',
'Doyle',41,'F','brooks@yahoo.com','8118403281','8991303988';
exec uspAddCustomer
'627af38cf458d13a507074dfaef9de96','c63f8f63590bf7309d5e76b5abc4503d','6055 Silent
Chase','none','Snows Corner','45758',
'Ohio','United States','Tommie
Shannon','11/01/2016','4697f2edebd5ab7b0a4400499bbe7bb6','American Express',
'b71cf7177119ebe29ce8d31a041a90e4','6055 Silent Chase','none','Snows
Corner','45758','Ohio','United States','Tommie',
'Shannon',55,'M','ehlen@gmail.com','8559100800','8188485040';
exec uspAddCustomer
'3042e6784b810304d9a225665c6b5918','dbf0e92ad8dc0d049d7eeb769f8db679','9413 Red Shadow
Maze','none','Kalamazoo','72548',
'Arkansas','United States','Everett
Frank','02/01/2018','c30e407163ab5677e5f57bb413887b75','Discover','fb1114644c5c0d8a1cdb5e
3af25bbbe1',
'9413 Red Shadow Maze','none','Kalamazoo','72548','Arkansas','United
States','Everett','Frank',76,'F','kuttler@rocketmail.com','8557232544','8112934301';
Insert Publisher/Publisher Contact
EXEC uspAddPublisherContact 'Andrew', '63e13ebec85d0e600652c65e9ddd8a50', 'Andrews
McMeel', 'Eli Neal', 4799874563;
EXEC uspAddPublisherContact 'Andrew', '63e13ebec85d0e600652c65e9ddd8a50',
'HarperCollins', 'Zane Buchanan', 4791239845;
EXEC uspAddPublisherContact 'Andrew', '63e13ebec85d0e600652c65e9ddd8a50', 'Andrews
McMeel', 'Eli Neal', 4799874563;
EXEC uspAddPublisherContact 'Andrew', '63e13ebec85d0e600652c65e9ddd8a50',
'HarperCollins', 'Zane Buchanan', 4791239845;
Add books to shopping cart
EXEC uspAddBookToShoppingCart '9781449460839', 'rockmasterx2000@rockstar.com'
EXEC uspAddBookToShoppingCart '9780062391735', 'rockmasterx2000@rockstar.com'
EXEC uspAddBookToShoppingCart '0445986518916', 'rockmasterx2000@rockstar.com'
EXEC uspAddBookToShoppingCart '7650816020495', 'TheSupremeProgrammer@gmail.com'
EXEC uspAddBookToShoppingCart '1099727848738', 'TheSupremeProgrammer@gmail.com'
EXEC uspAddBookToShoppingCart '7962192512153', 'TheSupremeProgrammer@gmail.com'
EXEC uspAddBookToShoppingCart '2879060597570', 'TheSupremeProgrammer@gmail.com'
EXEC uspAddBookToShoppingCart '9781234567897', 'duraku@hotmail.com'
EXEC uspAddBookToShoppingCart '2135040972828', 'cichon@yahoo.com'
EXEC uspAddBookToShoppingCart '1609190566464', 'quastad@gmail.com'
EXEC uspAddBookToShoppingCart '3190084542284', 'quastad@gmail.com'
EXEC uspAddBookToShoppingCart '7650816020495', 'quastad@gmail.com'
EXEC uspAddBookToShoppingCart '8441155925360', 'cowgirl@rocketmail.com'
EXEC uspAddBookToShoppingCart '9419905884520', 'cowgirl@rocketmail.com'
EXEC uspAddBookToShoppingCart '3190084542284', 'ewton@gmail.com'
EXEC uspAddBookToShoppingCart '9781234567897', 'lineman@outlook.com'
EXEC uspAddBookToShoppingCart '1609190566464', 'lineman@outlook.com'
EXEC uspAddBookToShoppingCart '9781234567897', 'lineman@outlook.com'
EXEC uspAddBookToShoppingCart '1609190566464', 'lineman@outlook.com'
EXEC uspAddBookToShoppingCart '0090060335185', 'lineman@outlook.com'
EXEC uspAddBookToShoppingCart '8445987218589', 'knape@rocketmail.com'
EXEC uspAddBookToShoppingCart '9781234567897', 'younger@hotmail.com'
EXEC uspAddBookToShoppingCart '1609190566464', 'younger@hotmail.com'
EXEC uspAddBookToShoppingCart '9419905884520', 'younger@hotmail.com'
EXEC uspAddBookToShoppingCart '1099727848738', 'means@hotmail.com'
EXEC uspAddBookToShoppingCart '9781234567897', 'means@hotmail.com'
EXEC uspAddBookToShoppingCart '2879060597570', 'means@hotmail.com'
EXEC uspAddBookToShoppingCart '0090060335185', 'brooks@yahoo.com'
EXEC uspAddBookToShoppingCart '8445987218589', 'brooks@yahoo.com'
EXEC uspAddBookToShoppingCart '0445986518916', 'ehlen@gmail.com'
EXEC uspAddBookToShoppingCart '1884709673002', 'ehlen@gmail.com'
EXEC uspAddBookToShoppingCart '7374569404550', 'ehlen@gmail.com'
EXEC uspAddBookToShoppingCart '1099727848738', 'ehlen@gmail.com'
EXEC uspAddBookToShoppingCart '7374569404550', 'kuttler@rocketmail.com'
EXEC uspAddBookToShoppingCart '1099727848738', 'kuttler@rocketmail.com'
Finish Transaction
EXEC uspFinishTransaction 'rockmasterx2000@rockstar.com'
EXEC uspFinishTransaction 'TheSupremeProgrammer@gmail.com'
EXEC uspFinishTransaction 'duraku@hotmail.com'
EXEC uspFinishTransaction 'cichon@yahoo.com'
EXEC uspFinishTransaction 'quastad@gmail.com'
EXEC uspFinishTransaction 'ewton@gmail.com'
EXEC uspFinishTransaction 'lineman@outlook.com'
EXEC uspFinishTransaction 'knape@rocketmail.com'
EXEC uspFinishTransaction 'younger@hotmail.com'
EXEC uspFinishTransaction 'means@hotmail.com'
EXEC uspFinishTransaction 'brooks@yahoo.com'
EXEC uspFinishTransaction 'ehlen@gmail.com'
EXEC uspFinishTransaction 'kuttler@rocketmail.com'

More Related Content

Viewers also liked

1 presentazione di prog.smart plat
1 presentazione di prog.smart plat1 presentazione di prog.smart plat
1 presentazione di prog.smart plat
giuliana d'amore
 
Instyletema
InstyletemaInstyletema
Instyletema
albertandrei
 
Interatividade : Definições, estudos e tendências
Interatividade : Definições, estudos e tendênciasInteratividade : Definições, estudos e tendências
Interatividade : Definições, estudos e tendências
Alysson neves
 
Smart plat giuliana d'amore
Smart plat giuliana d'amoreSmart plat giuliana d'amore
Smart plat giuliana d'amore
giuliana d'amore
 
Online Communities: Revenue Drivers or Dead Zones?
Online Communities: Revenue Drivers or Dead Zones?Online Communities: Revenue Drivers or Dead Zones?
Online Communities: Revenue Drivers or Dead Zones?
Influitive
 
NATIONAL_PRODUCER_AGREEMENT_Fill-In_-1
NATIONAL_PRODUCER_AGREEMENT_Fill-In_-1NATIONAL_PRODUCER_AGREEMENT_Fill-In_-1
NATIONAL_PRODUCER_AGREEMENT_Fill-In_-1
Bob Itzinger, ARM
 
Jater1
Jater1Jater1
Employee Mutual Commitment Benefits Policy (Domestic Partnership Registry)
Employee Mutual Commitment Benefits Policy (Domestic Partnership Registry)Employee Mutual Commitment Benefits Policy (Domestic Partnership Registry)
Employee Mutual Commitment Benefits Policy (Domestic Partnership Registry)
Mark Penney
 
Do I Have to Pay My Employees for That? Common and Not-So Common Workplace Sc...
Do I Have to Pay My Employees for That? Common and Not-So Common Workplace Sc...Do I Have to Pay My Employees for That? Common and Not-So Common Workplace Sc...
Do I Have to Pay My Employees for That? Common and Not-So Common Workplace Sc...
ADP, LLC
 
PMI_veterans_brochure_singlepage
PMI_veterans_brochure_singlepagePMI_veterans_brochure_singlepage
PMI_veterans_brochure_singlepage
Sandy Cobb, PfMP®, PgMP®, PMP®, M.Ed., ITIL
 
test3
test3test3
El viaje al poder de la conciencia
El viaje al poder de la concienciaEl viaje al poder de la conciencia
El viaje al poder de la conciencia
Euler Ruiz
 

Viewers also liked (13)

1 presentazione di prog.smart plat
1 presentazione di prog.smart plat1 presentazione di prog.smart plat
1 presentazione di prog.smart plat
 
guia #
guia #guia #
guia #
 
Instyletema
InstyletemaInstyletema
Instyletema
 
Interatividade : Definições, estudos e tendências
Interatividade : Definições, estudos e tendênciasInteratividade : Definições, estudos e tendências
Interatividade : Definições, estudos e tendências
 
Smart plat giuliana d'amore
Smart plat giuliana d'amoreSmart plat giuliana d'amore
Smart plat giuliana d'amore
 
Online Communities: Revenue Drivers or Dead Zones?
Online Communities: Revenue Drivers or Dead Zones?Online Communities: Revenue Drivers or Dead Zones?
Online Communities: Revenue Drivers or Dead Zones?
 
NATIONAL_PRODUCER_AGREEMENT_Fill-In_-1
NATIONAL_PRODUCER_AGREEMENT_Fill-In_-1NATIONAL_PRODUCER_AGREEMENT_Fill-In_-1
NATIONAL_PRODUCER_AGREEMENT_Fill-In_-1
 
Jater1
Jater1Jater1
Jater1
 
Employee Mutual Commitment Benefits Policy (Domestic Partnership Registry)
Employee Mutual Commitment Benefits Policy (Domestic Partnership Registry)Employee Mutual Commitment Benefits Policy (Domestic Partnership Registry)
Employee Mutual Commitment Benefits Policy (Domestic Partnership Registry)
 
Do I Have to Pay My Employees for That? Common and Not-So Common Workplace Sc...
Do I Have to Pay My Employees for That? Common and Not-So Common Workplace Sc...Do I Have to Pay My Employees for That? Common and Not-So Common Workplace Sc...
Do I Have to Pay My Employees for That? Common and Not-So Common Workplace Sc...
 
PMI_veterans_brochure_singlepage
PMI_veterans_brochure_singlepagePMI_veterans_brochure_singlepage
PMI_veterans_brochure_singlepage
 
test3
test3test3
test3
 
El viaje al poder de la conciencia
El viaje al poder de la concienciaEl viaje al poder de la conciencia
El viaje al poder de la conciencia
 

Similar to AAZ Books Documentation

E space abstract
E   space abstractE   space abstract
E space abstract
k Ushababuraj
 
Online Vegetable Selling project Presentation
Online Vegetable Selling project PresentationOnline Vegetable Selling project Presentation
Online Vegetable Selling project Presentation
mayur patel
 
FINAL-Review
FINAL-ReviewFINAL-Review
FINAL-Review
Amrin Nisha
 
Book store ppt
Book store pptBook store ppt
Book store ppt
Rajesh Rajesh.Bca.McA9
 
BMS PPT.pptx
BMS PPT.pptxBMS PPT.pptx
BMS PPT.pptx
KishanPatel906963
 
SYNOPSIS_PROJECT_TITLE_TOUR_AND_TRAVAL_M.docx
SYNOPSIS_PROJECT_TITLE_TOUR_AND_TRAVAL_M.docxSYNOPSIS_PROJECT_TITLE_TOUR_AND_TRAVAL_M.docx
SYNOPSIS_PROJECT_TITLE_TOUR_AND_TRAVAL_M.docx
GouravPatel18
 
synopsis.pdf
synopsis.pdfsynopsis.pdf
synopsis.pdf
BabluSingh83
 
Technical architecture for order management
Technical architecture for order managementTechnical architecture for order management
Technical architecture for order management
Mohit kumar Gupta
 
PROJECT REPORT -CT-19022-CT-19043-CT-19027-dbms.pdf
PROJECT REPORT -CT-19022-CT-19043-CT-19027-dbms.pdfPROJECT REPORT -CT-19022-CT-19043-CT-19027-dbms.pdf
PROJECT REPORT -CT-19022-CT-19043-CT-19027-dbms.pdf
vishaah1
 
P2P cycle made easy
P2P cycle made easyP2P cycle made easy
P2P cycle made easy
ketulp
 
Master Data Records
Master Data RecordsMaster Data Records
Master Data Records
Rameswara Vedula
 
Practical guide to SQL basics
Practical guide to SQL basicsPractical guide to SQL basics
Practical guide to SQL basics
Pavani Ganti
 
Physical data modeling
Physical data modelingPhysical data modeling
Physical data modeling
Abbas Ahmed
 
2 Relational Database Concepts.ppt
2 Relational Database Concepts.ppt2 Relational Database Concepts.ppt
2 Relational Database Concepts.ppt
Souha Bennani
 
BMS PPT.pptx
BMS PPT.pptxBMS PPT.pptx
BMS PPT.pptx
AdityaSingh393412
 
Fi payment advice functional spec.
Fi payment advice functional spec.Fi payment advice functional spec.
Fi payment advice functional spec.
ANILKUMARPULIPATI1
 
Inventory and Intuit Point of Sale
Inventory and Intuit Point of SaleInventory and Intuit Point of Sale
Inventory and Intuit Point of Sale
rukalm
 
Customer master Data
Customer master DataCustomer master Data
Customer master Data
Gopal Volluri
 
Interface
InterfaceInterface
On-line book store presentation
On-line book store presentation On-line book store presentation
On-line book store presentation
Smit Patel
 

Similar to AAZ Books Documentation (20)

E space abstract
E   space abstractE   space abstract
E space abstract
 
Online Vegetable Selling project Presentation
Online Vegetable Selling project PresentationOnline Vegetable Selling project Presentation
Online Vegetable Selling project Presentation
 
FINAL-Review
FINAL-ReviewFINAL-Review
FINAL-Review
 
Book store ppt
Book store pptBook store ppt
Book store ppt
 
BMS PPT.pptx
BMS PPT.pptxBMS PPT.pptx
BMS PPT.pptx
 
SYNOPSIS_PROJECT_TITLE_TOUR_AND_TRAVAL_M.docx
SYNOPSIS_PROJECT_TITLE_TOUR_AND_TRAVAL_M.docxSYNOPSIS_PROJECT_TITLE_TOUR_AND_TRAVAL_M.docx
SYNOPSIS_PROJECT_TITLE_TOUR_AND_TRAVAL_M.docx
 
synopsis.pdf
synopsis.pdfsynopsis.pdf
synopsis.pdf
 
Technical architecture for order management
Technical architecture for order managementTechnical architecture for order management
Technical architecture for order management
 
PROJECT REPORT -CT-19022-CT-19043-CT-19027-dbms.pdf
PROJECT REPORT -CT-19022-CT-19043-CT-19027-dbms.pdfPROJECT REPORT -CT-19022-CT-19043-CT-19027-dbms.pdf
PROJECT REPORT -CT-19022-CT-19043-CT-19027-dbms.pdf
 
P2P cycle made easy
P2P cycle made easyP2P cycle made easy
P2P cycle made easy
 
Master Data Records
Master Data RecordsMaster Data Records
Master Data Records
 
Practical guide to SQL basics
Practical guide to SQL basicsPractical guide to SQL basics
Practical guide to SQL basics
 
Physical data modeling
Physical data modelingPhysical data modeling
Physical data modeling
 
2 Relational Database Concepts.ppt
2 Relational Database Concepts.ppt2 Relational Database Concepts.ppt
2 Relational Database Concepts.ppt
 
BMS PPT.pptx
BMS PPT.pptxBMS PPT.pptx
BMS PPT.pptx
 
Fi payment advice functional spec.
Fi payment advice functional spec.Fi payment advice functional spec.
Fi payment advice functional spec.
 
Inventory and Intuit Point of Sale
Inventory and Intuit Point of SaleInventory and Intuit Point of Sale
Inventory and Intuit Point of Sale
 
Customer master Data
Customer master DataCustomer master Data
Customer master Data
 
Interface
InterfaceInterface
Interface
 
On-line book store presentation
On-line book store presentation On-line book store presentation
On-line book store presentation
 

AAZ Books Documentation

  • 2. Table of Contents: 1. Executive Summary 2. Contextual ER Diagram 3. Fully Attributed Diagram 4. Table diagram 5. Overview tables 6. TableDataDictionary 7. User Manual 8. Execution Manual 9. Overview of Views 10.View Code 11.Trigger Code 12. Stored Procedure Code 13.Table Creation Code 14.Execute/ Insert Statements
  • 3. Executive Summary In our database we track Customers as they add books to a shopping cart and purchase them and all the additional data required. In the books table we track the name, ISBN, quantity, Copyright Date, Cost, Publisher and genre. Customers are tracked by their CustomerID, Billing Address, Shipping Address, Credit Card, First Name, Last Name, age, gender, Email, Home phone and work phone. Whenever a customer would like to purchase a book they add it to their shopping cart using their email. To actually purchase a book the customer finishes the transaction and then the data from the purchase is added to purchases. In addition to the other features of the data base a customer can change their email address and their hash and salt and many others. Our assumptions were that a customer can have only one billing address and one shipping address because this will force them to have an accurate address that will prevent them from having any reoccurring accidents. We assumed a book can have more than one author and more than one genre, and we also assumed that a customer can only have one credit card.
  • 5. Fully Attributed ER Diagram CUSTOMER ADMINISTRATOR SHOPPING_CART CUSTOMER_DATA TRANSACTIONS BILLING_ADDRESS SHIPPING_ADDRESS BOOK_DATA DISCOUNT PUBLISHER GENRE AUTHOR PURCHASES CustomerIDPK Salt Hash AdminIDPK Salt Hash ShoppingCartIDPK TransactionIDFK CustomerDataIDFK CustomerDataIDPK CustomerIDFK BillingAddressIDFK TransactionIDPK ShoppingCartIDFK BookDataIDFK BillingAddressIDPK Street ShippingAddressIDPK Street BookDataIDPK AuthorIDFK PurchaseIDFK DiscountIDPK DiscountPercent PublisherIDPK PublisherName GenreIDPK GenreName AuthorIDPK AuthorName PurchaseIDPK DatePurchased ShippingAddressIDFK City Zip Street2 State FirstName Age Gender EMail Street2 State Zip City PublisherIDFK GenreIDFK SellingPrice ISBN Quantity Cost LastName Total CopyrightDate CreditCardNumber HomePhone WorkPhone Phone ContactName Address
  • 6. Table Diagram CUSTOMER ADMINISTRATOR SHOPPING_CART CUSTOMER_DATA TRANSACTIONS BILLING_ADDRESS SHIPPING_ADDRESS BOOK_DATA DISCOUNT PUBLISHER_CONTACTS GENRE AUTHOR PURCHASES PUBLISHER GENRE_INTERSECTION AUTHOR_INTERSECTION CREDIT_CARD CustomerIDPK Salt Hash AdminIDPK Salt Hash ShoppingCartIDPK CustomerDataIDFK CustomerDataIDPK CustomerIDFK BillingAddressIDFK TransactionIDPK ShoppingCartIDFK BookDataIDFK BillingAddressIDPK Street ShippingAddressIDPK Street BookDataIDPK DiscountIDPK DiscountPercent PublisherIDFKPublisherName GenreIDPK GenreName AuthorIDPK AuthorName PurchaseIDPK PurchaseDateTime ShippingAddressIDFK City Zip Street2 Region FirstName Age Gender EMail Street2 Zip City PublisherIDFK SellingPrice ISBN Quantity Cost LastName Total CopyrightDate HomePhone WorkPhone Phone ContactNameStreet PublisherIDPK GenreIDFKPK BookDataIDFKPK AuthorIDFKPK BookDataIDFKPK Name CreditCardIDPK CreditCardNumber Name ExpirationDate SecurityCode CreditCardIDFK City Region Zip ContactIDPK Name CreditCardType TransactionDateTime Username AdminAccess Country Region Country Country BookDataIDFK
  • 7. Overview of Tables ADMINISTRATOR – A table that holds administrator information such as username and login information. The password is stored as a hash and salt from the algorithm in the code behind. Also tells what admins can add others and which ones cannot. DISCOUNT – A table will have values that we can pull from in a stored procedure using a DiscountID to put a discount on the total of a finished shopping cart. CUSTOMER – A table that holds customer information such as username and login information. The password is stored as a hash and salt from the algorithm in the code behind. AUTHOR – A table that holds a surrogate key for an author and their name. AUTHOR_INTERSECTION – Since a book can have many authors and an author can have many books, for normalization purposes, we need an intersection table. This table links authors and books together. BILLING_ADDRESS - A table that will hold customer's billing address information. A customer must have a billing address and can have multiple. CUSTOMER_DATA - A table that will hold information about the customer. SHIPPING_ADDRESS - A table that will hold the customer's shipping address. A customer must have a shipping address and can have multiple. BOOK_DATA - This table will hold all of our information about our books. PURCHASES - This table will PUBLISHER - This table will hold all information about the publishers. It holds the name and address of the publishers. PUBLISHER_CONTACTS - This table will hold the phone numbers and the names of the publishers CREDIT_CARD - This table will hold all credit card information for a user. The expiration date must be greater than the current date. SHOPPING_CART - This table will hold the items that the user will buy. TRANSACTIONS - This is an intersection table for the SHOPPING_CART and BOOK_DATA tables. GENRE_INTERSECTION – This is an intersection table to join BOOK_DATA and GENRE GENRE – This is a table to store the different genre names
  • 8. Table Data Dictionary ADMINISTRATOR Attribute Data Type Description AdministratorID Integer (PK) Unique key for Administrator Username Varchar(20) Login username for Administrator Hash Varchar(45) Auto-Generated Value from password Salt VarChar(45) Auto-Generated Value added to Hash AdminAccess Bit 0 = Cannot add new admins 1 = Can add new admins CUSTOMER Attribute Data Type Description CustomerID Integer (PK) Unique key for Customer Hash Varchar(45) Auto-Generated Value from password Salt VarChar(45) Auto-Generated Value added to Hash BILLING_ADDRESS Attribute Data Type Description BillingAddressID Integer(PK) Unique key for Billing Address Street Varchar(25) Customer Billing Address Street2 Varchar(25) If customer has a PO Box City Varchar(25) Customers city that they wish to be billed at. Zip Varchar(6) Customers zip that they wish to be billed at Region Varchar(25) Customers region that they wish to be billed at Country Varchar(25) Customers country that they wish to be billed at Discount Attribute Data Type Description DiscountID Integer(PK) Unique key for Discount Name Varchar(25) Name of discount DiscountPercent Numeric(2,2) The percentage that is be to discounted AUTHOR_INTERSECTION Attribute Data Type Description AuthoerID Integer(PK) Unique key for Author Intersection BookDataID Integer(PK) Unique key for Author Intersection
  • 9. AUTHOR Attribute Data Type Description AuthorID Integer(PK) Unique key for Author AuthorName Varchar(20) The name of the author Customer_DATA Attribute Data Type Description CustomerDataID Integer(PK) Unique key for Customer Data CustomerID Integer(FK) Foreign key from Customer BillingAddressID Integer(FK) Foreign key from Billing Address ShippingAddressID Integer(FK) Foreign key from Shipping Address CreditCardID Integer(FK) Foreign key from Credit Card FirstName Varchar(25) Customers First Name LastName Varchar(25) Customers Last Name Age Integer Customers age Gender Char(1) Customers gender Email Varchar(40) Customers Email HomePhone Varchar(25) Customers Homephone WorkPhone Varchar(25) Customers Workphone CREDIT_CARD Attribute Data Type Description CreditCardID Integer(PK) Unique key for CREDIT_CARD Name Varchar(25) Name of the credit card holder ExpirationDate DateTime2 The month and year when the credit card expires CreditCardNumber Numeric(16) 16-digit number on the credit card CreditCardType Varchar(25) The type of credit card SecurityCode Integer 3-digit code on the back of the credit card SHOPPING_CART Attribute Data Type Description ShoppingCartID Integer(PK) Unique key for SHOPPING_CART TransactionID Integer(FK) Unique key for TRANSACTIONS CustomerDataID Integer(FK) Unique key for CUSTOMER_DATA TransactionDateTime DateTime2 Time that the transaction took place Total Money Total dollar amount of the transaction
  • 10. TRANSACTIONS Attribute Data Type Description TransactionID Integer(PK) Unique key for TRANSACTIONS ShoppingCartID Integer(FK) Unique key for SHOPPING_CART BookDataID Integer(FK) Unique key for BOOK_DATA GENRE_INTERSECTION Attribute Data Type Description GenreID Integer(PK) Unique key for GENRE BookDataID Integer(PK) Unique key for BOOK_DATA GENRE Attribute Data Type Description GenreID Integer(PK) Unique key for GENRE GenreName VarChar(25) Name of the type of genre Publisher Attribute Data Type Description PublisherID Integre(PK) Unique key for Publisher PublisherName Varchar(30) The publishers name that they go by Street Varchar(30) The publisher's street that they work at City Varchar(30) The publisher's city that they work in Region Varchar(25) The publisher's regioin that they work in Country Varchar(25) The publisher's country that they work in Zip Varchar(6) The publisher's zip that they work in BOOK_DATA Attribute Data Type Description BookDataID Integer (PK) Unique key for Book Data PurchaseID Integer(FK) Foreign key for Purchases PublisherID Integer(FK) Foreign key for Publisher Name Varchar(45) The name of the Book ISBN Varchar(13) The ISBN for the book Quantity Integer How many books are on stock CopyrightDate Date The year that the book was written Cost Numeric(5,2) The cost of the book
  • 11. PURCHASES Attribute Data Type Description PurchaseID Integer(PK) Unique key for Purchases PurchaseDateTime DateTime2 The time that the item was purchased SellingPrice Money The selling price of the item or items SHIPPING_ADDRESS Attribute Data Type Description ShippingAddressID Integer(PK) Unique key for Shipping Address Street Varchar(25) Customer's address where they receive mail Street2 Varchar(20) Customer's PO box City Varchar(25) Customer's city that the shipping address is in Zip Varchar(5) Customer's zip that the shipping address is in Region Varchar(25) Customer's region that the shipping address is in Country Varchar(25) Customer's country that the shipping address is in PUBLISHER_CONTACTS Attribute Data Type Description ConatctID Integer Unique key for Publisher_Contacts PublisherID Integer Foreign key for Publisher ContactName VARCHAR(20) The name of the person from the publishing company Phone Numeric(11) The phone number to contact the publisher
  • 12. User Manual Overview of Stored Procedures uspAddCustomer Accepts: Hash, Salt, StreetBa, Street2Ba, CityBa, ZipBa, RegionBa, CountryBa, Name, ExpirationDate, CreditCardNumber, CreditCardType, SecurityCode, StreetSa, Street2Sa, CitySa, ZipSa, RegionSa, CountrySa, FirstName, LastName, Age, Gender, Email, Homephone, WorkPhone Description: This procedure adds a new customer with their shipping address, billing address, and credit card uspAddAministrator Accepts: CurrentAdministrator, CurrentSalt, Username, Hash, Salt, AdminAccess Description: This procedure allows a current administrator to add a new administrator. First, it checks if the current administrator has permission to add a new administrator, then it checks if the current administrator user name is exists. If the administrator does have permission and the administrator's user name exists, then it add the new administrator's user name, hash, salt, and admin access. Otherwise it will print an error message. uspAddAuthor Accepts: AuthorName, CurrentAdministrator, CurrentSalt Description This procedure allows an administrator to add a new author, uspAddAuthorToBook Accepts: AuthorName, ISBN, CurrentAdministrator, CurrentSalt Description This procedure allow an administrator to link an author to a book. uspAddBookData Accepts: CurrentAdministrator, CurrentSalt, Name, ISBN, Quantity, CopyrightDate, Cost, PublisherName Description: This procedure allows a current administrator to insert a new book into the book_data table given the administrator’s name, and salt, and the book’s title, ISBN number, quantity, copyright date, cost, and the publisher’s name. uspAddBookToShoppingCart Accepts: ISBN, Email Description: This procedure allows link a shopping cart to a book.
  • 13. uspAddGenre Accepts: GenreName Description: This procedure allows a user to insert a type of genre uspAddGenreToBook Accepts: GenreName, ISBN, CurrentAdministrator, CurrentSalt Description: This procedure allows a user to link a book to a type of genre. uspAddPublisher Accepts: PubName, PubStreet, PubCity, PubRegion, PubCountry, PubZip Description: This procedure allows a user to create a new publisher contact with all of their contact information. uspAddPublisherContact Accepts: CurrentAdministrator, CurrentSalt, PublisherName, ContactName, Phone Description: This procedure allows an administrator to create another publisher contact from the same publishing company. uspFinishTransaction Accepts: Email Description: This procedure allows a user to checkout and saves what they selected to purchase. This also checks if the customer is eligible for a discount. uspGetAuthorID Accepts: Author Description: This procedure returns an authorID given the author’s name. uspGetBookID Accepts: ISBN Description: This procedure returns the bookDataID given an ISBN. uspGetCustomerDataID Accepts: Email Description Accepts the customer’s Email and returns the CustomerID for that customer. uspGetCustomerID Accepts: Email, CurrentSalt Description Same as uspGetCustomerDataID, but it requires the customer’s salt.
  • 14. uspGetGenreID Accepts: GenreName Description: This procedure returns the genreID given a genre name. uspGetPublisherID Accepts: PublisherName Description: This procedure returns the publisherID given the publisher’s name. uspGetShoppingCartID Accepts: Email Description: This procedure returns the shoppingCartID given the customer’s email address. uspRemoveBookFromShoppingCart Accepts: Email, ISBN Description: This procedure. uspShowPopularBooksByUnitSold Accepts: Description: This procedure displays the most popular books by the number of them that has been sold. uspShowPopularBooksByVolume Accepts: Description: This procedure displays the most popular books by the total dollar amount of them that has been sold. uspTotalRevenueTimeFrame Accepts: BeginDate, EndDate Description: This procedure allows a user to view the revenue of a specific time frame given a beginning and end date. uspUpdateAdminAccess Accepts: CurrentAdministrator, CurrentSalt, UserStatusChange, ChangeAccess Description: This procedure allows a current administrator to update and change an administrator’s access level.
  • 15. uspUpdateAdminHashSalt Accepts: CurrentAdministrator, CurrentSalt, NewSalt, NewHash Description: This procedure allows a current administrator to update his or her salt and hash given their current administrator name and their current salt. uspUpdateBillingAddress Accepts: CurrentAdministrator, CurrentSalt, Email, Street1, Street2, City, Zip, Region/State, Country Description: This procedure allows an administrator to update the customer’s billing address given the administrator’s username and salt, and the customer’s email address. uspUpdateBookInformation Accepts: CurrentAdministrator, currentSalt, ISBN, Name, NewISBN, Quantity, CopyrightDate, Cost Description: This procedure allows an administrator to update a book’s general information given the administrator’s username and salt, and the book’s ISBN. uspUpdateCustomerEmail Accepts: CurrentAdministrator, AdminSalt, CurrentSalt, Email, NewEmail Description: This procedure allows a current administrator to update and change a customer’s email address given the current administrator’s name, the administrator’s salt, the customer’s salt, and the customer’s new email address and old email address. uspUpdateCustomerHashSalt Accepts: CurrentAdministrator, CurrentSalt, Email, NewCustomerSalt, NewCustomerHash Description: This procedure allows a current administrator to update and change a customer’s hash and salt given the current administrator’s name, salt, the customer’s email, and the customer’s new salt and hash. uspUpdateCustomerInformation Accepts: CurrentAdministrator, CurrentSalt, Email, FirstName, LastName, Age, Gender, NewEmail, HomePhone, and WorkPhone Description: This procedure allows an administrator to update the customer’s general I nformation give the current administrator’s name and salt, and the customer’s current email.
  • 16. uspUpdateShippingAddress Accepts: CurrentAdministrator, CurrentSalt, Email, Street1, Street2, City, Zip, Region/State, Country Description: This procedure allows an administrator to update a customer’s shipping address given the administrator’s username and salt, and the customer’s email address. uspVerifyAdministrator Accepts: CurrentAdministrator, CurrentSalt Description: This procedure checks that the current administrator exists in the administrator table. If the administrator exists in the table then it returns 1, otherwise it will print 'Administrator username or salt is incorrect' and return 0. UspVerifyPublisher Accepts: PublisherName Description: This procedure allows a user to verify that a given publisher name exists with the publisher table.
  • 17. Execution Manual Because database’s require certain information before it can have other information there is a certain way the stored procedures have to be executed. We take an outside inside approach when we execute them meaning that data that has no prerequisites gets executed first. First we will execute uspAddAministrator, that way we have an administrator to be able to create other things. Next we can execute, uspAddAuthor, uspAddBookData, uspAdd Customer, uspAddGenre, and uspAddPublisher. Next we can execute uspAddAuthorToBook, uspAddGenreToBook, and uspAddPublisherContact. After that we are able to execute uspAddBookToShoppingCart. Finally we are able to execute FinishTransaction. Once those are all executed any stored procedure is able to be executed at any time.
  • 18. Overview of Views TotalInventoryByGenre Description: Allows the user to view the total amount of books in each genre. AvgTrans Description: Allows the user to view the average transaction price from all of the transactions. ValueInventoryByPublisher Description: Allows the user to see the value of the total inventory of each publisher. PublisherRevenuePerDay Description: Allows the user to see the revenue made by the different publishers on a particular day.
  • 19. View Code TotalInventoryByGenre CREATE VIEW TotalInventoryByGenre AS --sum and group by SELECT g.GenreName, SUM (bd.Quantity) AS 'Total Inventory' FROM BOOK_DATA bd JOIN GENRE_INTERSECTION gi ON bd.BookDataID = gi.BookDataID JOIN GENRE g ON gi.GenreID = g.GenreID WHERE bd.BookDataID = gi.BookDataID AND gi.GenreID = g.GenreID GROUP BY GenreName AvgTrans CREATE VIEW AvgTrans as SELECT CONCAT ('$',AVG(SellingPrice)) AS 'Average Transaction Amount' FROM PURCHASES ValueInventoryByPublisher CREATE VIEW ValueInventoryByPublisher AS SELECT CONCAT('$', SUM(COST * Quantity)) AS 'Value of Inventory', PublisherName AS 'Publisher Name' FROM BOOK_DATA bd JOIN Publisher p on p.PublisherID = bd.PublisherID GROUP BY PublisherName PublisherRevenuePerDay CREATE VIEW PublisherRevenuePerDay AS SELECT PublisherName as 'Publisher', sum(SellingPrice) as 'Revenue', CONVERT(date,PurchaseDateTime,10) as 'Date' FROM PUBLISHER JOIN BOOK_DATA AS BK ON PUBLISHER.PublisherID = BK.PublisherID JOIN PURCHASES AS PK ON BK.BookDataID = PK.BookDataID GROUP BY PublisherName, CONVERT(date,PurchaseDateTime,10);
  • 20. Trigger ustPrintAdmistratorCreated Occurs: After Insert Description: Prints out that an administrator was created after an administrator has been inserted.’ Code CREATE TRIGGER ustPrintAdministratorCreated ON dbo.ADMINISTRATOR AFTER INSERT AS BEGIN PRINT '******************************' PRINT 'Administrator has been created' PRINT '******************************' END;
  • 21. Stored Procedure Code /* Adds a Administrator to database*/ CREATE PROCEDURE uspAddAdministrator ( @CurrentAdministrator VARCHAR(20), @CurrentSalt VARCHAR(45), @Username VARCHAR(20), @Hash VARCHAR(45), @Salt VARCHAR(45), @AdminAccess BIT ) AS BEGIN DECLARE @RowCount INT DECLARE @AdminRowCount INT /*Check if current administrator can add a admin*/ SELECT @AdminRowCount = COUNT(*) FROM ADMINISTRATOR WHERE Username = @CurrentAdministrator AND Salt = @CurrentSalt AND AdminAccess = 1 /*Check if username already exist*/ SELECT @RowCount = COUNT(*) FROM dbo.ADMINISTRATOR WHERE Username = @Username IF @AdminRowCount = 1 IF @RowCount = 0 INSERT INTO ADMINISTRATOR(Username, [Hash], Salt, AdminAccess) VALUES (@Username, @Hash, @Salt, @AdminAccess) ELSE PRINT 'UserName Already Exists' ELSE PRINT 'Current Administrator Invalid' END
  • 22. CREATE PROCEDURE uspAddAuthor ( @AuthorName VARCHAR(20), @CurrentAdministrator VARCHAR(20), @CurrentSalt VARCHAR(45) ) AS BEGIN DECLARE @RowCount INT DECLARE @Admin BIT /*Verify the admin*/ EXEC @Admin = uspVerifyAdministrator @CurrentAdministrator, @CurrentSalt IF @Admin <> 1 PRINT 'Author not inserted' ELSE BEGIN /*See if the author name exists already*/ SELECT @RowCount = COUNT(*) FROM Author WHERE AuthorName = @AuthorName IF @RowCount = 0 INSERT INTO AUTHOR (AuthorName) VALUES (@AuthorName) ELSE PRINT 'AuthorName Already Exists' END END
  • 23. CREATE PROCEDURE uspAddAuthorToBook ( @AuthorName VARCHAR(20), @ISBN VARCHAR(13), @CurrentAdministrator VARCHAR(20), @CurrentSalt VARCHAR(45) ) AS BEGIN DECLARE @RowCount INT DECLARE @Admin BIT DECLARE @GAuthorID INT DECLARE @GBookID INT /*Verify the admin*/ EXEC @Admin = uspVerifyAdministrator @CurrentAdministrator, @CurrentSalt IF @Admin <> 1 PRINT 'Author not connected with book' ELSE BEGIN /*See if the author is already connected*/ EXEC @GAuthorID = uspGetAuthorID @AuthorName EXEC @GBookID = uspGetBookID @ISBN SELECT @RowCount = COUNT(*) FROM AUTHOR_INTERSECTION WHERE AuthorID = @GAuthorID AND BookDataID = @GBookID IF @RowCount = 0 INSERT INTO AUTHOR_INTERSECTION (AuthorID, BookDataID) VALUES (@GAuthorID, @GBookID) ELSE PRINT 'Connection already exists' END END
  • 24. CREATE PROCEDURE uspAddBookData @CurrentAdministrator VARCHAR(20), @CurrentSalt VARCHAR(45), @Name VARCHAR(45), @ISBN VARCHAR(13), @Quantity INT, @CopyrightDate DATE, @Cost NUMERIC(5,2), @PublisherName VARCHAR(30) AS BEGIN DECLARE @Admin BIT DECLARE @PublisherID INT DECLARE @Publisher BIT /*Verify the Admin*/ EXEC @Admin = uspVerifyAdministrator @CurrentAdministrator, @CurrentSalt IF @Admin <> 1 PRINT 'User does not have permission to edit' ELSE BEGIN EXEC @Publisher = uspVerifyPublisher @PublisherName IF @Publisher <> 1 PRINT 'Publisher Name is not valid' ELSE BEGIN EXEC @PublisherID = uspGetPublisherID @PublisherName INSERT INTO BOOK_DATA ( Name, ISBN, Quantity, CopyrightDate, Cost, PublisherID ) VALUES ( @Name, @ISBN, @Quantity, @CopyrightDate, @Cost, @PublisherID ) END END END;
  • 25. CREATE PROCEDURE uspAddBookToShoppingCart ( @ISBN VARCHAR(13), @Email VARCHAR(40) ) AS BEGIN Declare @previousTotal MONEY Declare @rowCount INT Declare @rowCountEmail INT Declare @ShoppingCartID INT Declare @BookDataID INT Declare @NewTotal MONEY Declare @Cost NUMERIC(5,2) Declare @FinalTotal MONEY Declare @CustomerDataID INT SELECT @rowCountEmail = COUNT (*) FROM CUSTOMER_DATA WHERE Email = @Email IF @rowCountEmail IS NULL PRINT 'The email does not exist' ELSE BEGIN SELECT @CustomerDataID = CustomerDataID FROM CUSTOMER_DATA WHERE Email = @Email /*See if customer has a shopping cart w/o date*/ /*select ShoppingCart where customerID = @CustomerID*/ SELECT @rowCount = COUNT(*) FROM SHOPPING_CART AS SC WHERE SC.CustomerDataID = @CustomerDataID AND SC.TransactionDateTime IS NULL; /*if tdt == null add one to hasShoppingCartDate*/ IF @rowCount = 1 BEGIN /*if so*/ /*Insert into transaction table ShoppingCartID and BookDateID*/ SELECT @ShoppingCartID = ShoppingCartID FROM SHOPPING_CART AS SC1 WHERE SC1.CustomerDataID = @CustomerDataID AND SC1.TransactionDateTime IS NULL; --get the book data ID SELECT @BookDataID = BookDataID FROM BOOK_DATA WHERE ISBN = @ISBN
  • 26. INSERT INTO TRANSACTIONS(ShoppingCartID,BookDataID) VALUES(@ShoppingCartID, @BookDataID) /*Update total*/ /*Grab book cost and and to total*/ SELECT @previousTotal= Total FROM SHOPPING_CART WHERE ShoppingCartID = @ShoppingCartID --get cost of the book SELECT @COST = COST FROM BOOK_DATA WHERE BookDataID = @BookDataID Select @FinalTotal = @previousTotal + @Cost /*Update the quantity of the bookdata*/ UPDATE SHOPPING_CART SET Total = @FinalTotal WHERE ShoppingCartID = @ShoppingCartID AND TransactionDateTime IS NULL; END /*if tdt != null add zero to hasShoppingCartDate*/ ELSE BEGIN /*if not*/ /*use @@IDENTITY TO GET id FROM SHOPPING CART*/ INSERT INTO SHOPPING_CART (CustomerDataID) VALUES (@CustomerDataID) SELECT @ShoppingCartID = @@IDENTITY --get the book data ID SELECT @BookDataID = BookDataID FROM BOOK_DATA WHERE ISBN = @ISBN INSERT INTO TRANSACTIONS(ShoppingCartID,BookDataID) VALUES(@ShoppingCartID, @BookDataID) --get cost of the book SELECT @COST = COST FROM BOOK_DATA WHERE BookDataID = @BookDataID UPDATE SHOPPING_CART SET Total = @Cost WHERE ShoppingCartID = @ShoppingCartID END END END
  • 27. CREATE PROCEDURE uspAddGenre ( @GenreName VARCHAR(25) ) AS BEGIN DECLARE @RowCount INT SELECT @RowCount = COUNT(*) FROM GENRE WHERE GenreName = @GenreName IF @RowCount = 0 INSERT INTO GENRE (GenreName) VALUES (@GenreName) ELSE PRINT 'GenreName Already Exists' END
  • 28. CREATE PROCEDURE uspAddGenreToBook ( @GenreName VARCHAR(30), @ISBN VARCHAR(13), @CurrentAdministrator VARCHAR(20), @CurrentSalt VARCHAR(45) ) AS BEGIN DECLARE @RowCount INT DECLARE @Admin BIT DECLARE @GgenreID INT DECLARE @GBookID INT /*Verify the Admin*/ Exec @Admin = uspVerifyAdminister (@CurrentAdministrator, @CurrentSalt) IF @ADMIN <> 1 PRINT 'Genre not connected with book' ELSE BEGIN /*See if the Genre is already connected*/ EXEC @GgenreID = uspGetGenreID @GgenreName EXEC @GBookID = uspGetBookID @ISBN SELECT @RowCount = Count(*) FROM GENRE_INTERSECTION WHERE GenreID = @GenreID AND BookDataID = @GBookID IF @RowCount = 0 INSERT INTO GENRE_INTERSECTION (GenreID, BookDataID) VALUES (@GgenreID, @GBookID) ELSE PRINT 'Connection already exists' END END;
  • 29. CREATE PROCEDURE uspAddPublisher @PubName VARCHAR(30), @PubStreet VARCHAR(30), @PubCity VARCHAR(30), @PubRegion VARCHAR(30), @PubCountry VARCHAR(30), @PubZip VARCHAR(6) AS BEGIN DECLARE @RowCount INT SELECT @RowCount = COUNT(*) FROM PUBLISHER WHERE PublisherName = @PubName IF @RowCount > 0 PRINT 'The publisher already exists in the database' ELSE INSERT INTO PUBLISHER ( PublisherName, Street, City, Region, Country, Zip ) VALUES ( @PubName, @PubStreet, @PubCity, @PubRegion, @PubCountry, @PubZip ) END;
  • 30. CREATE PROCEDURE uspAddPublisherContact @CurrentAdministrator VARCHAR(20), @CurrentSalt VARCHAR(45), @PublisherName VARCHAR(30), @ContactName VARCHAR(20), @Phone NUMERIC(11) AS BEGIN DECLARE @PublisherID INT DECLARE @Admin BIT DECLARE @Publisher BIT /*Verify the Admin*/ EXEC @Admin = uspVerifyAdministrator @CurrentAdministrator, @CurrentSalt IF @Admin <> 1 PRINT 'User does not have permission to edit' ELSE BEGIN /*Verify the publisher name*/ EXEC @Publisher = uspVerifyPublisher @PublisherName IF @Publisher <> 1 PRINT 'Publisher name is not valid' ElSE BEGIN /*Get the publisherID*/ EXEC @PublisherID = uspGetPublisherID @PublisherName INSERT INTO PUBLISHER_CONTACTS ( PublisherID, ContactName, Phone ) VALUES ( @PublisherID, @ContactName, @Phone ) END END END;
  • 31. CREATE PROCEDURE uspFinishTransaction /*get stuff*/ @Email VARCHAR(40) AS BEGIN /*create table to store shopping cart books*/ -- DECLARE @MyArray table(ShoppingCartID INT, TransactionDateTime DATETIME2, Total MONEY) DECLARE @ShoppingCartID INT DECLARE @TransactionDateTime DATETIME2 DECLARE @Total MONEY DECLARE @BookDataID INT DECLARE @Counter INT DECLARE @DiscountPercent NUMERIC(2,2) DECLARE @CustomerDataID INT DECLARE @TransactionID INT DECLARE @PreviousTransactionID INT DECLARE @Cost NUMERIC (5,2) DECLARE @Quantity INT --get the customer data ID EXEC @CustomerDataID = uspGetCustomerDataID @Email --get the shopping Cart ID SELECT @ShoppingCartID = ShoppingCartID FROM SHOPPING_CART WHERE CustomerDataID = @CustomerDataID AND TransactionDateTime IS NULL SET @Counter = 0 --count the rows that have the same customerDataID's -- count the books in the shopping cart DECLARE @RowCount INT SELECT @RowCount = COUNT(*) FROM TRANSACTIONS WHERE ShoppingCartID = @ShoppingCartID SET @TransactionDateTime = CURRENT_TIMESTAMP -- get the last transactionID of that customer where transactionDateTime is not null /* SELECT TOP 1 @PreviousTransactionID = TransactionID FROM TRANSACTIONS JOIN SHOPPING_CART ON SHOPPING_CART.ShoppingCartID = TRANSACTIONS.ShoppingCartID WHERE TRANSACTIONS.ShoppingCartID = @ShoppingCartID AND SHOPPING_CART.TransactionDateTime IS NOT NULL ORDER BY TransactionID ASC */ SET @PreviousTransactionID = 0 /*fill table*/ WHILE @Counter < @RowCount
  • 32. BEGIN SELECT TOP 1 @TransactionID = TransactionID FROM TRANSACTIONS WHERE ShoppingCartID = @ShoppingCartID AND TransactionID > @PreviousTransactionID ORDER BY TransactionID ASC SELECT @BookDataID = BookDataID FROM TRANSACTIONS WHERE TransactionID = @TransactionID -- get the price of the book SELECT @Cost = Cost FROM BOOK_DATA WHERE BookDataID = @BookDataID -- insert purchaseDateTime, sellingPrince(of book), and BookDataID into purchases INSERT INTO PURCHASES (PurchaseDateTime, SellingPrice, BookDataID) VALUES (@TransactionDateTime, @Cost, @BookDataID) SET @PreviousTransactionID = @TransactionID --decrement quantity of book by 1 SELECT @Quantity = Quantity FROM BOOK_DATA WHERE BookDataID = @BookDataID UPDATE BOOK_DATA SET Quantity = @Quantity - 1 WHERE BookDataID = @BookDataID -- increment the counter SET @Counter = @Counter + 1 END -- get the Total from ShoppingCart SELECT @Total = Total FROM SHOPPING_CART WHERE ShoppingCartID = @ShoppingCartID /*check if they are eligible for a discount*/ IF @Total > 75 BEGIN SELECT @DiscountPercent = DiscountPercent FROM DISCOUNT WHERE DiscountID = 1 IF @DiscountPercent = NULL PRINT 'No discount available' ELSE SET @Total = @Total * (1 - @DiscountPercent) END UPDATE SHOPPING_CART SET TransactionDateTime = @TransactionDateTime,
  • 33. Total = @Total WHERE ShoppingCartID = @ShoppingCartID END;
  • 34. CREATE PROCEDURE uspGetAuthorID ( @Author VARCHAR(20) ) AS BEGIN DECLARE @AuthorID INT SELECT @AuthorID = AuthorID FROM AUTHOR WHERE AuthorName = @Author IF @AuthorID = NULL BEGIN PRINT 'Author does not exist' RETURN 0 END ELSE RETURN @AuthorID END;
  • 35. CREATE PROCEDURE uspGetBookID ( @ISBN VARCHAR(13) ) AS BEGIN DECLARE @BookID INT SELECT @BookID = BookDataID FROM BOOK_DATA WHERE ISBN = @ISBN IF @BookID = NULL PRINT 'ISBN does not exist' ELSE RETURN @BookID END;
  • 36. CREATE PROCEDURE uspGetCustomerDataID @Email VARCHAR(200) AS BEGIN DECLARE @CustomerDataID INT --get the customerDataID SELECT @CustomerDataID = CustomerDataID FROM CUSTOMER_DATA WHERE Email = @Email -- if the email was not found IF @CustomerDataID = NULL PRINT 'Invalid Email' ELSE RETURN @CustomerDataID END;
  • 37. Create PROCEDURE uspGetCustomerID @Email VARCHAR(200), @CurrentSalt VARCHAR(45) AS BEGIN /*Check if email exists*/ DECLARE @CustomerID INT DECLARE @RowCount INT SELECT @CustomerID = CustomerID FROM CUSTOMER_DATA WHERE Email = @Email /*if email does not exist*/ IF @CustomerID = NULL PRINT 'The email does not exist' ELSE BEGIN /*Check that the customer salt matches with the customerID*/ SELECT @RowCount = COUNT(*) FROM CUSTOMER JOIN CUSTOMER_DATA ON CUSTOMER.CustomerID = CUSTOMER_DATA.CustomerID WHERE @CustomerID = CUSTOMER.CustomerID AND @CurrentSalt = Salt If @RowCount <> 1 PRINT 'Input invalid customer salt' ELSE RETURN @CustomerID END END;
  • 38. CREATE PROCEDURE uspGetGenreID ( @GenreName VARCHAR(30) ) AS BEGIN /*Check if the genre exists*/ DECLARE @GenreID INT SELECT @GenreID = GenreID FROM GENRE WHERE GenreName = @GenreName /*Return the genreid if the name exists*/ IF @GenreID = NULL PRINT 'Name does not exist' ELSE RETURN @GenreID END;
  • 39. CREATE PROCEDURE uspGetPublisherID ( @PublisherName VARCHAR(30) ) AS BEGIN DECLARE @PublisherID INT SELECT @PublisherID = PublisherID FROM PUBLISHER WHERE PublisherName = @PublisherName IF @PublisherID = NULL PRINT 'Name does not exist' ELSE RETURN @PublisherID END;
  • 40. CREATE PROCEDURE uspGetShoppingCartID @Email VARCHAR(200) AS BEGIN DECLARE @ShoppingCartID INT DECLARE @CustomerDataID INT EXEC @CustomerDataID = uspGetCustomerDataID @Email SELECT @ShoppingCartID = ShoppingCartID FROM SHOPPING_CART WHERE CustomerDataID = @CustomerDataID IF @ShoppingCartID = NULL PRINT 'A shoppingCartID was not found' ELSE RETURN @ShoppingCartID END;
  • 41. CREATE PROCEDURE uspRemoveBookFromShoppingCart ( @Email VARCHAR(40), @ISBN VARCHAR(13) ) AS BEGIN DECLARE @RowCount INT DECLARE @CustomerID INT DECLARE @BookDataID INT DECLARE @ShoppingCartID INT DECLARE @BookCost NUMERIC(5,2) DECLARE @OldTotal NUMERIC(5,2) DECLARE @NewTotal NUMERIC(5,2) --See if book is in shopping cart EXEC @CustomerID = uspGetCustomerDataID @Email SELECT @RowCount = COUNT(*) FROM SHOPPING_CART sc JOIN TRANSACTIONS tc ON sc.ShoppingCartID = tc.ShoppingCartID JOIN BOOK_DATA bd ON tc.BookDataID = bd.BookDataID WHERE ISBN = @ISBN AND sc.CustomerDataID = @CustomerID AND sc.TransactionDateTime IS NULL --If there is a book or books IF @RowCount > 1 BEGIN --Lower the total EXEC @ShoppingCartID = uspGetShoppingCartID @Email SELECT @BookCost = Cost FROM BOOK_DATA WHERE BookDataID = @BookDataID SELECT @OldTotal = Total FROM SHOPPING_CART WHERE ShoppingCartID = @ShoppingCartID SELECT @NewTotal = @OldTotal - @BookCost UPDATE SHOPPING_CART SET Total = @NewTotal WHERE ShoppingCartID = @ShoppingCartID AND TransactionDateTime IS NULL --Remove from transactions DELETE FROM TRANSACTIONS WHERE ShoppingCartID = @ShoppingCartID AND BookDataID = @BookDataID END ELSE BEGIN PRINT 'There is no such book in the shopping cart' END END
  • 42. CREATE PROCEDURE uspVerifyPublisher ( @PublisherName VARCHAR(30) ) AS BEGIN DECLARE @PublisherID INT SELECT @PublisherID = PublisherID FROM PUBLISHER WHERE PublisherName = @PublisherName /*If publisher is null then return 0 for false*/ IF @PublisherID = NULL Return 0 ELSE /*If publisher is not null then return 1 for true*/ Return 1 END;
  • 43. CREATE PROCEDURE uspShowPopularBooksByVolume AS BEGIN SELECT TOP 10 Name, SUM(SellingPrice) AS 'Volume Sold' FROM PURCHASES AS P JOIN BOOK_DATA AS BD ON BD.BookDataID = P.BookDataID GROUP BY Name ORDER BY SUM(SellingPrice) DESC END
  • 44. CREATE PROCEDURE uspShowPopularBooksByUnitSold AS BEGIN SELECT Name, COUNT (PURCHASES.BookDataID) AS UnitsSold FROM PURCHASES JOIN BOOK_DATA ON BOOK_DATA.BookDataID = PURCHASES.BookDataID GROUP BY Name ORDER BY UnitsSold DESC END
  • 45. CREATE PROCEDURE uspTotalRevenueTimeFrame @BeginDate DATE, @EndDate DATE AS BEGIN /*get the beginning and end dates check that beginning is earlier than end date Add all the totals between those 2 dates */ IF @BeginDate > @EndDate PRINT 'Begin Date must be earlier than End Date' ELSE SELECT SUM (SellingPrice) AS 'Total Sales During Period' FROM PURCHASES WHERE PurchaseDateTime >= @BeginDate AND PurchaseDateTime <= @EndDate END
  • 46. CREATE PROCEDURE uspUpdateAdminHashSalt @CurrentAdministrator VARCHAR(20), @CurrentSalt VARCHAR(45), @NewSalt VARCHAR(20), @NewHash VARCHAR(45) AS BEGIN DECLARE @AdminCheck BIT /*Verify the administrator*/ EXEC @AdminCheck = uspVerifyAdministrator @CurrentAdministrator, @CurrentSalt IF @AdminCheck <> 1 PRINT 'User does not have permission to edit' ELSE BEGIN /*Update the old hash and salt with the new hash and salt*/ UPDATE ADMINISTRATOR SET Hash = @NewHash, Salt = @NewSalt WHERE Username = @CurrentAdministrator END END;
  • 47. CREATE PROCEDURE uspUpdateBillingAddress @CurrentAdmin VARCHAR(20), @CurrentSalt VARCHAR(45), @Email VARCHAR(40), @Street1 VARCHAR(25), @Street2 VARCHAR(25), @City VARCHAR(25), @Zip VARCHAR(6), @Region VARCHAR(25), @Country VARCHAR(25) AS BEGIN DECLARE @Admin BIT DECLARE @EmailCount INT DECLARE @BillingAddressID INT --check that the current administrator has permission to update EXEC @Admin = uspVerifyAdministrator @CurrentAdmin, @CurrentSalt IF @Admin <> 1 PRINT 'User does not have permission to edit' ELSE BEGIN --Verify the email SELECT @EmailCount = COUNT(*) FROM CUSTOMER_DATA WHERE Email = @Email IF @EmailCount < 1 PRINT 'The email does not exist' ELSE BEGIN --get the BillingAdressID SELECT @BillingAddressID = BillingAddressID FROM CUSTOMER_DATA WHERE Email = @Email UPDATE BILLING_ADDRESS SET Street = @Street1, Street2 = @Street2, City = @City, Zip = @Zip, Region = @Region, Country = @Country WHERE BillingAddressID = @BillingAddressID END END END;
  • 48. CREATE PROCEDURE uspUpdateBookInformation @CurrentAdmin VARCHAR(20), @CurrentSalt VARCHAR(40), @ISBN VARCHAR(13), @Name VARCHAR(45), @NewISBN VARCHAR(13), @Quantity INT, @CopyrightDate DATE, @Cost NUMERIC(5,2) AS BEGIN DECLARE @Admin BIT DECLARE @ISBNCount INT DECLARE @BookDataID INT --check that the current administrator has permission to update EXEC @Admin = uspVerifyAdministrator @CurrentAdmin, @CurrentSalt IF @Admin <> 1 PRINT 'User does not have permission to edit' ELSE BEGIN --check that the ISBN exists in the table SELECT @ISBNCount = COUNT(*) FROM BOOK_DATA WHERE ISBN = @ISBN IF @ISBNCount < 1 PRINT 'The ISBN does not exist in the table' ELSE BEGIN --get bookDataID SELECT @BookDataID = BookDataID FROM BOOK_DATA WHERE ISBN = @ISBN --insert new information UPDATE BOOK_DATA SET Name = @Name, ISBN = @NewISBN, Quantity = @Quantity, CopyrightDate = @CopyrightDate, Cost = @Cost WHERE BookDataID = @BookDataID END END END;
  • 49. CREATE PROCEDURE uspUpdateCustomerHashSalt @CurrentAdministrator VARCHAR(20), @CurrentSalt VARCHAR(45), @Email VARCHAR(30), @NewCustomerSalt VARCHAR(45), @NewCustomerHash VARCHAR(45) AS BEGIN DECLARE @AdminCheck BIT DECLARE @CustomerID INT /*Verify the administrator*/ EXEC @AdminCheck = uspVerifyAdministrator @CurrentAdministrator, @CurrentSalt IF @AdminCheck <> 1 PRINT 'User does not have permission to edit' ELSE BEGIN EXEC @CustomerID = uspGetCustomerID @CurrentSalt, @Email /*Update the old customer hash and salt with the new hash and salt*/ UPDATE CUSTOMER SET Hash = @NewCustomerHash, Salt = @NewCustomerSalt WHERE CustomerID = @CustomerID END END;
  • 50. CREATE procedure uspUpdateCustomerEmail ( @CurrentAdministrator Varchar(20), @AdminSalt Varchar(45), @CurrentSalt Varchar(45), @Email varchar(200), @NewEmail varchar(30) ) AS BEGIN DECLARE @CurrentAdmin int /*Check to see if user is admin*/ DECLARE @AdminCheck BIT DECLARE @CustomerID INT /*Verify the administrator*/ EXEC @AdminCheck = uspVerifyAdministrator @CurrentAdministrator, @AdminSalt IF @AdminCheck <> 1 PRINT 'User does not have permission to edit' ELSE /*If user is admin*/ BEGIN EXEC @CustomerID = uspGetCustomerID @Email,@CurrentSalt /*Update the old customer email*/ UPDATE CUSTOMER_DATA SET Email = @NewEmail WHERE CustomerID = @CustomerID END END;
  • 51. CREATE PROCEDURE uspUpdateCustomerInformation @CurrentAdmin VARCHAR(20), @CurrentSalt VARCHAR(45), @Email VARCHAR(40), @FirstName VARCHAR(25), @LastName VARCHAR(25), @Age INT, @Gender CHAR(1), @NewEmail VARCHAR(40), @HomePhone VARCHAR(15), @WorkPhone VARCHAR(15) AS BEGIN DECLARE @Admin BIT DECLARE @EmailCount INT DECLARE @CustomerDataID INT --check that the current administrator has permission to update EXEC @Admin = uspVerifyAdministrator @CurrentAdmin, @CurrentSalt IF @Admin <> 1 PRINT 'User does not have permission to edit' ELSE BEGIN --Verify the email SELECT @EmailCount = COUNT(*) FROM CUSTOMER_DATA WHERE Email = @Email IF @EmailCount < 1 PRINT 'The email does not exist' ELSE BEGIN --get customerDataID SELECT @CustomerDataID = CustomerDataID FROM CUSTOMER_DATA WHERE Email = @Email UPDATE CUSTOMER_DATA SET FirstName = @FirstName, LastName = @LastName, Age = @Age, Gender = @Gender, Email = @NewEmail, HomePhone = @HomePhone, WorkPhone = @WorkPhone WHERE CustomerDataID = @CustomerDataID END END END;
  • 52. CREATE PROCEDURE uspUpdateShippingAddress @CurrentAdmin VARCHAR(20), @CurrentSalt VARCHAR(45), @Email VARCHAR(40), @Street1 VARCHAR(25), @Street2 VARCHAR(25), @City VARCHAR(25), @Zip VARCHAR(6), @Region VARCHAR(25), @Country VARCHAR(25) AS BEGIN DECLARE @Admin BIT DECLARE @EmailCount INT DECLARE @ShippingAddressID INT --check that the current administrator has permission to update EXEC @Admin = uspVerifyAdministrator @CurrentAdmin, @CurrentSalt IF @Admin <> 1 PRINT 'User does not have permission to edit' ELSE BEGIN --Verify the email SELECT @EmailCount = COUNT(*) FROM CUSTOMER_DATA WHERE Email = @Email IF @EmailCount < 1 PRINT 'The email does not exist' ELSE BEGIN --get the shippingAddressID SELECT @ShippingAddressID = ShippingAddressID FROM CUSTOMER_DATA WHERE Email = @Email UPDATE SHIPPING_ADDRESS SET Street = @Street1, Street2 = @Street2, City = @City, Zip = @Zip, Region = @Region, Country = @Country WHERE ShippingAddressID = @ShippingAddressID END END END;
  • 53. CREATE PROCEDURE uspUpdateAdminAccess ( @CurrentAdministrator VARCHAR(45), @CurrentSalt VARCHAR(45), @UserStatusChange VARCHAR(45), @ChangeAccess bit ) AS BEGIN DECLARE @AdminCheck BIT /*See if current user is an admin*/ EXEC @AdminCheck = uspVerifyAdministrator @CurrentAdministrator, @CurrentSalt IF @AdminCheck <> 1 PRINT 'User does not have permission to edit' ELSE BEGIN UPDATE ADMINISTRATOR SET AdminAccess = @ChangeAccess WHERE UserName = @UserStatusChange END END
  • 54. Table Creation Code CREATE TABLE ADMINISTRATOR ( AdministratorID INT NOT NULL IDENTITY (1000,1), Username VARCHAR(20) NOT NULL, Hash VARCHAR(45) NOT NULL, Salt VARCHAR(45) NOT NULL, AdminAccess BIT NOT NULL, CONSTRAINT Admin_PK PRIMARY KEY(AdminID) ); CREATE TABLE DISCOUNT ( DiscountID INT NOT NULL IDENTITY (1,1), Name VARCHAR(25) NOT NULL, DiscountPercent NUMERIC(2,3) NOT NULL, CONSTRAINT Discount_PK PRIMARY KEY(DiscountID) ); CREATE TABLE CUSTOMER ( CustomerID INT NOT NULL IDENTITY(1000,1), Hash VARCHAR(45) NOT NULL, Salt VARCHAR(45) NOT NULL, CONSTRAINT Customer_PK PRIMARY KEY(CustomerID) ); CREATE TABLE AUTHOR_INTERSECTION ( AuthorID INT NOT NULL, BookDataID INT NOT NULL, CONSTRAINT AInter_PK PRIMARY KEY(AuthorID, BookDataID) ); CREATE TABLE AUTHOR ( AuthorID INT NOT NULL IDENTITY (1000,1), AuthorName VARCHAR(20) NOT NULL, CONSTRAINT Author_PK PRIMARY KEY(AuthorID) ); CREATE TABLE BILLING_ADDRESS ( BillingAddressID INT NOT NULL IDENTITY (1000,1), Street VARCHAR(25) NOT NULL, Street2 VARCHAR(25) NULL, City VARCHAR(25) NOT NULL, Zip VARCHAR(6) NULL, Region VARCHAR(25) NOT NULL, Country VARCHAR(25) NOT NULL, CONSTRAINT Billing_PK PRIMARY KEY(BillingAddressID), CONSTRAINT Region_check CHECK(Region='Alabama' or Region='Alaska' or Region='Arizona' or Region='California' or Region='Colorado' or Region='Connecticut' or Region='Delaware' or Region='Florida' or Region='Georgia' or Region='Hawaii' or Region='Idaho' or Region='Illinois' or Region='Indiana' or Region='Iowa' or Region='Kansas' or Region='Kentucky' or Region='Louisiana' or Region='Maine' or Region='Maryland' or Region='Massachusetts' or Region='Michigan' or Region='Minnesota' or Region='Mississippi' or Region='Missouri' or Region='Montana' or Region='Nebraska' or Region='Nevada' or Region='New Hampshire' or Region='New Jersey' or Region='New Mexico' or Region='New York' or Region='North Carolina' or Region='North Dakota' or Region='Ohio' or Region='Oklahoma' or Region='Oregon' or Region='Pennsylvania' or Region='Rhode Island' or Region='South Carolina' or Region='South Dakota' or Region='Tennessee' or
  • 55. Region='Texas' or Region='Utah' or Region='Vermont' or Region='Virginia' or Region='Washington' or Region='West Virginia' or Region='Wisconsin' or Region='Wyoming' or Region='Pacific Coast' or Region='Gulf of Mexico' or Region='Baja' or Region='Central' or Region='Northern' or Region='Alberta' or Region='British Columbia' or Region='Manitoba' or Region='New Brunswick' or Region='Newfoundland and labrador' or Region='Northwest Territories' or Region='Nova Scotia' or Region='Nunavut' or Region='Ontario' or Region='Prince Edward Island' or Region='Quebec' or Region='Saskatchewan' or Region='Yukon'), CONSTRAINT Country_Check Check(Country='United States' or Country='Mexico' or Country='Canada') ); CREATE TABLE CUSTOMER_DATA ( CustomerDataID INT NOT NULL IDENTITY(1000,1), CustomerID INT NOT NULL, BillingAddressID INT NOT NULL, ShippingAddressID INT NOT NULL, ShoppingCartID INT NOT NULL, CreditCardID INT NOT NULL, FirstName VARCHAR(25) NOT NULL, LastName VARCHAR(25) NOT NULL, Age INT NOT NULL, Gender CHAR(1) NOT NULL, EMail VARCHAR(40) NOT NULL, HomePhone VARCHAR(15) NOT NULL, WorkPhone VARCHAR(15) NULL, CONSTRAINT CustomerData_PK PRIMARY KEY(CustomerDataID), CONSTRAINT CustomerID_FK FOREIGN KEY(CustomerID) REFERENCES CUSTOMER(CustomerID), CONSTRAINT BillingAddressID_FK FOREIGN KEY(BillingAddressID) REFERENCES BILLING_ADDRESS(BillingAddressID), CONSTRAINT ShippingAddressID_FK FOREIGN KEY(ShippingAddressID) REFERENCES SHIPPING_ADDRESS(ShoppingAddressID), CONSTRAINT ShoppingCartID_FK FOREIGN KEY(ShoppingCartID) REFERENCES SHOPPING_CART(ShoppingCartID), CONSTRAINT CreditCardID_FK FOREIGN KEY(CreditCardID) REFERENCES CREDIT_CARD(CreditCardID), CONSTRAINT Gender_check Check ('U' or 'F' or 'M' ) ); CREATE TABLE SHIPPING_ADDRESS ( ShippingAddressID INT NOT NULL IDENTITY(1000,1), Street VARCHAR(25) NOT NULL, Street2 VARCHAR(20) NULL, City VARCHAR(25) NOT NULL, Zip VARCHAR(5) NULL, Region VARCHAR(25) NOT NULL, Country VARCHAR(25) NOT NULL, CONSTRAINT ship_address_pk PRIMARY KEY(shippingAddressID), CONSTRAINT Region_check CHECK(Region='Alabama' or Region='Alaska' or Region='Arkansas' or Region='Arizona' or Region='California' or Region='Colorado' or Region='Connecticut' or Region='Delaware' or Region='Florida' or Region='Georgia' or Region='Hawaii' or Region='Idaho' or Region='Illinois' or Region='Indiana' or Region='Iowa' or Region='Kansas' or Region='Kentucky' or Region='Louisiana' or Region='Maine' or Region='Maryland' or Region='Massachusetts' or Region='Michigan' or Region='Minnesota' or Region='Mississippi' or Region='Missouri' or Region='Montana' or Region='Nebraska' or Region='Nevada' or Region='New Hampshire' or Region='New Jersey' or
  • 56. Region='New Mexico' or Region='New York' or Region='North Carolina' or Region='North Dakota' or Region='Ohio' or Region='Oklahoma' or Region='Oregon' or Region='Pennsylvania' or Region='Rhode Island' or Region='South Carolina' or Region='South Dakota' or Region='Tennessee' or Region='Texas' or Region='Utah' or Region='Vermont' or Region='Virginia' or Region='Washington' or Region='West Virginia' or Region='Wisconsin' or Region='Wyoming' or Region='Pacific Coast' or Region='Gulf of Mexico' or Region='Baja' or Region='Central' or Region='Northern' or Region='Alberta' or Region='British Columbia' or Region='Manitoba' or Region='New Brunswick' or Region='Newfoundland and labrador' or Region='Northwest Territories' or Region='Nova Scotia' or Region='Nunavut' or Region='Ontario' or Region='Prince Edward Island' or Region='Quebec' or Region='Saskatchewan' or Region='Yukon'), CONSTRAINT Country_Check Check('United States' or 'Mexico' or 'Canada') ); CREATE TABLE PURCHASES ( PurchaseID INT NOT NULL IDENTITY(1000,1), BookDataID INT NOT NULL, PurchaseDateTime DATETIME2 NOT NULL, SellingPrice Money NOT NULL, Constraint Purchase_PK PRIMARY KEY(PurchaseID), Constraint Book_Data_FK FOREIGN KEY(BookDataID) ); CREATE TABLE BOOK_DATA ( BookDataID INT NOT NULL IDENTITY(1000,1), PublisherID INT NOT NULL, Name VARCHAR(25) NOT NULL, ISBN VARCHAR(13) NOT NULL, Quantity INT NOT NULL, CopyrightDate DATE NULL, Cost NUMERIC(5,2) NOT NULL, Constraint BookData_PK PRIMARY KEY(BookDataID), Constraint Author_FK FOREIGN KEY(AuthorID) REFERENCES AUTHOR (AuthorID), Constraint Publisher_FK FOREIGN KEY(PublisherID)REFERENCES PUBLISHER (PublisherID), Constraint Genre_FK FOREIGN KEY(GenreID)REFERENCES GENRE (GenreID), Constraint Cost_Check CHECK (COST >= 0) ); CREATE TABLE PUBLISHER ( PublisherID INT NOT NULL IDENTITY(1000,1), PublisherName VARCHAR(30) NOT NULL, Street VARCHAR(30) NOT NULL, City VARCHAR(30) NOT NULL, Region VARCHAR(25) NOT NULL, Country VARCHAR(25) NOT NULL, Zip VARCHAR(6) NULL, CONSTRAINT Publisher_PK PRIMARY KEY(PublisherID), CONSTRAINT Region_check CHECK(Region='Alabama' or Region='Alaska' or Region='Arkansas' or Region='Arizona' or Region='California' or Region='Colorado' or Region='Connecticut' or Region='Delaware' or Region='Florida' or Region='Georgia' or Region='Hawaii' or Region='Idaho' or Region='Illinois' or Region='Indiana' or Region='Iowa' or Region='Kansas' or Region='Kentucky' or Region='Louisiana' or Region='Maine' or Region='Maryland' or Region='Massachusetts' or Region='Michigan' or Region='Minnesota' or Region='Mississippi' or Region='Missouri' or Region='Montana' or Region='Nebraska' or Region='Nevada' or Region='New Hampshire' or Region='New Jersey' or
  • 57. Region='New Mexico' or Region='New York' or Region='North Carolina' or Region='North Dakota' or Region='Ohio' or Region='Oklahoma' or Region='Oregon' or Region='Pennsylvania' or Region='Rhode Island' or Region='South Carolina' or Region='South Dakota' or Region='Tennessee' or Region='Texas' or Region='Utah' or Region='Vermont' or Region='Virginia' or Region='Washington' or Region='West Virginia' or Region='Wisconsin' or Region='Wyoming' or Region='Pacific Coast' or Region='Gulf of Mexico' or Region='Baja' or Region='Central' or Region='Northern' or Region='Alberta' or Region='British Columbia' or Region='Manitoba' or Region='New Brunswick' or Region='Newfoundland and labrador' or Region='Northwest Territories' or Region='Nova Scotia' or Region='Nunavut' or Region='Ontario' or Region='Prince Edward Island' or Region='Quebec' or Region='Saskatchewan' or Region='Yukon'), CONSTRAINT Country_Check Check(Country='United States' or Country='Mexico' or Country='Canada') ); CREATE TABLE PUBLISHER_CONTACTS ( ContactID INT NOT NULL IDENTITY(1000,1), PublisherID INT NOT NULL, ContactName VARCHAR(20) NULL, Phone NUMERIC(11) NULL, CONSTRAINT PublisherCON_PK PRIMARY KEY(ContactID), CONSTRAINT PublisherID_FK FOREIGN KEY (PublisherID)REFERENCES PUBLISHER(PublisherID) ); CREATE TABLE CREDIT_CARD ( CreditCardID INT NOT NULL IDENTITY(1000,1), Name VARCHAR(25) NOT NULL, ExpirationDate DATETIME2(4) NOT NULL, CreditCardNumber NUMERIC(16) NOT NULL, CreditCardType VARCHAR(25) NOT NULL, SecurityCode INT NOT NULL, CONSTRAINT CreditCardID_PK PRIMARY KEY(CreditCardID), CONSTRAINT CardType_Check CHECK(CreditCardType = 'VISA' OR CreditCardType ='American Express' OR CreditCardType ='MasterCard' OR CreditCardType ='Discover'), ); CREATE TABLE SHOPPING CART ( ShoppingCartID INT NOT NULL IDENTITY(1000,1), CustomerDataID INT NOT NULL, TransactionDateTime DATETIME2 NULL, Total MONEY NULL, CONSTRAINT ShoppingCartID_PK PRIMARY KEY(ShoppingCartID), CONSTRAINT TransactionID_FK FOREIGN KEY(TransactionID) REFERENCES TRANSACTIONS(TransactionID), CONSTRAINT CustomerDataID_FK FOREIGN KEY(CustomerDataID) REFERENCES CUSTOMER_DATA(CustomerDataID), ); CREATE TABLE TRANSACTIONS ( TransactionID INT NOT NULL IDENTITY(1000,1), ShoppingCartID INT NOT NULL, BookDataID INT NOT NULL, CONSTRAINT TransactionID_PK PRIMARY KEY(TransactionID), CONSTRAINT ShoppingCartID_FK FOREIGN KEY(ShoppingCartID) REFERENCES SHOPPING_CART(ShoppingCartID), CONSTRAINT BookDataID_FK FOREIGN KEY(BookDataID) REFERENCES BOOK_DATA (BookDataID)
  • 58. ); CREATE TABLE GENRE_INTERSECTION ( GenreID INT NOT NULL, BookDataID INT NOT NULL, CONSTRAINT GenreID_BookDataID_PK PRIMARY KEY(GenreID, BookDataID) ); CREATE TABLE GENRE ( GenreID INT NOT NULL IDENTITY(1000,1), GenreName VARCHAR(25) NULL, CONSTRAINT GenreID_PK PRIMARY KEY(GenreID) ); ALTER TABLE GENRE_INTERSECTION ADD FOREIGN KEY (GenreID) REFERENCES GENRE(GenreID); ALTER TABLE GENRE_INTERSECTION ADD FOREIGN KEY (BookDataID) REFERENCES BOOK_DATA(BookDataID); ALTER TABLE AUTHOR_INTERSECTION ADD FOREIGN KEY (BookDataID) REFERENCES BOOK_DATA(BookDataID); ALTER TABLE AUTHOR_INTERSECTION ADD FOREIGN KEY (AuthorID) REFERENCES AUTHOR(AuthorID);
  • 59. Execute/Insert Statements Insert Genre EXEC uspAddGenre 'Computer Science'; EXEC uspAddGenre 'Classic'; EXEC uspAddGenre 'Comic'; EXEC uspAddGenre 'Crime'; EXEC uspAddGenre 'Fable'; EXEC uspAddGenre 'Fairy Tale'; EXEC uspAddGenre 'Christian'; EXEC uspAddGenre 'Christian Fiction'; EXEC uspAddGenre 'Fantasy'; EXEC uspAddGenre 'Historical Fiction'; EXEC uspAddGenre 'Horror'; EXEC uspAddGenre 'Legend'; EXEC uspAddGenre 'Mystery'; EXEC uspAddGenre 'Science Fiction'; EXEC uspAddGenre 'Short Story'; EXEC uspAddGenre 'Thriller'; EXEC uspAddGenre 'Tall Tale'; EXEC uspAddGenre 'Western'; EXEC uspAddGenre 'Autobiography'; EXEC uspAddGenre 'Biography'; EXEC uspAddGenre 'Essay'; EXEC uspAddGenre 'Textbook'; EXEC uspAddGenre 'Mathematics'; EXEC uspAddGenre 'Reference'; EXEC uspAddGenre 'Childrens'; EXEC uspAddGenre 'Womens Fiction';
  • 60. Insert Book_data exec uspAddBookData 'Zach','25604dc1079c9137d26925da85a22b6b','Forgotten Snake','9781234567897',21,'10-27- 1993','33','Andrews McMeel'; exec uspAddBookData 'Zach','25604dc1079c9137d26925da85a22b6b','The Hot Streams','1990259367631',10,'2/29/2000','2','Andrews McMeel'; exec uspAddBookData 'Zach','25604dc1079c9137d26925da85a22b6b','Men of Sorcerer','0445986518916',213,'5/12/2000','34','Andrews McMeel'; exec uspAddBookData 'Zach','25604dc1079c9137d26925da85a22b6b','The Voyages Shard','7374569404550',344,'5/30/2001','12','Andrews McMeel'; exec uspAddBookData 'Zach','25604dc1079c9137d26925da85a22b6b','The Stone of the Word','8744533136741',22,'6/21/2001','10','Andrews McMeel'; exec uspAddBookData 'Zach','25604dc1079c9137d26925da85a22b6b','Child in the Tears','7650816020495',66,'7/9/2002','32','Andrews McMeel'; exec uspAddBookData 'Zach','25604dc1079c9137d26925da85a22b6b','Last Children','1884709673002',77,'6/29/2004','12','Andrews McMeel'; exec uspAddBookData 'Zach','25604dc1079c9137d26925da85a22b6b','The Bold Stars','8445987218589',212,'12/22/2005','14','Andrews McMeel'; exec uspAddBookData 'Zach','25604dc1079c9137d26925da85a22b6b','Dying of Someone','1099727848738',212,'2/16/2006','15','Andrews McMeel'; exec uspAddBookData 'Zach','25604dc1079c9137d26925da85a22b6b','The Ships Obsession','9474622227365',211,'5/10/2006','23','Andrews McMeel'; exec uspAddBookData 'Zach','25604dc1079c9137d26925da85a22b6b','The Years of the Witches','8441155925360',32,'5/12/2006','21','Andrews McMeel'; exec uspAddBookData 'Zach','25604dc1079c9137d26925da85a22b6b','Boy in the Dreamer','5813272132446',45,'8/7/2006','32','Andrews McMeel'; exec uspAddBookData 'Zach','25604dc1079c9137d26925da85a22b6b','Cracked Willow','1609190566464',23,'10/4/2006','45','Andrews McMeel'; exec uspAddBookData 'Zach','25604dc1079c9137d26925da85a22b6b','The Hot Waves','2135040972828',254,'2/16/2007','12','Andrews McMeel'; exec uspAddBookData 'Zach','25604dc1079c9137d26925da85a22b6b','Bridge of Women','8668364422722',153,'2/27/2007','32','Andrews McMeel'; exec uspAddBookData 'Zach','25604dc1079c9137d26925da85a22b6b','The Snakes Spark','0090060335185',22,'10-27- 1993','45','Andrews McMeel'; exec uspAddBookData 'Zach','25604dc1079c9137d26925da85a22b6b','The Roses of the Swords','9781234567897',67,'12/10/2007','11','Andrews McMeel'; exec uspAddBookData 'Zach','25604dc1079c9137d26925da85a22b6b','Dreamer in the Dreams','9419905884520',1,'8/11/2008','16','Andrews McMeel'; exec uspAddBookData
  • 61. 'Zach','25604dc1079c9137d26925da85a22b6b','Only Emerald','0162911639327',232,'11/11/2008','32','Andrews McMeel'; exec uspAddBookData 'Zach','25604dc1079c9137d26925da85a22b6b','The Final Destruction','4659766372122',243,'1/28/2011','15','Andrews McMeel'; exec uspAddBookData 'Zach','25604dc1079c9137d26925da85a22b6b','Dream of Touch','7962192512153',67,'8/29/2011','32','Andrews McMeel'; exec uspAddBookData 'Zach','25604dc1079c9137d26925da85a22b6b','The Lordss Lights','2879060597570',99,'12/8/2011','29','Andrews McMeel'; exec uspAddBookData 'Zach','25604dc1079c9137d26925da85a22b6b','The Boyfriend of the Secrets','1888859649381',787,'3/19/2013','13','Andrews McMeel'; exec uspAddBookData 'Zach','25604dc1079c9137d26925da85a22b6b','Willow in the Husband','0272223960105',245,'3/4/2014','12','Andrews McMeel'; exec uspAddBookData 'Zach','25604dc1079c9137d26925da85a22b6b','Trembling Dying','3190084542284',342,'12/2/2014','12','Andrews McMeel'; Insert Author exec uspAddAuthor 'Joan Griffith','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthor 'Johanna Allison','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthor 'Rick Andrews','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthor 'Glenda Greer','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthor 'Sadie Holloway','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthor 'Lee Sanchez','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthor 'Ann Mack','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthor 'Marion Chavez','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthor 'Lucas Salazar','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthor 'Edmund Bridges','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthor 'Anita Berry','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthor 'Sophia Lyons','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthor 'Kathaleen Anthony','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthor 'Arlena Ashcraft','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthor 'Blossom Lenz','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthor 'Richelle Hindman','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthor 'Carmine Ives','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthor 'Janita Hamrick','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthor 'Elina Koonce','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthor 'Arianna Minor','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthor 'Minna Couture','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthor 'Bari Sanborn','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthor 'Marcela Brinkman','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthor 'Tamar Ferrara','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthor 'Tonita Jefferies','Zach','25604dc1079c9137d26925da85a22b6b';
  • 62. Insert AuthorToBook exec uspAddAuthorToBook 'Joan Griffith','9781234567897','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthorToBook 'Johanna Allison','1990259367631','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthorToBook 'Rick Andrews','0445986518916','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthorToBook 'Glenda Greer','7374569404550','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthorToBook 'Sadie Holloway','8744533136741','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthorToBook 'Lee Sanchez','7650816020495','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthorToBook 'Ann Mack','1884709673002','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthorToBook 'Marion Chavez','8445987218589','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthorToBook 'Lucas Salazar','1099727848738','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthorToBook 'Edmund Bridges','9474622227365','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthorToBook 'Anita Berry','8441155925360','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthorToBook 'Sophia Lyons','5813272132446','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthorToBook 'Kathaleen Anthony','1609190566464','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthorToBook 'Arlena Ashcraft','2135040972828','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthorToBook 'Blossom Lenz','8668364422722','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthorToBook 'Richelle Hindman','0090060335185','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthorToBook 'Carmine Ives','9781234567897','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthorToBook 'Janita Hamrick','9419905884520','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthorToBook 'Elina Koonce','0162911639327','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthorToBook 'Arianna Minor','4659766372122','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthorToBook 'Minna Couture','7962192512153','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthorToBook 'Bari Sanborn','2879060597570','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthorToBook 'Marcela Brinkman','1888859649381','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthorToBook 'Tamar Ferrara','0272223960105','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddAuthorToBook 'Tonita Jefferies','3190084542284','Zach','25604dc1079c9137d26925da85a22b6b';
  • 63. Insert AddGenreToBook exec uspAddGenreToBook 'Horror','9781234567897','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddGenreToBook 'Legend','1990259367631','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddGenreToBook 'Historical Fiction','0445986518916','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddGenreToBook 'Christian','7374569404550','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddGenreToBook 'Christian Fiction','8744533136741','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddGenreToBook 'Fairy Tale','7650816020495','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddGenreToBook 'Fable','1884709673002','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddGenreToBook 'Thriller','8445987218589','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddGenreToBook 'Tall Tale','1099727848738','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddGenreToBook 'Western','9474622227365','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddGenreToBook 'AutoBiography','8441155925360','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddGenreToBook 'Essay','5813272132446','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddGenreToBook 'Textbook','1609190566464','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddGenreToBook 'Mathematics','2135040972828','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddGenreToBook 'Reference','8668364422722','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddGenreToBook 'Childrens','0090060335185','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddGenreToBook 'Womens Fiction','9781234567897','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddGenreToBook 'Fantasy','9419905884520','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddGenreToBook 'Computer Science','0162911639327','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddGenreToBook 'Classic','4659766372122','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddGenreToBook 'Comic','7962192512153','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddGenreToBook 'Crime','2879060597570','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddGenreToBook 'Fable','1888859649381','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddGenreToBook 'Fantasy','0272223960105','Zach','25604dc1079c9137d26925da85a22b6b'; exec uspAddGenreToBook 'Legend','3190084542284','Zach','25604dc1079c9137d26925da85a22b6b';
  • 64. Insert CustomerData exec uspAddCustomer '3aeb68512873517780de26e7d5c2c797','f74373bfb971478ff39bbc2f63e23738','2521 Foggy Quay','none','Smacker','06271', 'Connecticut','United States','Kaitlin Gonzales','2016-01- 01','bdbc5e32c5093be0c980fd5bf44f07f3','Visa', '8bbff5ca15840b768e54d0af6dcbe923','2521 Foggy Quay','none','Smacker','06271','Connecticut','United States', 'Kaitlin','Gonzales',21,'F','TheSupremeProgrammer@gmail.com','8330029333','8557295452' exec uspAddCustomer '7a910465674a172f8d2bda6ebd0fef13','806d6f4364da918d09a9d0a78a8a7003','1485 Rustic Island','none','Elk Point', '74341','Oklahoma','United States','Reba Johns','12/01/2016','bdbc5e32c5093be0c980fd5bf44f07f3','Visa', '6c6bf61764f0ebc6e7963f0f97e263ad','1485 Rustic Island','none','Elk Point','74341','Oklahoma','United States', 'Reba','Johns',34,'F','duraku@hotmail.com','8995139294','8995906995'; exec uspAddCustomer '7a910465674a172f8d2bda6ebd0fef13','806d6f4364da918d09a9d0a78a8a7003','1485 Rustic Island','none','Elk Point', '74341','Oklahoma','United States','Reba Johns','12/01/2016','bdbc5e32c5093be0c980fd5bf44f07f3','Visa', '6c6bf61764f0ebc6e7963f0f97e263ad','1485 Rustic Island','none','Elk Point','74341','Oklahoma','United States', 'Reba','Johns',34,'F','duraku@hotmail.com','8995139294','8995906995'; exec uspAddCustomer '50a0e3908bfe7aab476e8ff239aa8f46','5e68b18886ea516c4157a8bff3ae14e1','1198 Easy Concession','none','Half Day', '64483','Missouri','United States','Francis Winters','5/01/2018','540c729845d43a49dcc3b3cdb4030f48','Visa', 'fdeae4c723b97cad80bd0068de4f850a','1198 Easy Concession','none','Half Day','64483','Missouri','United States', 'Francis','Winters',24,'M','cichon@yahoo.com','8330834977','8332498010'; exec uspAddCustomer '59fb2bb4a6394193c861d83d5dad3eec','88e632b10bffef59036ab9d4eaf8d415','4027 Green Key','none','Spackenkill', '74386','Oklahoma','United States','Daryl Burt','2/01/2017','8a3d8fa5561018d0226c28109aeeb4f5','Visa', '53f43e021295e1e573d0bc1f25ee83f8','4027 Green Key','none','Spackenkill','74386','Oklahoma','United States','Daryl', 'Burt','67',M,'quastad@gmail.com','8442141998','8114419861'; exec uspAddCustomer '1a329016def2b1cbe3464f096e23883b','9b7edb63f3524969bdb89a3509a70952','3580 Stony Zephyr Via','none','Hog Back', '64109','Missouri','United States','Dana Marsh','3/01/2016','852a392b297e3f25e082401a24eb014c','MasterCard', 'ae4f856688cb91a255afa4695745cbba','3580 Stony Zephyr Via','none','Hog Back','64109','Missouri','United States', 'Dana','Marsh',65,'F','ewton@rocketmail.com','8999002333','8554494340'; exec uspAddCustomer '82a02ea479d46a709507e88fdd30b51c','be6eeda2f9c517a011138ad921e83a48','5978 Velvet Grove','none','Montague', '44189','Ohio','United States','Mindi Andrews','10/01/2017','4e40386beae17a6dce432c3970f6f3a4','MasterCard', '2e997169635e3ba4fd9e51017a34daa1','5978 Velvet Grove','none','Montague','44189','Ohio','United States','Mindi', 'Andrews',45,'F','ewton@gmail.com','8115698543','8338113644';
  • 65. exec uspAddCustomer 'c7f11753b8b15ca9349774b564fdc3d6','d84e4aed20d6a4065fc95c420a4f53cf','6873 Silver Circle','none','Trojan', '56485','Minnesota','United States','Teddy Howe','11/01/2016','fcfcd793f55d8c55ba24c9ad6baa9fba','MasterCard', '07da5ae6ef692ac3f2867ad5f383d1d9','6873 Silver Circle','none','Trojan','56485','Minnesota','United States', 'Teddy','Howe',88,'M','lineman@outlook.com','8332702587','8339949158'; exec uspAddCustomer '772cca0799a1d81bef8ec25feb752235','e3aae19a4883ef6cf99afa3d102bfb2a','268 Dewy Fawn Limits','none','Asylum', '64229','Missouri','United States','Lynne Man','8/01/2016','ca610302309c3aec8cad43ebb0258a06','MasterCard', 'd2eb358097c89edce0549f4914436d3f','268 Dewy Fawn Limits','none','Asylum','64229','Missouri','United States', 'Lynne','Man',56,'F','knape@rocketmail.com','8229199079','8330059665'; exec uspAddCustomer 'f3f08106d7435e850892ddb924c36ef4','d9cf20819661467e71c50940b3874842','8572 Iron Bear Cape','none','Hampton', '44661','Ohio','United States','Thomas Klein','7/01/2017','eb6ba83fab3d29a405d3b8198174102c','American Express', '46cb321738b4ca43df57f1ed95acda2d','8572 Iron Bear Cape','none','Hampton','44661','Ohio','United States','Thomas', 'Klein',26,'M','younger@hotmail.com','8997921351','8337794237'; exec uspAddCustomer 'd906346ea26c1afe021cbd679e5bf497','5d360c0be0e6f6b6c649edec6c8f1ee8','9593 Emerald Parade','none','Baptist', '43797','Ohio','United States','Shirley Herrera','6/01/2017','4c82d70cea65cef6613877a99b377470','American Express', '995bad8eab9179020182e534aa7d15a8','9593 Emerald Parade','none','Baptist','43797','Ohio','United States','Shirley', 'Herrera',90,'F','means@hotmail.com','8112178503','8227611128'; exec uspAddCustomer 'a340ddccff49cf444671ea54042ee853','18d12cf3c0a8a451e0aa7f9f71119eda','5562 Amber Heights','none','Scotland', '56300','Minnesota','United States','Deon Doyle','4/01/2016','31cce9ba84673d591a676d6cd35a1b5c','American Express', 'd4c27c37d7bc600779bf6f1f7957f76c','5562 Amber Heights','none','Scotland','56300','Minnesota','United States','Deon', 'Doyle',41,'F','brooks@yahoo.com','8118403281','8991303988'; exec uspAddCustomer '627af38cf458d13a507074dfaef9de96','c63f8f63590bf7309d5e76b5abc4503d','6055 Silent Chase','none','Snows Corner','45758', 'Ohio','United States','Tommie Shannon','11/01/2016','4697f2edebd5ab7b0a4400499bbe7bb6','American Express', 'b71cf7177119ebe29ce8d31a041a90e4','6055 Silent Chase','none','Snows Corner','45758','Ohio','United States','Tommie', 'Shannon',55,'M','ehlen@gmail.com','8559100800','8188485040'; exec uspAddCustomer '3042e6784b810304d9a225665c6b5918','dbf0e92ad8dc0d049d7eeb769f8db679','9413 Red Shadow Maze','none','Kalamazoo','72548', 'Arkansas','United States','Everett Frank','02/01/2018','c30e407163ab5677e5f57bb413887b75','Discover','fb1114644c5c0d8a1cdb5e 3af25bbbe1', '9413 Red Shadow Maze','none','Kalamazoo','72548','Arkansas','United States','Everett','Frank',76,'F','kuttler@rocketmail.com','8557232544','8112934301';
  • 66. Insert Publisher/Publisher Contact EXEC uspAddPublisherContact 'Andrew', '63e13ebec85d0e600652c65e9ddd8a50', 'Andrews McMeel', 'Eli Neal', 4799874563; EXEC uspAddPublisherContact 'Andrew', '63e13ebec85d0e600652c65e9ddd8a50', 'HarperCollins', 'Zane Buchanan', 4791239845; EXEC uspAddPublisherContact 'Andrew', '63e13ebec85d0e600652c65e9ddd8a50', 'Andrews McMeel', 'Eli Neal', 4799874563; EXEC uspAddPublisherContact 'Andrew', '63e13ebec85d0e600652c65e9ddd8a50', 'HarperCollins', 'Zane Buchanan', 4791239845;
  • 67. Add books to shopping cart EXEC uspAddBookToShoppingCart '9781449460839', 'rockmasterx2000@rockstar.com' EXEC uspAddBookToShoppingCart '9780062391735', 'rockmasterx2000@rockstar.com' EXEC uspAddBookToShoppingCart '0445986518916', 'rockmasterx2000@rockstar.com' EXEC uspAddBookToShoppingCart '7650816020495', 'TheSupremeProgrammer@gmail.com' EXEC uspAddBookToShoppingCart '1099727848738', 'TheSupremeProgrammer@gmail.com' EXEC uspAddBookToShoppingCart '7962192512153', 'TheSupremeProgrammer@gmail.com' EXEC uspAddBookToShoppingCart '2879060597570', 'TheSupremeProgrammer@gmail.com' EXEC uspAddBookToShoppingCart '9781234567897', 'duraku@hotmail.com' EXEC uspAddBookToShoppingCart '2135040972828', 'cichon@yahoo.com' EXEC uspAddBookToShoppingCart '1609190566464', 'quastad@gmail.com' EXEC uspAddBookToShoppingCart '3190084542284', 'quastad@gmail.com' EXEC uspAddBookToShoppingCart '7650816020495', 'quastad@gmail.com' EXEC uspAddBookToShoppingCart '8441155925360', 'cowgirl@rocketmail.com' EXEC uspAddBookToShoppingCart '9419905884520', 'cowgirl@rocketmail.com' EXEC uspAddBookToShoppingCart '3190084542284', 'ewton@gmail.com' EXEC uspAddBookToShoppingCart '9781234567897', 'lineman@outlook.com' EXEC uspAddBookToShoppingCart '1609190566464', 'lineman@outlook.com' EXEC uspAddBookToShoppingCart '9781234567897', 'lineman@outlook.com' EXEC uspAddBookToShoppingCart '1609190566464', 'lineman@outlook.com' EXEC uspAddBookToShoppingCart '0090060335185', 'lineman@outlook.com' EXEC uspAddBookToShoppingCart '8445987218589', 'knape@rocketmail.com' EXEC uspAddBookToShoppingCart '9781234567897', 'younger@hotmail.com' EXEC uspAddBookToShoppingCart '1609190566464', 'younger@hotmail.com' EXEC uspAddBookToShoppingCart '9419905884520', 'younger@hotmail.com' EXEC uspAddBookToShoppingCart '1099727848738', 'means@hotmail.com' EXEC uspAddBookToShoppingCart '9781234567897', 'means@hotmail.com' EXEC uspAddBookToShoppingCart '2879060597570', 'means@hotmail.com' EXEC uspAddBookToShoppingCart '0090060335185', 'brooks@yahoo.com' EXEC uspAddBookToShoppingCart '8445987218589', 'brooks@yahoo.com' EXEC uspAddBookToShoppingCart '0445986518916', 'ehlen@gmail.com' EXEC uspAddBookToShoppingCart '1884709673002', 'ehlen@gmail.com' EXEC uspAddBookToShoppingCart '7374569404550', 'ehlen@gmail.com' EXEC uspAddBookToShoppingCart '1099727848738', 'ehlen@gmail.com' EXEC uspAddBookToShoppingCart '7374569404550', 'kuttler@rocketmail.com' EXEC uspAddBookToShoppingCart '1099727848738', 'kuttler@rocketmail.com'
  • 68. Finish Transaction EXEC uspFinishTransaction 'rockmasterx2000@rockstar.com' EXEC uspFinishTransaction 'TheSupremeProgrammer@gmail.com' EXEC uspFinishTransaction 'duraku@hotmail.com' EXEC uspFinishTransaction 'cichon@yahoo.com' EXEC uspFinishTransaction 'quastad@gmail.com' EXEC uspFinishTransaction 'ewton@gmail.com' EXEC uspFinishTransaction 'lineman@outlook.com' EXEC uspFinishTransaction 'knape@rocketmail.com' EXEC uspFinishTransaction 'younger@hotmail.com' EXEC uspFinishTransaction 'means@hotmail.com' EXEC uspFinishTransaction 'brooks@yahoo.com' EXEC uspFinishTransaction 'ehlen@gmail.com' EXEC uspFinishTransaction 'kuttler@rocketmail.com'