Which of these two database settings should I choose?

I have 3 types of content: blogs, press releases, and reminders. They all have fields bodyand entered by. Blogs and press releases have a field titlethat the reminder does not have, and reminders have a field hourthat does not have blogs and press releases. This is what looks like a table format, so it's easy for you to see ...

                   blog       press release      reminder
---------------------------------------------------
entered by field   yes        yes                yes
body field         yes        yes                yes
title field        yes        yes                --
time field         --         --                 yes

I create a main table called contentthat refers to specialized tables blogs press releases reminders. I was thinking about 2 structures

The first structure ... This is how the content management system does it, but I do not want to blindly follow them because my needs do not match. Put ALL common fields in the main table content. Thus, the table contentwill not have typeand type idfor links to specialized tables, the table contentwill also have common fields, such as bodyand entered by. The remaining 3 tables have only their own unique fields.

content table    B=blogs table   PR=press releases table     R=reminders table
------------------------------------------------------------------------------
id               id              id                          id
type=B/PR/R      title           title                       hour
type id
body
entered by

The second structure. The table contenthas only tags typeand type idis needed to link to the other 3 tables. This means that common fields are repeated in three tables.

content table    B=blogs table   PR=press releases table     R=reminders table
------------------------------------------------------------------------------
id               id              id                          id
type=B/PR/R      entered by      entered by                  entered by 
type id          body            body                        body
                 title           title                       hour

? , , , - . , title, blogs press releases, ...

, , ? , 2.

+3
4

- , , . , , .

: , , , /- . , , . , , , (, ).

, (nn = not null, n = nullable) id (nn), id (nn), (nn), body (nn), (nn), title (n), hour (n). , , , , , , . , , .

+2

. , ContentID, .

alt text

+3

- , : , , - . , , . , pressreleases , , , . 1:1 "is-a". . , , .

, .

+1

, . ?

, .

0
source

All Articles