I am a simple beginner that want to learn programming and I am a little confused
I have three entities: administrator (the only seller), customer and products. Beetween these entities has to be the next relation?
- Administrator and Product (@OneToMany), Product and Administrator (@ManyToOne)
- Customer and Product (@OneToMany), Product and Customer (@ManyToOne)
Administrator is the only seller and he selles its own products and the customer can buy more products. This is the main idea of my application.
Also, do I have to create authentication and authorization part before to start relations between entities?
Can someone tell me if is it a good approach? 🙂
I tried to understand better this concept of entities relation, but I am not sure how to implement them.
2
Answers
It is not necessary to use bidirectional relationship between your entities. Just use it when you want to access each entity from the other entity in two ways.
It is better to use something like this .
I think this kind of data model is better for your purpose.
for customer and product you need to give the many to many relationship which means one customer can buy many products and one product can be buyed by many customer check the relation first .