I need to create a table in the database and query this table if specifically on the frontend we receive something like:
self-delivery reception: 10:00-13:00
deadline for admission: 19:00
deadline: 12:00
order acceptance:
{morning: 12:00-13:00}{evening: 16:00-17:00}
We have a structure:
Title string
Value string
Intervals []*Intervals
Which refers in one of the fields to another structure.
Structure:
Title string
Value string
I have created 3 tables:
- table of usual values
INSERT INTO delivery_conditions(title, val)
VALUES ('self-delivery reception', '10:00-13:00'),
('deadline for admission', '19:00'),
('deadline', '12:00');
- table links to another structure
INSERT INTO delivery_intervals(title, val)
VALUES ('order acceptance', 1);
- table for different structure
INSERT INTO customers.intervals_settings(title, val)
VALUES ('morning', '12:00-13:00'),
('evening', '16:00-17:00');
I also wrote a query in which I combined the fields of the third table with the json object
SELECT
sfc.title,
sfc.val,
json_build_object(
'title', sfi.title,
'val', sfi.val
) AS interval
FROM delivery_conditions sfc
JOIN delivery_intervals sfi ON sfi.conditions_id = sfc.id;
as far as I understand, my method is not at all correct and I would be very grateful to people who will explain how to act in such situations.