Different availabilities at different times of the day

Hi Everyone

My used case is:

I have a set of X (say, shops). X are open throughout a normal day. However, I have another variable Y (say, active promotion). Y is hourly and can change per X throughout the day.

E.g. X1 can have Y1, Y2, Y3 in a given day
(i.e. Walmart can have 10am, 1pm, 3pm)

Also, throughout the day, though my X will be the same, the Y can change (X is static, Y is dynamic).

E.g. X1 will not have Y1, Y3 and Y4 (new time slot) β†’ Y variable needs to be dynamically updated

How can I design a database to accommodate this?

Thank you in advance!

Hello, well you can create a collection called X and another collection called Y. Then you can create a relationship between the two collection which you choose that Each x can have multiple Y and each Y belong to one X.

I see.

So since Y are hours of a day when the promotion is available and this can change every day, how would I update the mapping every day?

5 Xs can have a promotion at 1pm and 3pm. The next day, they might have it at 2pm and 8pm.

Thank you!

Hi @goyal.vishesh,

So you have collections called promotions and hours and you need to add a way to select hours for that promotion? And you should have the ability to change it every time too?

Thank you

Yes that is correct.

So I have a list of retailers (X) on one side. On the other side, I have hours of the day and each retailer can have a promotion at a particular hour (Y).

so X1 can have 10am, 1pm, 5pm
X2 can have 3pm, 6pm, 9pm
and so on…

These Y values for each X can change dynamically every day and even potentially during the day
e.g. X1 knows at noon that another promotion is going up at 4pm, so now X1 has 10am (already passed), 1pm, 4pm, 5pm

Hi @goyal.vishesh ,

You might want to add date field at Y collection and can be filtered using start of today.