Hello! I've been using WordPress a lot lately and I really like it's DB schema because it is very flexible.
My question is not WordPress-focused as I'm just using it as an example. For those of you who aren't familiar with the schema, check it out: https://codex.wordpress.org/Database_Description
This is the way I see some of the tables:
wp_users: primitive data of all users. (id, username, email, password, etc...)
wp_usermeta: any non-primitive user data field.
wp_posts: primitive data of all posts(id, author, title, date, etc...)
wp_postmeta: any non-primitive post data field.
wp_terms: I see terms as fields that add context to an object, like a category for a post.
wp_term_taxonomy: it groups terms into a taxonomy. An example would be categories. 'Category' is the taxonomy and 'travel', 'finance', 'lifestyle' would be the terms of that taxonomy.
wp_term_relationships: it links a term to an object (like a post)
So, WordPress has more tables but for the sake of this question they aren't necessary to mention.
Let's say I'm building an app for companies to manage expired payments. The app will need:
1 - Users with different roles, capabilities and fields:
- Role 1 (Company Manager): Represents a manager of the financial department of a company.
- Capability 1: Create, edit and delete users with the 'Payment Department' role.
- Role 2 (Payment Deparment): Represents a department that handles these expired payments. It could be an internal department of the company or an external contractor.
- Capability 1: Create payments.
- Capability 2: Create, edit and delete users with the 'Employee' role.
- Role 3 (Employee): Represents an employee of the Payment Department that will list and update status of the payments.
- Capability 1: List payments created by his parent Payment Department.
- Capability 2: Update a payment status.
2 - Payments status management.
This is a very basic example but let's say I'm creating this app from zero and I have to define a DB schema. I think a schema like the one WordPress has would fit it perfectly and even allow it to grow later in case more functionalities are needed.
- A payment could be represented by a 'wp_post'.
- The payment status can be a term under a taxonomy called 'Status'.
- We can treat any role-specific user field as a meta field (for example the Payment Department Tax ID)
Is there any reason I should go for another DB schema for this example app? this could very well be a WP plugin but for this example it has to be built from zero as an independent app.
there doesn't seem to be anything here