Database Tables, more the better?

前端 未结 6 1504
旧时难觅i
旧时难觅i 2021-01-06 14:16

Lately I\'ve been rethinking a database design I made a couple of months ago. The main reason is that last night I read the databse schema of vBulletin and saw that they use

6条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-06 14:37

    I want to add a small tip. A little off topic, and quite basic, but it's a lot clearer to use enum instead of tinyint for status flags, i.e.

       enum('user','type')
    

    If there are only two statuses, tinyint is a little more memory efficient, but less clear. Another disadvantage in enum is that you put a part of the business logic in the data tier - when you need to add or remove statuses, you have to alter the DB. Otherwise it's much more clear and I prefer enum.

提交回复
热议问题