Users and accounts ER diagram

How users and accounts will be modeled in the database

How users and accounts will be modeled in the database

This ER diagram shows the database implementation of the tables modelling the users, accounts and groups.

With the accounts table, there is no seperate between if an account is a company account (account which leads a project) or a client account (the account on the receiving end of the project) as this distinction is made at run time, as descipbed in this post on modeling accounts.

When describing the diagram, I’ll skip all the trivial fields, such as first_name, email etc

Key points:

  • In the users, accounts and groups tables, the primary key is simply an auto incrementing ID.
  • In the accounts table, the user_id field is a foreign key of the ID column in the users table, and this represents the account owner.
  • In the users table, the password will be a SHA1 hash, and it will be salted as well, more on this later
  • A user can optionally have a set of contact details, but at most only one entry in that table, so the users ID will act as both a primary and foreign key
  • The user/account relation is many to many, meaning each account is made up of 1 or more users, and each user can belong to more then one account. This was discussed in this post about linking users and accounts

Initial database tables

The following is an initial list of database tables. A lot of the tables for sections (messaging, tasks, milestones etc) are likely to change as those sections evolve. The users, account and project tables seem pretty fixed.

I’ll get an ER diagram up in the next few days for the first couple of tables, which will also explain more about the choices I’ve made and what fields will be included.

Accounts and users
users
accounts
account_users
groups
group_users
contact_details

Projects
projects
project_categories
project_category_projects
project_users

Messages
messages
message_categories
message_category_messages

Tasks
tasks
lists
list_categories
list_category_lists
task_priorities
user_lists
user_tasks
group_lists
group_tasks

Tickets
tickets
ticket_messages
ticket_tasks

Milestones
milestones
milestone_categories
milestone_categories_milestones

Files
files
account_files
project_files
file_versions
file_folders
file_folders_files
file_tags
file_tags_files

Comments
comments
comment_comments
project_comments
message_comments
file_comments

Times
times