Which of these 2 database setups should I choose?

前端 未结 4 1089
猫巷女王i
猫巷女王i 2021-01-21 09:29

I have 3 types of content: blogs, press releases, and reminders. All of them have a body and entered by fields. The blogs and press releases have a

4条回答
  •  南笙
    南笙 (楼主)
    2021-01-21 10:18

    I would sooner go without any sort of "type" field, instead making four tables: content, blogs, pressreleases and reminders. Content has the common fields enteredby, body, and title. For each of blogs, pressreleases and reminders, they have an id that is a primary key and also a foreign key to a content id. This makes a 1:1 "is-a" relationship. reminder can have the additional time field. To determine what type of entry a content row is, do a join select.

    This may not be the best in terms of performance but it's better normalized.

提交回复
热议问题