E
E
EVOSandru62017-09-04 15:30:29
PostgreSQL
EVOSandru6, 2017-09-04 15:30:29

What is the best entity to pack the intermediate in the offer->intermediate_link->coupon?

Good afternoon.
There are 2 tables
offers (offer)
.id
.date_from
.date_to
.name
deals (coupons)
.id
.offer_id
.name
.price_from
.price_to
This was originally the final structure. But the customer made changes and a hierarchy appeared:
Offer_1
Entity_intermediate_link - 1 day
Coupon_1 person - own price
Coupon_2 people - own price
Entity_intermediate_link - 2 days
Coupon_1 person - own price
Coupon_2 people - own price
Moreover, Entity_intermediate_link - own pricemay be completely absent or, for example, there may be a combined version of the offer, where some coupons fall directly from it, and some from Essence_intermediate_link
Please advise - where is the best place to put this thing. I roughly believe that there are several solutions:
1. Make the offer hierarchical
2. Make the coupon hierarchical
3. Create a new table
Give good advice, fellow programmers.
According to 1-2 options, it is embarrassing that some fields in their case will be empty.
According to the 2nd option, it is confusing that it will be necessary to add the type (deal / category) field.
In the third, I don’t see any special advantages.
In addition to the question, if 1. or 2. - would it be correct to store the hierarchy in the adjacency list?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question