Is it possible to reference one column as multiple foreign keys? ( PostgreSQL )

Jackson Kasi - Aug 29 '22 - - Dev Community

NOTE: I am new for psql

How to add two different table column as reference in one field ( column ) in PostgreSQL

Image description

case:

  • I my case, I have 3 table, "salary", "user_management", "driver_management"
  • "user_management" and "driver_management" both table have column "user_id"
  • "user_id" in these two separate tables should use only one column "salary" > "user_id" as reference.

below my psql query:

create table salary (
  "id"  SERIAL PRIMARY KEY,
  "user_id" VARCHAR REFERENCES user_management(user_id) REFERENCES driver_management(user_id),
   "basic_pay" INT,
  "pay_group" VARCHAR,
  "pay_method" Pay_Method,
  "pay_cycle"  Pay_Cycle,
  "bank_name" VARCHAR,
  "account_number" numeric(26),
  "lmts" timestamp default current_timestamp
);
Enter fullscreen mode Exit fullscreen mode
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player