Develop WinForm project (1) Database design and project framework generation progressively

Source: Internet
Author: User
Tags sort table name powerdesigner

In many cases, a lot of beginners will soon ask me: I was transferred from other languages to C # development, there are some basic information for us to learn it, your frame feel too big, want to have a step-by-step tutorial or video to learn the good.

In fact, maybe we are faced with too many things every day, feel a lot of common, even in very small places, we may have formed a habit. Conversely, if we switch to other areas, such as iOS, Android, then we may not know much about the rules in many of the designs, and the beginning may also be confused.

This article would like to be my "progressive development WinForm Project" series of the opening, mainly introduces the database design attention to some matters, so as to facilitate the construction of the project framework and development process.

1. database table Design

As the saying goes, the high-rise building from the bottom, the development of application projects, database design is very important, it may be business objects, business process integrated design, good database design can reduce the late repetition rework, improve development efficiency.

We have a simple database table for the design discussion, step-by-step analysis of the relationship.

1 Table and field names

General table name, depending on the business relationship, we can use different prefixes to differentiate, using prefixes, can be very convenient to distinguish between different business tables, such as my own general base table uses "Tb_" to define the prefix, the Permission system table uses "T_acl_" to define the prefix, the workflow table uses "Tbapp_", Business table using "T_" and so on, so for the differentiation of different business, convenient management is very good.

In terms of field names, we can agree on some rules, such as the appointment of primary keys using IDs; In general, the ID as the primary key, you can use the growth of the shaping field, you can also use the character field of the GUID, if to facilitate the compatibility of different databases and facilitate migration or develop web-based applications I suggest using the character field of the GUID, using this type of field, we can know the primary key of this record from the time we create the data, which is very advantageous for us to maintain the parent-child table.

The name of the field, suggest a simple main, such as customer name, directly using name to name it, do not need to use customername such verbose names.

Because if you take a character ID primary key, we may need to add a createtime date type if we need to sort correctly, so that we can sort by date.

If this table also has a reference to a foreign key, it is recommended that the uniform naming standard, I generally use the name of the table name _id, such as user_id, contact_id and other similar names as foreign keys, do not need a table prefix.

2 The model design of database

Database model design, we recommend that in the third party database design tools, such as powerdesigner design tools, the use of tools to design the database has many advantages, one is efficient to adjust, the second is to generate different database types of SQL statements as needed, The third is the global understanding of the relationship between the tables and so on.

Using database design tools such as PowerDesigner can greatly improve the design efficiency of our database.

2, the project framework Generation

After the design of the database, we use the code generation tools to build the entire project framework, so that we are in the development of new projects have good benefits, the inside of the project level, DLL reference relationship, has been dealt with, which is very convenient for us. But most of the time, we are incremental development, that is, we may have completed a number of other business development, may add a two tables, or a batch of business table processing, so it does not matter, we have to copy the newly generated code to the project, because the project generated, The primary namespace and associated table prefixes are specified so that the code we generate can be easily read, reducing the chance of redundancy and error.

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.