Check out example codes for "set up foreign key relation in psql". It will help you in understanding the concepts better.

Code Example 1

CREATE TABLE so_items (
  item_id INTEGER NOT NULL,	
  so_id INTEGER REFERENCES so_headers(id),
  product_id INTEGER,
  qty INTEGER,
  net_price numeric,
  PRIMARY KEY (item_id,so_id)
);

Learn ReactJs, React Native from akashmittal.com