
C# ПІДРУЧНИКИ / c# / Premier Press - C# Professional Projects
.pdf

PROJECT CASE STUDY AND DESIGN |
Chapter 27 |
599 |
|
|
|
|
|
Similar to Deepthoughts Publications,Black and White Publications is one of the major book providers of Bookers Paradise. Established in 1994, Black and White Publications has grown to be a leading publishing house in the United States.The organization, with its corporate office located in New York, has its branches spread all over the United States. Black and White Publications shares the corporate goal of increasing its yearly profits with Bookers Paradise.Therefore, Black and White Publications wants to collaborate with Bookers Paradise to sell its books online. To do this, the publishing house plans to create a Web service that provides the site of Bookers Paradise with the information about the books published at its publishing house.
Project Requirements
Bookers Paradise wants to launch an online bookstore that contains information about books published by Deepthoughts Publications and Black and White Publications. To display the catalog of books on the Web portal, Deepthoughts Publications and Black and White Publications need to host a Web service that is used to expose the information about the books in the form of a catalog. This information includes the ISBN (International Standard Book Number) number, the title, the author, and so on. To access the information exposed by the Web services, Bookers Paradise needs to host a Web service client.This Web service client is the Web portal launched by Bookers Paradise. The Web service client displays the book catalogs to the visitors on the site. In addition, the Web service client stores the information about its customers.
The function of the Web service that you create is not limited to providing the Web portal with book catalogs. The customers that visit the site of Bookers Paradise can search for information about the books on the site. For example, the customer can search for books on a particular subject, books written by a particular author, or books published by a particular publisher. To provide customers with the required information, Web services need to expose functions to the Web service client. In addition, the Web service can expose functions that provide information about the availability of the book and the editions of the book released by the publisher.



602 Project 5 CREATING A WEB PORTAL FOR A BOOKSTORE
Ordering a Book on the Web Site
The procedure to order a book on the Web site is as follows:
1.The user selects a book to order in the Orders page.
2.The user then clicks on the Order button to order the book.
3.The user is taken to the Orders page. On the Orders page, the customer details, such as name, address, and credit card information, are specified.
4.After specifying the required details, the user clicks on the Order button.
5.When the Order button is clicked, the details submitted by the user is sent to the database maintained by the publishing house.
NOTE
To send the information submitted by the user to the database of the publishing house, the Web site uses a Web method created in the Web service. You will learn about this method, AcceptDetails(), in Chapter 29, “Developing Web Services.”
6.The details of the customer and the order placed by the customer are stored in the database at the publishing house.
7.At the site of the publishing house, the request of the user is processed and the book is delivered to the client.
Project Design
Having examined the project requirements in detail, you need to create a detailed design of the project. You can create a design of the application in the project design stage. The project design stage includes identifying the database design and the database schema. To finalize the database schema, you first need to decide on the tables required in the database. Then, a detailed analysis of the database design is required to identify the relationships between various tables in the database. Based on this, a detailed schema of the database is created. It is critical to examine all possible requirements and incorporate them in the database schema to avoid reworking at a later stage. The following section delineates the database design for the Web portal.

PROJECT CASE STUDY AND DESIGN |
Chapter 27 |
|
603 |
|
|
||||
|
|
|
|
|
Database Design
After creating the structure of database tables and normalizing the structure, you arrive at a database schema that is appropriate for your Web portal project. Normalizing the database design helps to remove data redundancy.
In the case of this Web portal, data is not stored in the database of any one organization.Data is spread across the databases of Bookers Paradise and the two publishing houses. It therefore becomes all the more essential for you to carefully plan the database design and normalize the design. This will help you avoid data redundancy across tables in the databases of different organizations. You have learned about the basic concepts of creating an SQL database and normalization in Chapter 7, “Project Case Study,” in the section “Normalization.”
In addition to creating the database design for the three organizations, you need to establish relationships between the tables in the databases. This will help you program your application to query and update data in the related tables. I will discuss how to create relationships between tables later in this chapter. However, I will first discuss the structure of the tables in the databases of the three organizations.
Database Design for Bookers Paradise
Bookers Paradise plans to launch a Web site that allows visitors to view information about books and to place an order for a book. To do this, Bookers Paradise maintains a database called BookersDB. This database includes two tables, BookersOrders and BookersCustDetails. The following section discusses these tables in detail.
The BookersOrders Table
The BookersOrders table stores information about the order placed by a customer for a book.Therefore, this table includes information such as OrderNo, CustomerID, and ISBNNo of the book. When a customer places an order, a unique identification number, CustomerID, is assigned to the customer. In addition, for each order, a unique number, OrderNo, is assigned.The OrderNo is defined as the primary key for the table. Table 27-1 shows the fields in the BookersOrders table in the BookersDB database.

604 Project 5 CREATING A WEB PORTAL FOR A BOOKSTORE
Table 27-1 Structure of the BookersOrders Table
Column Name |
Data Type |
Length |
Allow Nulls |
OrderNo |
char |
10 |
0 |
CustomerID |
char |
6 |
0 |
ISBNNo |
char |
10 |
0 |
|
|
|
|
NOTE
In the preceding structure of the BookersOrders table, the value 0 for the Allow Nulls column does not allow the user to leave this field blank. However, if you specify the value as 1, the field is optional when adding a new record. I will be using this convention while discussing the structure of the rest of the tables.
The BookersCustDetails Table
In addition to storing the details of the order, Bookers Paradise wants to store the details of all the customers who place an order for a book. To do this, the BookersCustDetails table is created. The BookersCustDetails table contains fields
such as CustomerID, CustomerName, BillingAddress, and so on. The CustomerID
field is set as primary key for this table. Table 27-2 shows the details of the
BookersCustDetails table.
Table 27-2 Structure of the BookersCustDetails Table
Column Name |
Data Type |
Length |
Allow Nulls |
CustomerID |
char |
6 |
0 |
CustomerName |
varchar |
50 |
0 |
BillingAddress1 |
varchar |
50 |
0 |
BillingAddress2 |
varchar |
50 |
0 |
BillingAddressCity |
varchar |
20 |
0 |
BillingAddressState |
varchar |
20 |
0 |
|
|
|
|



PROJECT CASE STUDY AND DESIGN |
Chapter 27 |
607 |
|
|
|
|
|
about the books published by Black and White Publications and the customers who order the books. To store this information, the BWDB database has two tables, BWCatalog and BWOrders. The following sections discuss these tables in detail.
The BWCatalog Table
The BWCatalog table stores information about the books published by Black and White Publications. Table 27-5 shows the structure of the BWCatalog table.
Table 27-5 Structure of the BWCatalog Table
Column Name |
Data Type |
Length |
Allow Nulls |
ISBNNo |
char |
10 |
0 |
BookName |
varchar |
50 |
0 |
Author |
varchar |
50 |
0 |
Price |
decimal |
9 |
0 |
AboutTheAuthor |
varchar |
100 |
1 |
Category |
varchar |
30 |
0 |
|
|
|
|
As you can see, the BWCatalog table stores information such as the ISBN number, name, author, price, and category of the book. In addition, the preceding table contains the AboutTheAuthor field. You can store some information about the author of the book in this field. The ISBNNo field is set as the primary key for this table.
The BWOrders Table
Similar to the orders table of Deepthoughts Publications,the orders table of Black and White Publications stores information about the orders that are sent by the site of Bookers Paradise. Table 27-6 shows the fields contained in the BWOrders table in the BWDB database.