Optimal database schema

I'm going to change the database schema, and I'm considering using ORM in my application. Will the following scheme work, for example with Eloquent ORM, or will I also need to add JOIN tables?

ISSUES(ID, ORGANIZATION_ID, DATE, TIME, CATEGORY_ID, TYPE_ID, ISSUE_DETAILS_ID) ISSUE_DETAILS(ID, NAME, STATUS, EMAIL) ORGANIZATIONS(ID, NAME, ADDRESS, CONTACT) CATEGORIES(ID, CATEGORY) TYPES(ID, TYPE, CATEGORY_ID) 
+5
source share
2 answers

The only thing I could do differently is to have the foreign key issue_id in the issue_details table issue_details that you can relate one to one .

So, if you used Eloquent, you could do something like this.

 echo $issue->details->name; 

I'm not quite sure what you will keep in the details table, there will probably be many details for the problem, in which case you will have a lot to do with .

+3
source

In addition to what Jason suggested, you can also remove category_id from the issues table, since each type already has a category , you already have access to the category through the type.

i.e. $issue->type->category

+1
source

Source: https://habr.com/ru/post/1413546/


All Articles