Database design practice

xiaoxiao2021-03-05  47

Usually, the design of the database should follow four paradigms as much as possible, in addition to the practical design, but also to see the specific database.

See several reference views in the design of the database: 1. For some keywords in the database system, avoid it, otherwise it will be wrong. In design, the design of the field is as designed with the word prefixed, or use the _ to connect. This is readable and avoids conflicts with keywords. 2. When the SQL Service's Create Table has a creative key key, it is a cluster index. The primary key is the aggregation index, but this is a waste of aggregation indexes. Although SQL Server defaults to establish a gathering index on the primary key. 3. Need to divide a large table into several small tables and connect to the main key or foreign key! 4. Put the fields that are often empty, can be placed in a table to reduce data redundancy .5. For the full-text search database: You can set the stored procedure or not to set the stored procedure, depending on the size of the data written to the data and the actual consideration. 6. For fields that are often searching or connected, set to an index. 7. For details from two tables to be obtained, they can be done by view. Regardless of whether it is logically, it is a great advantage from security!

Pay attention to the database design: 1. You cannot establish an index for a field longer than 900 bytes. For VARCHARs, it can be established on fields longer than 8000. 2. For establishing a database, you can build a database by writing a series of documents. SQL, and then import it. At the same time, pay attention to timely echo related information.

Processing between the field of the large object and the string: 1. How to store strings into the image type field: Set a file type field fileType, then use a statement to use a statement on the image field: sp_fultext_column 'dali', 'MyImage', 'add', 0x0804, 'filetype' --- This sentence is to specify the MYIMAGE list as a full-text index column through this statement, then use Insert Dali Values ​​(..., 'Shdagjksjksldjkimage', 'txt'); you can write strings SHDAGJKSJKSLDJKIMAGE to Image. And support full-text search 2. For Text type, the text is still text data, and can be read and written directly. And the image type data is not good because it stores binary coding!

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

New Post(0)