Answer the question
In order to leave comments, you need to log in
How to avoid collision in on site in db?
Good afternoon,
There is such a data structure: hotel
users room rate per room (for one person, for 2, etc.) sub- application applications ( here is a sore point) - a necessary item (!?) referring to the tariff, depending on the number of people in the room, the process (so called the element where the user and the room are connected for this application)
Unfortunately, you cannot specify a specific coefficient for each hotel that calculates the cost of a room for a certain number of people - and this the number can be arbitrary.
The user creates an application where he can select an arbitrary number of rooms and populate them with an arbitrary number of people.
Structure:
users
---------
id
hotels
---------
id
bids
---------
id
rooms
---------
id
hotel_id
tarifs
-- -------
id
room_id
subbids
---------
id
bid_id
tarif_id
mc_processes
---------
id
user_id
room_id
subbid_id
There are 2 points that interest me:
1. I really don't like that when editing the number of people in a certain room ( processes ) an additional process will change the tariff ( tarif_id) in a subbid ( subbids ) , it seems very bad (
2. If 1. is inevitable - is it possible in postgres to make this function happen in it. For example:
if update count () of processes where subbid_id = x ... update subbids set tarif_id = (count () of processes where subbid_id) where subbids.id = x
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question