Q
Q
Quber2015-03-29 15:30:20
PHP
Quber, 2015-03-29 15:30:20

How to add different entities to the shopping cart of an online store?

Hi all.
There is a site where services and goods of different directions are sold. For example, just a link can be sold (for example, to an archive for downloading), clothes / equipment, services ala a husband for an hour. Actually, each such type of sale is its own essence. Links to archives are one entity. Goods are another entity, services are a third. Etc.
How to add different entities to the cart/order of such a store?
It comes to mind to create the Cart / Order entity, then create the Item entity, connect it with a One-to-Many connection. Create an entity View and then Descriminator Column in it, which will point to the link/product/service type. Connect Item and View One-to-many entities. Would such an approach be correct?
Below is an example diagram:
037fb0ec0e454bde851c5dad14f978e3.PNG

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timur Shemsedinov, 2015-03-29
@MarcusAurelius

There are three options here, either make subtype discriminator or document (schemaless) databases (for example, MongoDB), or in many relational DBMSs (for example, PostgreSQL) JSON columns have already been completed (where you can write all the fields that differ in different Item types, write a serialized object there, in fact).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question