Table 1: Schema for the bookworm database. Primary keys are underlined. There are some foreign key references to link the tables together; you can make use of these with natural joins.
Author(aid, alastname, afirstname, acountry, aborn, adied).
Book(bid, btitle, pid, bdate, bpages, bprice).
City(cid, cname, cstate, ccountry).
Publisher(pid, pname).
Author_Book(aid, bid).
Publisher_City(pid, cid).
I have been trying to delete all books published after 1985 while deleting tuples from both the author_book and book tables, using only two delete statements.
So far I have tried..
delete from book
where bdate > 1985;
giving me the syntax:
ERROR: update or delete on table "book" violates foreign key constraint
"author_book_bid_fkey" on table "author_book"
DETAIL: Key (bid)=(cltl) is still referenced from table "author_book".
and...
delete from author_book
where bid > 1985;
with another syntax:
ERROR: operator does not exist: character > integer
LINE 2: where bid > 1985;
^
HINT: No operator matches the given name and argument type(s).
You might need to add explicit type casts.
I know this is easier than I think, but just cant grasp what is going wrong. Look forward to hearing your input. This still isn't working can someone help please!!
author_bookand there is still a row in that table referencing the book you are trying to delete. You need to first delete the rows fromauthor_bookor declare the foreign key ason delete cascade