|
Sorry if this belongs in the Coding Forum.
I'm restructuring the mySQL database for my site to separate news, articles and videos into their own tables. The current system has them all under a single "posts" table, but I have extraneous fields for each group ("sources" just for news, "thumbnails" for videos and articles, etc.) that wind up empty two thirds of the time. I've read that it's best to keep tables concise, so that's the reason for the change.
Now, in order to get content from all three tables to show up in the same feed on the front page (ten at a time, sorted by date), I'm using CREATE TEMPORARY TABLE to basically recreate the structure I had to begin with dynamically. I know this can't be ideal: if nothing else, it probably slows down my page (I haven't actually timed it, though).
But since the tables don't line up I can't use UNION. I haven't really experimented with JOIN, but from what I've read I'm pretty sure that it isn't what I'm looking for either.
So, am I stuck using temporary tables? And, if so, should I just go back to my original structure where everything is in a single table and opt for speed over cleanliness?
The tables I have right now are set up something like this:
Table: news
Fields: id, title, url, author, date, body, sources
Table: articles
Fields: id, title, url, author, date, summary, body, thumbnail
Table: videos
Fields: id, title, url, author, date, embed_src, description, thumbnail
|