3: Don't worry about the receive_emails field. Keep in mind that your database is just a model of the real world and should not be perfect. Yes, you can make the "recipients" your own table. Think about what you gain and what you lose. Be that as it may, this is not a bad design. You can use a trigger to set receive_emails to false if the user is not a recipient. Or use the view to hide the field for applications that work with drivers or managers. Just as you like. Well, if you really want to get rid of the field, you can have an emeil_recipients table containing all the user IDs that are the recipients of the emails. You see, there are many ways to solve this problem, and all of them have their advantages and disadvantages. Your design is fine.
2: As I understand it, each package has up to one manager, one driver and one recipient. This is true? Then why do you have a table of "owners"? Place the three fields in the packages table; user_id_driver, user_id_manager, user_id_recipient. Thus, your model is much closer to reality. (You can create the owners view to replace the owners table during the migration.)
1: Now in conglomerates. The easiest way would be to introduce two new tables: first you would have a table "company_groups" with an identifier and, possibly, a description field. Your "users" of the table will have a "company_group_id" field, which will replace the "company_id" field. Thus, you associate users with groups of companies, and not with individual companies. Your second new table will be "company_group_members" with two fields: id_company_group and id_company. You would create “groups” consisting of only one company (for managers, recipients and drivers) and groups consisting of a larger number of companies (conglomerates for conglomerate managers). Thus, your database does not change so much, but offers everything you need.
Having said all this, you can still think about reducing the "users" of the table to common fields and have new tables "managers", "recipients", "drivers" and "conglomeration" that contain additional fields. This brings you closer to reality and improves connectivity with packages. However, this is due to a more different model from your current one. And what if you add co-authors, secretaries, or anything else? Every time a new table for a new job? Again: There are many ways to build your model. Choose the one that suits you.
I hope my advice will help you think through everything.
source share