Three-tier architecture for database connections

Source: Internet
Author: User

First, what is a three-tier architecture

1. Concept

The three-tier architecture (3-tier architecture) typically has a three-tier architecture that divides the entire business application into: The presentation layer (UI), the Business Logic layer (BLL), the data Access Layer (DAL). The purpose of distinguishing hierarchy is to "high cohesion, low coupling" thought.

Tiered (tier) Concept
Presentation Layer (UI) Popular speaking is to show the user interface, used to display data and accept user input data, that is, the user in the use of a system when he saw the results.
Business Logic Layer (BLL) For the operation of the specific problem, it can also be said that the operation of the data layer, the data business logic processing. is a bridge between the presentation layer and the data access layer.
Data access Layer (DAL) This layer of transactions directly manipulate the database, for data additions, deletions, modifications, lookups and so on.
Database entities Class (entity) Encapsulating data Objects, there are some simple features

2. The role of each layer

Layered Role
Presentation Layer (UI) The main means of the web, or can be expressed as a WinForm way, the web can also be represented as: ASPX, if the logical layer is quite powerful and perfect, no matter how the presentation layer is defined and changed, the logical layer can provide a perfect service.
Business Logic Layer (BLL) Mainly for the specific problem of operation, can also be understood as the operation of the data layer, the data business logic processing, if the data layer is a building block, the logic layer is the building of these blocks.
Data access Layer (DAL) The main is the original data (database or text files, such as the form of data storage) operation layer, rather than the original data, that is, the operation of the data, rather than the database, specifically for the business logic layer or presentation layer to provide data services

As can be seen from the above table, an extra Database entity Class (entity), he does not exist as a layer in layer three, but as a class library, play the role of encapsulating database tables.

3. Relationships between layers and class libraries

Second, why use a three-tier architecture?

1. Analysis

Hierarchies are ubiquitous in the real world. Remember there is a joke about a village head proudly to his wife bragging: "The whole of China is bigger than my official only four people, Township, county magistrate, Governor and the State Council," the joke reflects the real social stratification phenomenon, social groups will be layered, the structure of corporate management will be layered,

The building is layered, even make buns of Tororo is also layered, although the purpose of layering is different, but is to solve a problem arises, so layered architecture is to solve a problem arising from the solution.

The advantages of social division of labor: Let the right people do what they do best, shorten working hours, improve labor efficiency. The most utilized. Software development is the same, the development of small projects, perhaps layered and non-layered may not see much difference, layering may appear more verbose, but when the development of a complex project, the advantages of layering is shown.

For example: We reconstruct the computer room toll system, need to access the database, in the case of non-hierarchical, there will be a large number of duplicate code, nothing more than the database of the increase, deletion, change, check, these duplicate code can be applied to multiple modules, that is, the field name and quantity are different. It takes us quite a bit of time to knock on these repetitive codes, not to mention our computer room charging system is just a small project. What if it's a larger project?

Every thing has its advantages and disadvantages, the disadvantages of layered architecture mainly include the following two points:

1), layered also, if not layered, many businesses can directly access the database, access to data, but now must be accessed through the middle tier, thereby reducing the system performance.

2), sometimes resulting in cascading changes. This kind of modification is especially reflected in the top-down direction. If you need to add a feature in the presentation layer to ensure that the design conforms to the layered structure, you may need to add code to the appropriate business logic layer and the data access layer.

However, the advantages of layered architecture outweigh the disadvantages.

2. Concluding remarks

In the software architecture, the layered structure is a relatively easy to understand and the most common structure, and the three-tier structure is the most common hierarchical structure of the hierarchy, but also the Microsoft recommended layered structure. Layered structure There are other patterns such as MVC, after understanding and familiarity with the three-tier architecture, learning other architectures will be easier, let's start with the easiest to understand.

Three-tier architecture for database connections

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.