20 best Practices for database design

Source: Internet
Author: User

Original: 20 best practices for database design

  Database design is one of the key points of the entire program, in order to support the operation of the relevant programs, the best database design is often not possible, can only be repeatedly explored and gradually refinement, this is a complex process, is planning and structured database data objects and the relationship between these data objects process. Here are 20 best practices for database design, and of course, the best is to see if it fits your program. Get to know it together.

  1. Use clear, unified labeling and listing names, such as School, Schoolcourse, Courceid.
  2. The data table name uses the singular rather than the plural, such as studentcourse, rather than studentcourses.
  3. Do not use spaces for data table names.
  4. Data table names do not use unnecessary prefixes or suffixes, such as using school instead of Tblschool, or schooltable, and so on.
  5. Passwords in the database are encrypted and then decrypted in the application. (In fact, hash storage, one-way encryption)
  6. Using integers as ID fields may not be necessary now, but will be needed in the future, such as association tables, indexes, and so on.
  7. Using an integer number field to index, otherwise it will cause a lot of performance problems.
  8. Using bit as a Boolean field, using integers or varcha is a waste. At the same time, this type of field should start with "is".
  9. To be authenticated to access the database, do not give each user administrator permissions.
  10. Try to avoid using "SELECT *" and "SELECT [Required_column_list]" for better performance.
  11. If the program code is more complex, use an ORM framework, such as Hibernate,ibatis. The performance problems of ORM framework can be solved by detailed configuration.
  12. Partition infrequently used data tables into different physical storage for better performance.
  13. For critical databases, use secure backup systems such as clustering, synchronization, and so on.
  14. Use foreign keys, non-null and other restrictions to ensure the integrity of the data, do not throw everything to the program.
  15. A lack of database documentation is fatal. You should write documents for your database design, including triggers, stored procedures, and other scripts.
  16. For frequently used queries and large data tables, use the index. Data analysis tools can help you decide how to build an index.
  17. The database server and the Web service should be placed on different machines. This improves security and reduces CPU pressure.
  18. Image and Blob fields should not be defined in a common data table, otherwise they may affect performance.
  19. Paradigm (normalization) to be used as required to improve performance. Normalization does not do enough to cause data redundancy, and excessive normalization can lead to too many joins and data tables, both of which can affect performance.
  20. Spend more time on database design, or you will pay twice as much time in the future.

English Original: javacodegeeks.com

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.