• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What's wrong with this code? =/

#11
[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.


Messages In This Thread
What's wrong with this code? =/ - by El Forum - 06-06-2012, 12:25 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 12:44 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 01:26 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 01:32 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 01:34 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 01:44 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 01:46 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 01:51 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 02:08 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 02:50 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 04:16 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 04:22 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 05:02 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 05:45 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.