Jump to content

php script uploading to MySQL tables


alexinjamestown

Recommended Posts

If I am using  the same script "add_catagory.php" and there are ten different catagories like "apples, oranges, strawberries, etc... " and it is uploading to MySQL and a table I'll call "uploads" and uploads has about 8 fields like "name, type, region, age, color, etc..." would you make a separate MySQL database for each category or have them all upload to one database?  Thanks in advance  ;D

 

Alex

Link to comment
https://forums.phpfreaks.com/topic/89650-php-script-uploading-to-mysql-tables/
Share on other sites

Is there a reason why it's better to have it uploaded to one database and not keep each category separate?  Does it make the site more efficient with searching and things like that?  Any feedback would really be great.  I'm about to link my newly designed database to my site.

I'm guessing by "database" you actually mean "table". So you would have 1 table called "apples" and 1 called "oranges" etc etc.

This is ALL wrong. Your logical division be as follows:

 

Table: fruit_categories

fields: cat_id, cat_name

 

This table will contain "apples", "oranges", "strawberries"

e.g.

1 "apples"

2 "oranges"

3 "strawberries"

 

Table: fruit

fields: name, region, age, color, CATEGORY!!!!

 

The category field is a foreign key to the fruit_categories table

 

This will contain

"granny smith", "cornwall", "18", "green", 1

"cox", "yorkshire", "2", "red", 1

 

See how it relates now?

I think you need a 101 in database normalisation ;)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.