Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

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

.pdf
Скачиваний:
475
Добавлен:
12.02.2016
Размер:
14.7 Mб
Скачать

598 Project 5 CREATING A WEB PORTAL FOR A BOOKSTORE

In the preceding projects, you learned how to develop Windows applications and an ASP.NET Web application. Windows applications are used to develop

applications that can run on a desktop computer. Alternatively, ASP.NET appli-

vice. In addition to integrating various applications,Ya Web service can be used to

cations are large-scale business applications that can be deployed on an intranet

of the organization or on the Internet. However, to find a business solution that

L integrate data from various applicationsFdeveloped for different organizations.

integrates applications built on different platforms, you need to create a Web ser-

In this chapter, I will discuss the case study of the Web portal project.In addition,

Organization Profile

I will discuss the database and the interface design for the Web portal. You will

learn to create the actual application in the forthcoming chapters.

 

M

A

E

T

 

Bookers Paradise is chain of retailers, having their retail outlets spread across the United States. Bookers Paradise was established in 1998 as a small bookstore in the city of New York. Since then, the organization has grown to be a chain of more than 50 outlets in the United States. To grow further in the business world and increase its yearly profits, the organization plans to sell the books of two publishers over the Internet. These publishers are Deepthoughts Publications and Black and White Publications.

Deepthoughts Publications is one of the leading book publishers of the United States. Deepthoughts Publications has been publishing books on various subjects ever since it was established in 1991. Deepthoughts Publications publishes highquality books and,therefore, has a huge clientele.In addition, Deepthoughts Publications has been dealing with a number of retailers, Bookers Paradise being one of them. Therefore, to enable its customers to buy books online, Deepthoughts Publications has decided to create a Web service. This Web service will provide the Web site developed by Bookers Paradise with information about the books published at the publishing house.

Team-Fly®

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.

600 Project 5 CREATING A WEB PORTAL FOR A BOOKSTORE

As stated earlier, a Web service is used to integrate information from various organizations.Therefore, a Web service provides the Web service client with information about books. Similarly, the Web service client shares the data of its customers with the publisher. When customers visit the Web portal for Bookers Paradise, they can view information about the books on the site. In addition,they can query for information on books on the site. When the customer views the information about a book and places an order for the book on the site of Bookers Paradise, the Web service client forwards the purchase request to the publisher of the book. In addition, the information about the customer is sent to the publisher.

The publisher then maintains the customer data along with the information about the book that is released. When the book is delivered to the customer, the publisher updates the status of the book in the database maintained by the publisher. The customer can then query the Web site to know the status of the order placed by the customer. I will discuss the structure of the databases maintained by the retailer and the publisher later in this chapter.

To have a clear understanding of the working of the Web portal,I will first list the tasks that need to be performed by the Web portal. In addition, I will discuss how these will be accomplished.

Querying for Information about All Books

As discussed earlier, a user can query for the information about the books published by a publisher. The procedure for querying information is as discussed here:

1.A user visits the Web site of Bookers Paradise. On the Main page, the user chooses to view the information about all the books published by the Deepthoughts Publications and the Black and White Publications publishing houses.

NOTE

The user has the option to view the information about all the books or search for information about the books based on criteria. In the next section, you will learn about the procedure for viewing the information about books based on criteria.

PROJECT CASE STUDY AND DESIGN

Chapter 27

601

 

 

 

 

2.The Web site sends the request to the Web service hosted by the two publishing houses.

3.The Web service processes the request and sends the result of the query back to the Web site. The user can then view the desired information on the Web site.

NOTE

The Web service has certain Web methods that the Web service uses to respond to the queries sent by the Web service client, which is the Web site in this case. You will learn about creating the Web service and the Web methods in the succeeding chapters.

Querying for Information about Books Based on Criteria

A user who visits the site of Bookers Paradise can view information about the selected books published by Deepthoughts Publications and Black and White Publications. The search for information about books in this case is based on criteria. For example, the user can search for information about books based on category, title, or author. The procedure to search for information based on criteria is given as follows:

1.The user visits the Web site of Bookers Paradise and selects the criteria from the list box in the Main page.

2.The Web site requests the Web service to retrieve the required information.

3.The required information is returned to the Web site in the form of records from the database. This information can then be viewed by the user in the Results form.

After the user has viewed and selected a book to purchase, the user can order the book on the site. The following section covers the procedure for ordering a book on the Web site.

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

 

605

 

 

 

 

 

 

Database Design for Deepthoughts Publications

If you consider the business requirements for the Web portal project, when a customer places an order for a book, the order, along with the information about the customer, is forwarded to the respective publisher. Deepthoughts Publications then stores this information in a database called DTDB. The DTDB database contains two tables, the DTCatalog and the DTOrders tables.I will discuss the structure of these tables in the following sections.

The DTCatalog Table

The DTCatalog table stores information about the books published by Deepthoughts Publications. This information includes the ISBN number, title, author, date of publishing, price, and category of the book. In addition, the table contains a short description of the book.

Every book published at the publishing house has a unique ISBN number, which is defined as the primary key for the DTCatalog table. Table 27-3 shows the structure of the DTCatalog table.

Table 27-3 Structure of the DTCatalog Table

Column Name

Data Type

Length

Allow Nulls

ISBNNo

char

10

0

BookTitle

varchar

50

0

Author

varchar

50

0

Category

char

10

0

Description

varchar

50

0

DateOfPublication

datetime

8

0

Price

varchar

8

0

 

 

 

 

The DTOrders Table

The DTOrders table stores information about an order placed by the customer. In addition, you can store the details of the customer who placed the order. Table 27-4 shows the fields in the DTOrders table.

606

Project 5

CREATING A WEB PORTAL FOR A BOOKSTORE

 

 

 

 

 

 

 

 

 

Table 27-4 Structure of the DTOrders Table

 

 

 

 

 

 

 

 

 

 

 

Column Name

Data Type

Length

Allow Nulls

 

 

 

 

 

 

 

 

 

ISBNNo

char

10

0

 

 

OrderNo

char

5

0

 

 

DateOfOrder

datetime

8

0

 

 

CustomerName

varchar

50

0

 

 

CustomerAddress1

varchar

50

0

 

 

CustomerAddress2

varchar

50

1

 

 

CustomerCity

varchar

20

0

 

 

CustomerState

varchar

10

0

 

 

OrderedBy

varchar

50

0

 

 

Status

 

varchar

20

0

 

 

CreditCardType

char

10

0

 

 

CreditCardNumber

varchar

20

0

 

 

 

 

 

 

 

 

The preceding table contains a Status column. This column contains information about the status of the delivery of the book to the customer. In addition, Table 27-4 contains a field with the name OrderedBy. This field stores the information about the retailer who ordered for the specified book. In our case, the value stored in this field is Bookers Paradise.

The DTOrders table also contains information about the credit card of the customer, such as the type of credit card and the credit card number of the customer.

The DTOrders table has the combination of ISBNNo and OrderNo fields as the composite key.

Database Design for Black and White Publications

Black and White Publications maintains a database called BWDB. Similar to the database of Deepthoughts Publications, the BWDB database stores information

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.