Postgres Constraints

Creator
Creator
Seonglae ChoSeonglae Cho
Created
Created
2022 Apr 13 11:58
Editor
Edited
Edited
2023 Mar 11 9:6
Refs
Refs
ALTER TABLE public.reservations ADD CONSTRAINT reservations_room_id_fkey FOREIGN KEY (room_id) REFERENCES public.rooms(id); ALTER TABLE public.reservations ADD CONSTRAINT reservations_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
ALTER TABLE public.reservations ADD CONSTRAINT daytime_check check (start_time::time >= '08:00:00' AND end_time::time <= '17:00:00')
 
 

Constraints

Postgres Constraints for Newbies
One of the things that makes Postgres so awesome for software development is the incredibly useful system of constraints. Constraints are a way to tell Postgres which kinds of data can be inserted into tables, columns, or rows. As an application developer, you're going to build in this logic to your application as well and that's great.
Postgres Constraints for Newbies
 
 

Recommendations