Welcome Guest, Not a member yet? Register   Sign In
Mysql Table Critique
#1

[eluser]CI-Newb[/eluser]
Hello, I'm semi-new to the whole database end of things. I was just wondering if anyone could look over this table structure for me and let me know if I have everything as optimal as can be as far as performance is concerned, if there's any changes I should make, etc. Thanks for the feedback.

Code:
+----------------+--------------------------------------------------+------+-----+----------+----------------+
| Field          + Type                                             + Null + Key + Default  + Extra          +
+----------------+--------------------------------------------------+------+-----+----------+----------------+
| id             | int(11) unsigned                                 | No   | PRI | NULL     | auto_increment |
| account_status | enum ('inactive','active','expired','suspended') | No   |     | inactive |                |
| account_type   | enum ('user','club','admin')                     | No   |     | user     |                |
| username       | varchar(20)                                      | No   | UNI | NULL     |                |
| email          | varchar(120)                                     | No   | UNI | NULL     |                |
| password       | char(40)                                         | No   |     | NULL     |                |
| salt           | char(32)                                         | No   |     | NULL     |                |
| activationcode | char(32)                                         | No   |     | NULL     |                |
| pwrdresetcode  | char(32)                                         | No   |     | NULL     |                |
| created        | datetime                                         | No   |     | NULL     |                |
| updated        | datetime                                         | No   |     | NULL     |                |
+----------------+--------------------------------------------------+------+-----+----------+----------------+
#2

[eluser]Aken[/eluser]
The clubid column could be a SMALLINT instead, if you foresee it never exceeding four digits. You'll save two bytes of storage for each entry there over using INT. If this column has a foreign key constraint, the other column needs to have the same settings.

The ENUM fields could be replaced by a lookup table method, reducing the actual amount of stored data, and making the entire thing easier to update. http://stackoverflow.com/questions/76121...343#761343

Your CHAR columns are okay, if the content of those columns will ALWAYS be that length (no more, no less). Otherwise they should be VARCHAR.

Your salt column may be unnecessary if you use an appropriate way of hashing passwords. See this PHPass library. No idea if it's out of date at all, but PHPass is acknowledged as one of the best libraries for password hashing.

That's all I can spot given my DB knowledge.
#3

[eluser]CI-Newb[/eluser]
Thank you very much. The clubid field has been removed I forgot to remove it before posting. the char columns will always be those exact lengths yes. I will look into the password hashing & lookup table method you've linked to! Thanks for the comments!




Theme © iAndrew 2016 - Forum software by © MyBB