Thursday, 15 March 2012

mysql - Is it always a terrible idea to store semantic data in IDs? -


Here are some (incomplete) database tables that store information about hotel rooms, the information that they store Is similar, but their design is different:

  1. Information about store flows in a separate column:

      | ID | Floor | ---- | ------- | 1 | 1 | 2 | 1 | 3 | 2 | 4 | 2    
  2. Store flow information in ID.

      | ID | ----- | 101 | 102 | 201 | 202         To correct this ?   

    If you want to use a natural key, use a natural key to use a natural key Do not name id .

    If you use synthetic keys, consider it as an arbitrary value that should be unique, but it has no other meaning.

No comments:

Post a Comment