beam icon indicating copy to clipboard operation
beam copied to clipboard

improve Postgres example with foreign keys

Open peterbecich opened this issue 11 months ago • 0 comments

Related:

  • #502
  • https://github.com/haskell-beam/beam/issues/587
  • https://github.com/haskell-beam/beam/discussions/715

I think the Postgres example does not implement foreign keys. Using the discussions above maybe it can be done.

postgres=# \d address
                                             Table "public.address"
   Column    |            Type             | Collation | Nullable |                   Default                   
-------------+-----------------------------+-----------+----------+---------------------------------------------
 address_id  | smallint                    |           | not null | nextval('address_address_id_seq'::regclass)
 address     | character varying(50)       |           | not null | 
 address2    | character varying(50)       |           |          | 
 district    | character varying(20)       |           | not null | 
 city_id     | smallint                    |           | not null | 
 postal_code | character varying(10)       |           |          | 
 phone       | character varying(20)       |           | not null | 
 last_update | timestamp without time zone |           | not null | now()
Indexes:
    "address_pkey" PRIMARY KEY, btree (address_id)



postgres=# \d city
                            Table "public.city"
   Column    |            Type             | Collation | Nullable | Default 
-------------+-----------------------------+-----------+----------+---------
 city_id     | smallint                    |           | not null | 
 city        | character varying(50)       |           | not null | 
 country_id  | smallint                    |           | not null | 
 last_update | timestamp without time zone |           | not null | now()
Indexes:
    "city_pkey" PRIMARY KEY, btree (city_id)


peterbecich avatar Dec 25 '24 21:12 peterbecich