For all applications a solid database design is absolutely essential, for small applications, a well designed database may mean the application is practically done.
Almost all applications require a users table which tends to be overly bloated. A typical structure looks something like this
Now this is all good but this has several flaws
- The table has to be changed whenever any of the attributes changes
- The table and any helper files you may have (models, migrations, forms, controllers etc) are not reusable across your different projects
- You can not easily test access control functions
- You will end up with a lot of “ifs” to determine existence of data or even worse role the user plays.
We need to clean this up to a couple of separate tables like this
This finally leaves us with clean and reusable structure
You should consider applying the same concepts to all your tables, general rule should be if a table has any group of attributes that you seem to use a lot together, strip them out and build a new table for them.
Till next time. Happy coding!