I am currently developing a file hosting site just like filehippo.com. I am done with it. But, my client wants a premium membership system similar to rapidshare pro. so, only premium members get the download access in a period of time (like a month or so).
I have two tables now :
should I create a new table for the membership status? What's the best practice to do it? the logic and maybe the database structure. please give me some advice.
thanks a lot.
If they are paying for the premium membership, I would create another table and associate it to the transaction id of the payment. This will be a one user row to many premium_access rows. That way you can have a historic record of what payment was used for how many days/months of service and allow to charge discounts for 6 month or yearly memberhips and still have accurate tracking to make sure you can track down any loopholes or exploits.
Then when you want to know when they expire it would just be
select * from premium_access where user_id = '$id' limit 1 order by end_date desc
EDIT: Here is a quick mock up of a possible table structure. Use your own judgment on the columns you will need and the proper naming convention:
CREATE TABLE IF NOT EXISTS premium_access (
id INT NOT NULL AUTO_INCREMENT ,
user_id INT NOT NULL , --fk to USERS
payment_id VARCHAR(45) NULL , --fk to PAYMENTS/INVOICES
start_date TIMESTAMP NOT NULL ,
end_date TIMESTAMP NOT NULL ,
PRIMARY KEY (id) )