Database Table relational model resolution 7 -- one table in the many-to-many data model is a self-join

Source: Internet
Author: User
Tags powerdesigner
Document directory
  • View code in MVC
  • Controller code in MVC
  • Model Code in MVC

In this section, we detail how to add, delete, modify, and query a table in a multi-data model in a real project.
The langben code generator can automatically generate ASP. NET pages and background code.
The technologies used by the generated project include jquery + MVC + Entity Framework.

In practical development, we use powerdesigner to design a database model. The langben code generator reads the database model designed by powerdesigner, analyzes the relationship model between the table and the table, and analyzes the keywords in the description information of the table and field, different pages are automatically generated.

The relational models between tables include:
  1. Single Table Data Model
  2. Self-connection data model
  3. One-to-one Data Model
  4. One-to-Multiple Data Models
  5. One table in the one-to-multiple data model is self-join.
  6. Multi-to-multi-data model
  7. One table in the many-to-many data model is self-join.
Keywords include
  1. Query
  2. Status
  3. Upload
  4. Workflow

 

Architecture Diagram

Component Description

Chart 1 project component description

  1. App-page display Layer

    The MVC framework is used, the jquery script library is used, and easyui is used for the control.

  2. Wcfhost -- service host (post-extension)

    Provides a host for external services, using the WCF technology and HTTPS communication protocol.

  3. Ibll-business interface layer

    APIs and service contracts exposed by methods at the business logic layer.

  4. Bll-business logic layer

    Business logic operations, including business processing, transactions, and logs.

  5. Dal-data access layer

    Database Access operations, data entities, business entities, data validation, using Entity Framework.

  6. Common -- public component layer

    Common auxiliary methods used by the entire application.

  7. Wfactivitys -- workflow activity layer (post-extension)

    Defines the activities required by the workflow and uses Microsoft WF technology.

  8. Wfdesigner-workflow designer (later extension)

    It allows implementers to freely configure the workflow designer and use Microsoft WPF technology.

     

Roles of personnel

Log on to the system using the user name and password of a person

There is an association table between the personnel and the Department, and the Department is a typical self-connection table. These three tables constitute a typical "one table in the many-to-many data model is self-join"

The following uses a person as an example to analyze the data model "one table in the many-to-many data model is a self-join". The code is already in the generated file and the annotations are detailed. This article will not go into details.

Data Model

The relationship between departments and personnel is many-to-many, and the Department is a self-join table.

Query

 

List

View code in appmvc on the page display Layer

This list page was developed with reference to the \ jquery-easyui-1.2.3 \ demo \ tree.html page

 

Controller code in MVC

 

Model Code in MVC

Model is the entity automatically generated by Entity Framework.

Business interface layer ibll

This layer serves as the interface of the business logic layer method and is also a contract exposed by WCF.

Business logic layer BLL

The business logic of the data dictionary class is written in the BLL class library. The transaction uses the transactionscope object. The syspersonbll. CS class file encapsulates the operation methods of the business logic and inherits the basebll base class.

The entire project should follow the following principles: fat Bll, thin MVC

Data access layer dal

The sysperson. CS file is used to verify the object and object metadata of the table, while the syspersonrepository. CS file is used to access the database.

The business entity is in sysperson. the sysperson class in the CS file. It is a partial class that can be customized internally. The metadatatype attribute specifies the validation class syspersonmetadata for this object attribute, and it inherits the ibaseentity interface (this interface does not have any members at the moment );

The sysperson. CS file also contains a syspersonmetadata class for verifying members in the sysperson class. Note that the verification class must reference using system. componentmodel. dataannotations; namespace.

Service Layer

(Extension later)

Delete

Select one, and then click Delete.

Create

Select a department (tree structure)

Select a role (non-tree structure)

Modify

View Details

 

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.