Type: \copyright for distribution terms \h for help with SQL commands \? for help with psql commands \g or terminate with semicolon to execute query \q to quit postgres=# CREATE TABLE Actor (id integer, name varchar(32)); CREATE TABLE postgres=# select * from Actor; id | name ----+------ (0 rows) postgres=# insert into Actor (id,name) values (1,'HHG'); INSERT 0 1 postgres=# select * from Actor; id | name ----+------ 1 | HHG (1 row) postgres=# create table Movie (id integer, title varchar(32)); CREATE TABLE postgres=# insert into Movie (id, title) values (1, 'A'); INSERT 0 1 postgres=# insert into Movie (id, title) values (2, 'B'); INSERT 0 1 postgres=# insert into Movie (id, title) values (3, 'C'); INSERT 0 1 postgres=# select * from Movie; id | title ----+------- 1 | A 2 | B 3 | C (3 rows) postgres=# create table Role (aid integer, mid integer); CREATE TABLE postgres=# insert into Role (aid, mid) values (1,2); INSERT 0 1 postgres=# select * from Role; aid | mid -----+----- 1 | 2 (1 row) postgres=# insert into Role (aid, mid) values (2,2); INSERT 0 1 postgres=# insert into Actor (id,name) values (2, 'X'); INSERT 0 1 postgres=# select * from Role where mid=2; aid | mid -----+----- 1 | 2 2 | 2 (2 rows) postgres=# select * from Role where mid=3; aid | mid -----+----- (0 rows) postgres=# select * from Role where mid=2; aid | mid -----+----- 1 | 2 2 | 2 (2 rows) postgres=# select a.name from Role r, Actor a where r.aid=a.id and r.mid=2; name ------ HHG X (2 rows)