A little experience in database design

Source: Internet
Author: User
Design | data | database | Database design
1. Fields are best to use default values, unless those are automatic growth or primary key foreign keys. The character type is the default empty string, the numeric type defaults to 0, and the date type defaults to the system date. The advantage of this is to reduce the unnecessary code of the program and reduce the length of the program code, thereby reducing the possibility of error in the program. For example, when a table contains 20 fields, we need to determine whether it is empty when we read a row of data to the corresponding control. Then, if you do not use the default value, you will increase the corresponding judgment statement, the length of the program may be increased by 60 lines.

The length of the 2 field is designed to take into account the need for future changes, which are generally two units longer than the length of the requirement analysis.

3 It is best to use automatic scaling for character fields which vary in length, which can save user disk space.

4 in the case of database reserved words, the name of the stored procedure table, and so on, in addition to have a certain descriptive, it is best to add a specific prefix. For example, in SQL Server, many people prefer to name a field by name, but name is the reserved word for SQL Server, and the resulting program often fails to find the cause.

5 Complex business logic is best addressed in stored procedures so that it is fast and efficient.


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.