V
V
Volokoron2021-01-20 08:36:40
PostgreSQL
Volokoron, 2021-01-20 08:36:40

"Complex" constraint for SQL character field?

Can the database perform such a check?

CREATE TABLE flyght_details
(
table_id int PRIMARY KEY,
flight_id int,
aircraft_code varchar,
seat_no varchar,
fare_conditions varchar CHECK (fare_conditions IN ('Economy' < 150 записей, 'Comfort' < 30 записей, 'Business' < 20 записей))
)


I'm doing a training project in Java booking airline tickets. In order not to sell extra tickets, I think what kind of check should I organize?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2021-01-20
@Volokoron

No, CHECK is only for current record data. Yes, even if you put a custom function there, such checks will lead to more difficult to detect problems than they will be useful.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question