Little experience in database design

zhaozj2021-02-17  37

1. The field is best to use the default value, unless the automatic growth or primary key foreign key. The character type defaults the empty string, the numeric type is default 0, and the date type default is the system date. Doing so, the benefit is: reduce the unnecessary code of the program, reduce the length of the program code, thereby reducing the possibility of an error. For example, in a table contains 20 fields, we need to judge whether it is empty in the corresponding row of data to the corresponding control. Then, if you do not use the default, you will add a corresponding judgment statement, and the length of the program may increase by 60 lines.

The length design of the 2 field should take into account the need for future changes, and the length is generally two units than the length of the demand analysis.

3 For which length change is not necessarily a character field, it is best to use automatic telescopic type, which saves user disk space.

4 In the case where the database reserved word is not known, the name field stores process table, except for a certain descriptive, it is best to add a specific prefix. For example, in SQL Server, many people like to name the field with Name, but Name is the reserved word of SQL Server, and the result is often an error and can't find the reason.

5 Complex business logic is best to resolve in the stored procedure, so fast and efficient.

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

New Post(0)