Getting "number of referencing and referenced columns for foreign key disagree" in PostgreSql

Viewed 7628

I'm creating a few tables in pgAdmin 4, but I keep getting the error it the title for some reason, can you spot why? I don't see any problem and i've looked into other code samples similar to mine which compiled perfectely. It also runs OK in IDEone (http://ideone.com/ZBn2Nr).

thanks!

Create table item
    (iname varchar(30) primary key,
    itype varchar(30));

Create table Cafe
    (license numeric(5,0) primary key,
    cname varchar(30),
    address varchar(30));

Create table Client
    (cid numeric(5,0) primary key,
    name varchar(30),
    phone numeric(9,0));

Create table Likes
    (cid numeric(5,0),
    iname varchar(30),
    primary key(cid,iname),
    foreign key(cid) references Client,
    foreign key(iname) references item);

Create table Sells
    (license numeric(5,0),
    iname varchar(30),
    price float check(price > 0),
    primary key(license,iname),
    foreign key(license) references Cafe,
    foreign key(iname) references item);

Create table Receipt
    (cid numeric(5,0),
    rno numeric(5,0),
    license numeric(5,0),
    rdate date,
    primary key(cid,rno),
    foreign key(cid) references Client,
    foreign key(license) references Cafe);

Create table Buys
    (cid numeric(5,0),
    rno numeric(5,0),
    iname varchar(30),
    amount int check(amount > 0),
    primary key(cid,rno,iname),
    foreign key(cid) references Client,
    foreign key(rno) references Receipt,
    foreign key(iname) references item);
1 Answers
Related