I'm struggling a bunch with some relatively simple Postgres that I was originally trying to define in Prisma but wasn't having much luck. It's a many to many relationship joined on a single field between two tables as such:
CREATE TABLE scheduleDate (
schedule_day_number int NOT NULL
, schedule_date date NOT NULL
,CONSTRAINT scheduledate_pkey PRIMARY KEY (schedule_date, schedule_day_number)
);
CREATE TABLE schoolDayBlock (
start_time varchar(10) NOT NULL
, end_time varchar(10) NOT NULL
,school_block_day_number int NOT NULL
, block_name varchar(10) NOT NULL
,CONSTRAINT schooldayblock_pkey PRIMARY KEY (start_time, end_time, school_block_day_number, block_name )
);
I eventually want to be able to get all the possible combinations between these two tables with the day number fields being the link. Ideally, later down the line, I can query Prisma for a block name and get all of the dates and times where that block name shows up. Does anyone know how I could
- Write this up in a Prisma schema or
- Write this up in postgres.sql and use introspection to generate a Prisma schema that accomplishes this.