i will create schema the database MySQL. There are username, password etc and rating system and available in month. Standard it looks like this:
id | username | password | january | february | march | rating1 | rating2| rating3 | 1 | john | xxx | 1 | 0 | 1 | 3 | 3 | 6 2 | amy | xxx | 1 | 1 | 0 | 1 | 6 | 3
if a user buys article then must add a rating (1,2,3). if chose 2 in John then rating2 +1
id | username | password | january | february | march | rating1 | rating2| rating3 | 1 | john | xxx | 1 | 0 | 1 | 3 | 4 | 6 2 | amy | xxx | 1 | 1 | 0 | 1 | 6 | 3
january, february (1 - available, 0 - not available)etc set himself John or Amy.
this is good? Should I create separate tables for Januar/feb/march and ra开发者_C百科ting1/2/3? Maybe only for rating?
im not a hard core database designer but at a glance this is schema is not normalized.
if you can create a separate table for month and rating would be better please find the below sample
d | username | password
1 | john | xxx
2 | amy | xxx
id | month | rating
1 | 1 | 3
MonthID | MonthName
1 | January
How ever this sujjestion may not be the ideal solution for your proposed database.
OK I know this is late but this is very serious!!!
First use bcrypt for encrypting passwords
Second NEVER store a password that is not encrypted properly. You need a "salt" to do this correctly.
See here: http://www.nathandavison.com/posts/view/13/php-bcrypt-hash-a-password-with-a-logical-salt
I'm not a php guy but it looks good.
As for the DB, Prabhakantha's answer looks OK but might not be complete suitable.
Users
id | username | password | salt
1 | john | xxx | blah
2 | amy | xxx | ughh
ratings
id | month_id | rating
1 | 1 | 3
Months
id | month | year
1 | January | 1990
I know in the ruby on rails world I would model this with a polymorphic association. Take a look how that works here: http://railscasts.com/episodes/154-polymorphic-association
Yes it is a video on rails but it applies here.
精彩评论