Re: news and article posts in one table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Nov 26, 2011 at 01:26:49PM -0600, Tamara Temple wrote:

> muad shibani <muad.shibani@xxxxxxxxx> wrote:
> 
> > i wanna to create one table that contains both news and articles posts,
> > they have similar columns like id, title, content, and date but they are
> > differ in one column = the source of news or article post
> > article has  writers that have permanent names and pictures obtained from
> > another table called writers that supposed to be  left joined with the news
> > table, while news posts simply have a source as text like AFP
> > or Reuters and so one.
> > 
> > How I can solve this ?
> 
> How you store things in tables can sometimes get a little tricky. One
> way to approach this is with normalized tables and using joins in your
> query like you are doing. To make this work, in your main entries table,
> have a field that indicates what the entry type is. If you are doing one
> select that gets both articles and news stories, having that extra field
> can help you distinguish what type it is, and which fields contain data
> in each record.
> 
> (cf: Wordpress wp_posts table for an example of how this is done. They
> store posts, pages, and attachments in a single table this way. I can't
> say if this is a better arrangement than keeping them in separate
> tables.)

I've had to hack this table. It's a prime example of bad design. Take a
long look at the records of this table in an active blog, with a survey
of each of the fields and their values. You'll see what I mean.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux