liamloveslearning Posted May 10, 2010 Share Posted May 10, 2010 Hi everyone, Im about to start building a membership based website (My first one) and I need to implement 3 different membership options, each with sub options within those categories. My 3 options will be bronze silver and gold, each option with have a sub option of 3 month, 6 month and 12 months. The difference will be option 1 can upload 3 images to the website, option 2 can upload 6 and option 3 can upload however many he wants. Im trying to decide the best way of how to do this, Would my best option to store a value corresponding to the membership purchase in the database? Or store them in different tables? Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted May 10, 2010 Share Posted May 10, 2010 I'd make a plan table: id | name 1, Bronze 2, Silver 3, Gold Then in your members / users table you can just add the following columns: id | member_name | ... | plan_id | sub_length_in_months | sub_renewal_date Or something like that. Quote Link to comment Share on other sites More sharing options...
liamloveslearning Posted May 11, 2010 Author Share Posted May 11, 2010 Ahh brilliant, can I ask what sub_length in months would equate to? Also is there a documentation on the best practice for creating user membership tables? Quote Link to comment Share on other sites More sharing options...
liamloveslearning Posted May 11, 2010 Author Share Posted May 11, 2010 Ahhh sorry its just clicked, so the lenght will be amount of time remaining on their membership and renewal date will be the date theyre sent an email to renew? sorry about the naivity! On my pages however where I want to restrict amount of images uploaded, would you use an else if statement? so IF bronze display 3 upload fields, ELSE display 6 etc? Quote Link to comment Share on other sites More sharing options...
ignace Posted May 11, 2010 Share Posted May 11, 2010 Just by reading your question I can think of multiple ways to achieve this, but your best bet would go to: plan (id, name, maximum_uploads) -- convention: 0 is unlimited member (id, username, password, ..) member_plan (member_id, plan_id, date_purchased, length_in_months) SELECT .. FROM table WHERE date_add(date_purchased, INTERVAL length_in_months MONTH) > now() Quote Link to comment Share on other sites More sharing options...
liamloveslearning Posted May 11, 2010 Author Share Posted May 11, 2010 Brilliant, thanks Ignace, when displaying the data on my pages would i use conditional statements based on the plan_id? Sorry for all the questions Quote Link to comment Share on other sites More sharing options...
ignace Posted May 11, 2010 Share Posted May 11, 2010 Sorry for all the questions No need to say sorry this forum's primary goal is for you, me and many others to ask questions. when displaying the data on my pages would i use conditional statements based on the plan_id No just use the maximum_uploads and the number of uploads the user has already made in a conditional statement and deny the upload if they exceed it. After giving this some more thought I came up with: plan_status (id, name) -- Silver, Bronze, Gold plan_license (id, length_in_months) -- 3, 6, 12, .. plan (id, status_id, license_id, maximum_uploads, pricing) member_plan (id, member_id, plan_id, date_purchased) In the future you may want to expand to to 24 or more months, you also may want to change the maximum uploads & price according to the status & license. You also may want to keep track of all plans a user has bought to come up with the most popular plan. I don't have the full background as your client may have in what he wants and at best I can guess, it's up to you to ask questions to your client to gain a full understanding of what he wishes to achieve and modify your design accordingly. Quote Link to comment Share on other sites More sharing options...
liamloveslearning Posted May 11, 2010 Author Share Posted May 11, 2010 Thanks ignace, The website im designing is for myself, Ive built simple membership websites n the past, but Id like to learn how to develop websites where the user can choose from a range of options and have the possibility to upgrade there plan at any given moment. Thanks again Quote Link to comment Share on other sites More sharing options...
liamloveslearning Posted May 11, 2010 Author Share Posted May 11, 2010 Im trying to sketch out my tables to before i start building anything, However I need to allow users to choose x amount of categories and upload x amount of audio clips dependant on their license. Would this be a valid way of going about that? plan_status (id, name) -- Silver, Bronze, Gold plan_license (id, length_in_months) -- 3, 6, 12, .. plan (id, status_id, license_id, maximum_uploads, maximum_audio_uploads, maximum_categories, pricing) plan_categories (id, primary_category, sub_category) member_audio (id, member_id, uploaded_file) member_plan (id, member_id, plan_id, date_purchased) Im a bit confused on how to limit the maximum audios? It seems to click for a second or two then I lose it Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted May 11, 2010 Share Posted May 11, 2010 I might want to think about the situation where a member might be a bronze member with X uploads. However, they really want Y uploads, where Y > X but they don't need the other benefits of the silver plan. So think now how you might offer this option for a member: You can be a member of plan P which comes with X uploads, but you can also purchase extra uploads without upgrading your plan costing M per extra upload slot. To that end, I'd probably have a column in the DB, probably on the user's record, called uploads_remaining. This column would be integer relating to the uploads allowed by the user's plan and any additional uploads they may have purchased. Quote Link to comment Share on other sites More sharing options...
liamloveslearning Posted May 11, 2010 Author Share Posted May 11, 2010 Thanks for bringing that up roopert thats an excellent point, very valid too and I could see it happening, As this is the most complex table structure ive ever built tho I have no idea how id go about producing this. Am i correct in assuming, when a user takes out the plan, the photo uploads value is inserted into the uploads remaining, and when users purchase additional photo uploads, I build an update function which updates the uploads_remaining field accordingly? Quote Link to comment Share on other sites More sharing options...
ignace Posted May 11, 2010 Share Posted May 11, 2010 To that end, I'd probably have a column in the DB, probably on the user's record, called uploads_remaining. This column would be integer relating to the uploads allowed by the user's plan and any additional uploads they may have purchased. Indeed. And in most cases (if you were to develop this for a real client) your client would want to run analytics on your software like how many people purchase extra slots? So that he can see the needs of his market and he knows where to invest his money next when he wants to expand your software. This would mean you would need to keep track of these purchases for each customer of your client. Also don't tie yourself to my database design most presumably it won't fit the bill. Quote Link to comment Share on other sites More sharing options...
liamloveslearning Posted May 11, 2010 Author Share Posted May 11, 2010 Thanks ignace, What would be the best way to track the analytics? And would it be best practice to plan and build all of my tables etc before I even start the php coding? Quote Link to comment Share on other sites More sharing options...
ignace Posted May 11, 2010 Share Posted May 11, 2010 And would it be best practice to plan and build all of my tables etc before I even start the php coding? No, you can adhere to the Agile development philosophy and that's to start out small by the things you know you need now, you implement new features as you gain a deeper understanding of the domain-model (the knowledge on the subject) like roopurt's suggestions or mine. Quote Link to comment Share on other sites More sharing options...
liamloveslearning Posted May 11, 2010 Author Share Posted May 11, 2010 Awesome! thanks for all the help Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted May 11, 2010 Share Posted May 11, 2010 There's a rule in software development that is often difficult to follow: Never add or program more than you have to. If you don't need the ability for people to purchase extra slots right now, then do not add it. But do spend some time to think about how this software is likely to be used and what extra features may be requested later. Then think about how they may fit into your current design. Quote Link to comment Share on other sites More sharing options...
liamloveslearning Posted May 12, 2010 Author Share Posted May 12, 2010 Yeah i see where your coming from roopert, Its a god idea however and I'd prefer to implement it at this stage, Thanks for the advice Quote Link to comment Share on other sites More sharing options...
ignace Posted May 12, 2010 Share Posted May 12, 2010 Never add or program more than you have to. Also referred to as YAGNI (You Ain't Gonna Need It) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.