Skip to main content

All Questions

Filter by
Sorted by
Tagged with
-1 votes
1 answer
51 views

How to INSERT a new record into 2 tables with FKEY inheritance?

Inheritance has been setup with FKEY instead of INHERITS due to FKEY limitation. My question: How to INSERT a new record into bonds table? CREATE TABLE IF NOT EXISTS instruments ( id SERIAL, ...
John Doe's user avatar
0 votes
1 answer
137 views

make exist table as inherit

i try to create parent table for exists table, by next algorithm: -- CREATE TABLE CREATE TABLE t1 (id serial PRIMARY KEY); CREATE TABLE foreign_t1 (id serial, t1_id integer REFERENCES t1 (id)); -- ...
user avatar
0 votes
1 answer
5k views

Inheritance and foreign keys in Postgres

This is about using inheritance and foreign keys in Postgresql databases. Consider the following simplistic example whose structure is based on what I am building at the moment (but the specifics were ...
ahron's user avatar
  • 813
0 votes
3 answers
5k views

Can i have one foreign key to both parent and it's childs in postgresql?

I want to have a foreign key to reference table and it's children. Here's how I tried and failed: CREATE TABLE parent ( id serial, CONSTRAINT parent_pk PRIMARY KEY(id) ); CREATE TABLE child ( ...
Ben's user avatar
  • 257
0 votes
1 answer
654 views

Foreign key double inheritance SQLITE

I'm designing a domotic system database and I'm trying to figure out how to represent two foreign keys. This is the cardinality I want. Consider 1...N Areas (rooms, halls, kitchens, etc.): Area 1 - ...
cabreracanal's user avatar