php - Which of these 2 database setups should I choose? -


i have 3 types of content: blogs, press releases, , reminders. of them have body , entered by fields. blogs , press releases have title field, reminder lacks, , reminders has hour field, blogs , press releases lack. looks in tabular format it's easy see...

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

i'm creating main table called content links specialized tables blogs press releases reminders. thought of 2 structures

first structure... how content management system use it, don't want follow in steps blindly because needs not same. put shared fields in main content table. content table not have type , type id link specialized tables, content table have common fields body , entered by. other 3 tables have 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 

second structure. content table has type , type id necessary link other 3 tables, means common fields repeated in 3 tables.

content table    b=blogs table   pr=press releases table     r=reminders table ------------------------------------------------------------------------------ id               id              id                          id type=b/pr/r      entered      entered                  entered  type id          body            body                        body                  title           title                       hour 

which should go with? thought first structure better because can search content whether it's blog or press release or reminder specific word. still have in other tables if want search title available blogs , press releases, but...

so structure better, , why think so? i'm open other ideas or improvements different these 2.

the first 1 better construct, allows content have specific set of required or common data in content table , specialized data in child tables. allows add more types in future other requirements still reuse common elements in content retain unique data.

one other key question if data required, example reminders require hour , blogs/press release require title. if required ensure child tables populated. if not perhaps should @ flattening structure (yes virginia should denormalize).

so instead content table becomes (nn = not null, n = nullable) id (nn) ,type id (nn), type (nn), body (nn), entered (nn), title (n), hour (n). main reason find doing if different data entities creating similar on time possible merge. example reminders @ time not require title, in future might.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -