简体   繁体   中英

Repeating Many-To-Many Relations

I have one entity Order and one entity Product .

It should be possible to add one product several times to an order, but with Doctrines default many-to-many-relation there can be only one relation in the join-table . Is there a way to solve this without an extra entity and two one-to-many-relations ?

Why add a Product many times to an Order? Make it a many-to-many relation with a Quantity column added to it. One Product with a Quantity of N should satisfy your wish.

No, you need an OrderLine table. Many-to-Many can exist conceptually, but in a relational database you can't. You have to break it into two Many-to-one relationships

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM