Currently, I have an ‘add your ad here’ page, with a form.
Now, the user must select what category he will want to post an ad into…
So I have a table for each category in mysql.
Now my question, how would I make each ad unique, with an ID nr?
If I have several tables, the ‘auto increment’ might turn out to be the same in some ads, am I right?
How is this usually solved?
Assigning a random nr to each ad with javascript?
Remember this: I also have a ‘picture upload’ file input where I must set the picture name the same as the ad id…
Thanks
UPDATE:
If I put all ads in one table, wont this slow down the search of the database? Isnt there any other way to do this?
This is a problem of normalization. Ad’s are a distinct class of object, and all the ads should be in the SAME table. Likewise categories should be in the same table, and then you should put a category id in your ad record, assuming you need to bring in category data.
Edit: Nah, shouldn’t be an issue. I’ve seen newspaper ad systems run on that model that have millions of ads (they usually store by ad, and then by individual “run date” so 1 ad record could have a hundred run date records), and don’t take significant time to query. Just figure out how you’re going to be accessing the ads (by date, by category, etc) and set up your indexes accordingly, and you should be fine.