I'm starting to use VueJS with Firebase (and VueFire), but I'm starting to struggle a bit about how to structure the data.
My case is pretty simple.
I have a list of suppliers and a list of products.
A product can only be linked to one supplier, and a supplier can have multiple products.
And I have different views :
- List of all products for all suppliers
- List of products for one supplier
- Detail of one product with the supplier.
For the 1st and 2nd views, I have no issue with the following structure
products
- productKey1
- name : Product1
- productKey2
- name : Product2
supplier-products:
- supplierKey1
- productKey1
- name : Product1
- supplierKey2
- productKey2
- name : Product2
supplier:
- supplierKey1
- name : Supplier1
- supplierKey2
- name : Supplier2
I can easily show a list of all products from "/products" and for each supplier from "supplier-products/supplierKey"
But what about a view with the product detail + the supplier detail.
What is the best way to do that ?
- Adding the supplier information into each products ?
- Add a kind of foreign key into products ?
- Another way to do it ?
Thanks for your help.