.NET PETSHOP Detailed (2): PETSHOP three-layer structure DataTier

zhaozj2021-02-16  53

.NET PETSHOP Detailed (2): PETSHOP three-layer structure DataTier

Three layers of interaction

In the previous article, our entire system has learned about the physical profile of PETSHOP's three-layer deployment structure. It does not explain how to divide from the point of view of the application, and it is not clear that the data display layer, intermediate layer, data How is the layer interacts. In order to better illustrate this three-story structure and the specific details of each layer, you also have a Walkthrough for the entire application. Here I will showcase from the perspective of the system (see Figure 1), customers are shopping During the process, the three layers of the system work and how interact. This thing is a bit like the example of the instance of UML, which is more helpful to demand and analysis.

Figure 1. Net PetShop architecture From this scenario, we can clearly understand the operation of Internet Customer during shopping. First, enter the customer's purchase of goods and quantity by the user interactive interface Cart.aspx page, then these shopping lists are made by the background application (Cart.aspx.cs) (such as security verification, check, Format of data, etc.), then call the middleware (some .NET Assembly in the program structure), encapsulate the business logic of the shopping, and finally update the data in the database (data layer).

DataBase

.NET PETSHOP database is not very large, with a total of 12 user tables and 23 stored procedures. The PETSHOP database is stored in user data, account data, product data, user configuration data, order data, inventory data, and supplier data. The data of the application accesses the database is not directly dealing with the database table, but the required data is obtained by the operation of the stored procedure. Such a design has a benefit to avoid frequent table operations, and the storage procedure running on the server can greatly improve the operation efficiency and improve the speed of access data, and also shield the logic of the database table, making Database access becomes a service access available to the database. Of course, some people have accused that these stored procedure migration is doubtful.

Below I will list the basic tables of these databases through the form (see Table 1), and do it one by one, I hope to help everyone in depth.

Table name

Remark information

Account

Basic user information.

Bannerdata

Store setting information for the Banner image of the system interface.

Category

Pet category catalog table (such as fish, dogs, etc.).

Inventory

Pet product inventory information.

Item

Details of a single product.

LineItem

Details of each item of the order, including product name and quantity, price, etc.

ORDERS

User shopping orders, one order can include multiple LineItem

ORDERSTATUS

Order status

PRODUCT

Pet Product List, a product may include multiple items

Profile

User configuration table for recording their Favorites.

Signon

User account login table, because of common use, since it is independent from Account.

Supplier

Supplier information.

Through the table below, we know some of the information of the PETSHOP database, but what is the relationship between these tables? People who care about database modeling and design may be more interested in this issue. Here, I will give the chart (Figure 2) to illustrate the relationship between these database tables. The relationships and primary key information between these tables are listed in Figure 2. Figure 2: PETSHOP database physical design mode

Tip: In fact, it is not a difficult thing to get the above database model graphics for people engaged in database modeling and design. As we mentioned earlier, we can use Visio to do engineering to get the above beautiful design model map. At the same time, we can also modify the design in the model map, you can apply it immediately to your physical database to keep it synchronized.

After finishing the basic database table, let's take a look at the stored procedure. With Microsoft, only the design is called the stored procedure, it is "Clearative Department of code from the middle-tier", I personally feel that this is good. Similarly, I will listed it in a form (Table 2).

Store process name

Remark information

UpaccountAdd

Add an account.

UpaccountGetDress

Get the user's address, mainly used for the registration address and the delivery address when the order is under orders.

UpaccountGetDetails

Get detailed information on your account.

Upaccountlogin

User login verification.

UpaccountUpdate

Update the user account.

UpcategorygetList

Get a list of products for a category.

UpinventoryAdd

Add the specified item to survival information.

UpinventorygetList

Get inventory list.

Upitemadd

Add a product.

Upitemgetdetails

Get detailed information for the specified product item.

Upitemgetlist

Get the list of specific items for a particular class product.

Upitemgetlist_listbypage

Function is with the same, but the data is acquired.

UpordersAdd

Add an order.

Upordersget

Get information about a certain order.

Upordersgetdetails

Get detailed information for a certain order.

Uporderstatusget

Get the status of the order.

UpproductAdd

Add a class of other products.

UpproductgetList

Returns a list of a type of product.

UpproductGetList_ListbyPage

With the same, the result data is obtained. .

UPPRODUCTSEARCH

product search.

UpproductSearch_listbypage

With the same, how to get the result data.

UPPROFILEGETBANNNEROPTION

Banner's configuration information.

UPPROFILEGETLISTLOption

Get user configuration information.

Table 2: list of PETSHOP stored procedures

In these stored processes, the characteristics of the OpenXML of SQL Server2000 are used instead of traditional row assemblies, and the system's burden can be reduced using very frequent data access operations.

Ok, PETSHOP's DataTiar said here, in the later article I will explain the execution of the stored procedure again on the instance of a data access. Next, I will introduce the intermediate layer.

转载请注明原文地址:https://www.9cbs.com/read-23291.html

New Post(0)