How do I structure my blog engine's database for multiple post types like Tumblr? -


i'm building blog engine has multiple post types, e.g.: text, image, link, quote.

the way see it, have 2 options:

option 1: single posts table columns, of inevitably null

post table ========== * post_id * created_at * updated_at * user_id * post_type * text * image_url * link_url * quote_source 

option 2: separate tables each post type

post table ========== * post_id * created_at * updated_at * user_id * post_type  text table ========== * post_id * text  image table =========== * post_id * image_url 

i think hint. pros/cons of each approach?

does know tumblr does? (it's not clear api docs.)

avoid using multiple tables entities (in case "posts"). have no idea how tumblr it, it's more similar first post, fields null in each row, , executable code evaluates post_type value determine how handle it.

multiple tables become nightmare you're pulling data several tables handle "one" request. example, if wanted select posts, of types, in last week, you'd have select each table , merge results (either in sort of sql temp table, or programmatically in script/executable code). , that's simple thing. imagine searching, etc.

again, don't know how tumblr it, nor "right" way - efficient way 1 table.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -