mardi 11 juillet 2017

Database modeling in Laravel 5.4 with many to many relationship

I have 3 entities.

1) Kpi

2) Subkpi

3) Department

The relationship between a KPI and a Subkpi is a One to Many (a kpi can have many subkpis) and between subkpi and department its many to many. Please see example below.

Kpi - Delivery

Subkpi - Code review

Department - Engineering, Operations

This combination of Kpi and Subkpi (Delivery/Code review) can belong to both (Engineering, Operations) departments. I have 3 master tables for these 3 entities having attributes like id, name and another pivot table to store the relationship of these 3, which has attributes id(primary key), kpi_id, subkpi_id, department_id. I have 2 questions now.

Q1 - Based on the relationship above, Is the database structure is correct? If not please help me to understand it?

Q2 - If the answer to Q1 is yes, then how can I get all the kpis/subkpis belongs to a department using Laravel's Eloquent ORM?

Thanks in advance for helping me out.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2uNv5f5
via IFTTT

Aucun commentaire:

Enregistrer un commentaire