SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Dec 2007
    Posts
    348
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simply SQL CMS App - why is content stored in another table

    Hi Rudy, I'm loving your book!

    I do have one question though, in the CMS app you have in there, you've defined a seperate 'content' table for the entries' content - why did you do this?

    if it's just a 1-to-1 relationship why not just store it in the entries table?

    I do understand that some entries might have different sorts of content which may be stored in different tables but even so wouldn't that require a different table structure anyway?

    i.e.

    entries
    content_type_a
    content_type_b
    content_type_c

    ?

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    thanks for the kind words

    there are actually two questions intermingled here

    different sorts of content in different tables would make sense, but i never touched upon that aspect, and considered all content to be of the same type -- with a generic "content" column that would, presumably, hold html

    you might have noticed that the content column actually started out in the entries table, but was then split off into its own table

    i think i had an explanation for that, but either i can't find it or it got edited out

    the idea is that if you wanted a multilingual web site, you can easily change the one-to-zero-or-one relationship into a one-to-zero-or-many by adding a language column in the contents table, so that the primary key would be composed of the entry_id (foreign key) and the language code
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Member
    Join Date
    Dec 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    With having the content field as a separate table, you could actually "break" the one-to-one relationship and use additional entries for things such as comments on the original posting.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •