06-06-2012, 04:16 PM
[eluser]Abel A.[/eluser]
Ok, I get what you're trying to do now. For one, it's bad DBA to have multiple tables for different articles. The solution would be to merge all the article tables together and have a column to distinguished what type of article it is.
Article Table:
id, author, date, type
If you have columns that are unique to certain articles, then you can create a new table with the extra unique columns and have the Article id column as the foreign key. This way, you can just use a join for the extra fields.
Here's an example of a db structure:
Table articles:
articleid, author, title, date, opened, visible, type
Table user:
userid, username, email, password
Table comments:
commentid, articleid, commentbody, author, date
Now say that an entertainment article has unique columns that the rest of the articles don't have, then you can do this:
Table entertainment_extras:
articleid, unique1, unique2, unique3
articleid is the foreign key.
As you can see, you can just add extra tables and Join them. Alternatively, if you don't want to change your db structure then creating a view would be best.
Ok, I get what you're trying to do now. For one, it's bad DBA to have multiple tables for different articles. The solution would be to merge all the article tables together and have a column to distinguished what type of article it is.
Article Table:
id, author, date, type
If you have columns that are unique to certain articles, then you can create a new table with the extra unique columns and have the Article id column as the foreign key. This way, you can just use a join for the extra fields.
Here's an example of a db structure:
Table articles:
articleid, author, title, date, opened, visible, type
Table user:
userid, username, email, password
Table comments:
commentid, articleid, commentbody, author, date
Now say that an entertainment article has unique columns that the rest of the articles don't have, then you can do this:
Table entertainment_extras:
articleid, unique1, unique2, unique3
articleid is the foreign key.
As you can see, you can just add extra tables and Join them. Alternatively, if you don't want to change your db structure then creating a view would be best.