webreinvent / vaahcms

VaahCMS is a laravel based open-source web application development platform shipped with a headless content management system (CMS).
https://vaah.dev/cms
MIT License
134 stars 22 forks source link

Thoughts on the database #31

Closed TomHAnderson closed 3 years ago

TomHAnderson commented 3 years ago

Having explored the entire database in #30 I have a few thoughts I'd like to share.

This would simplify the schema immensely.


Next, the vh_user_roles table is named wrong were it an actual many to many pivot table. But it is not and there is not a unique index on vh_user_id + vh_role_id and those columns are not not null (see next comment).


Not Null columns. Nowhere in the schema except for primary keys are columns marked as not null. This is a flaw in the database design and should be addressed directly.

themodernpk commented 3 years ago

- pseudo foreign keys : Are you referring to:

$table->integer('created_by')->nullable()->index();
$table->integer('updated_by')->nullable()->index();
$table->integer('deleted_by')->nullable()->index();

We have those relationships to serve some purpose in future development.

- vh_audit We do have plans to introduce vh_activities but not a priority at this point.

- vh_user_roles You did not suggest the name, did you mean it should be vh_user_role?

- Not Null columns nullable() columns have helped us in handling multiple scenarios at the code level. If we make this change in migration, we may have to test the entire application and review the code. If you have an explanation for this, I would like to learn.