Java electricity supplier payment systems Hands (Part two) - Best Practices database table design

1 Database Design

Table 1.1 combing relationship

  • Think carefully about business relationships, obtain the following table diagram

    1.2 User table structure

    1.3 Classification Structure


    id = 0 as the root node, in fact, is the classification tree

Table 1.4 Commodity structure

  • Note that the price field of type decimal

1.5 payment information table structure

1.6 Orders table structure

  • At first glance, it is necessary to engage in so many time thing? There are a number of reasons
    • Front-end display needs, it must deposit with it!
    • Convenient positioning troubleshoot problems, such as a customer complaint for an order has not shipped, it certainly takes time to locate
    • Facilitate data analysis, such as the need to calculate the average time payment from the user to the final issue of commodities
    • The corresponding order confirmation time order status

1.7 Order Details

Due to changes in prices and other factors, need to record details of the relevant properties when users buy goods, when we do the associated table, encounter such variables, to consider whether to make the archive.

1.8 shipping address

2 Index

2.1 unique index

The only index unique, to ensure data uniqueness
such as:

  • The user name field in the user table, write the same username will error.
  • Orders table Order Number

    2.2 single index and combination index

    Single / multiple fields to index called single / combination index

    3 timestamp

    For positioning troubleshooting business issues
  • create_ time: Creation Time
  • update_ _time: Updated

Thus, each table has the basic two fields Oh!

4 Summary

In database design, pay attention to the following points

  • Table Relationships
  • Single index and combination index
  • Table Structure
  • Timestamp
  • The only index

    reference

  • High Performance MySQL Third Edition
  • Java combat pay electronic business platform

Guess you like

Origin www.cnblogs.com/JavaEdge/p/12231786.html