i'm supposed write sql query given schema:
bookauthors
(isbn, authorname, gender, title, yearpublished, pubid, pubname, phone)fd
= { isbn -> title, pubid, yearpublished; authorname -> gender; pubid -> pubname, phone }
here's wrote:
create table authors ( authorname varchar(64) primary key, gender char(1) ); create table publishers ( pubid varchar(32) primary key, pubname varchar(64), phone numeric(10) ); go create table books ( isbn varchar(32) primary key not null, title varchar(32), pubid varchar(32) foreign key references publishers(pubid) not null, yearpublished numeric(4) );
is correct answer? i'm worried not having connections between author , book.
the problems come fact in functional dependencies missing dependence isbn authorname: because each book uniquely determines author. dependences should be:
isbn -> title, pubid, yearpublished, authorname authorname -> gender pubid -> pubname, phone
so, third normal form following:
books(isbn authorname pubid title yearpublished) , { isbn → authorname pubid title yearpublished } > authors (authorname gender) , { authorname → gender } > publishers (pubid pubname phone) , { pubid → pubname phone } >
and should set of relations defined. of course, should add right constraints, primary keys , foreign keys (and solution of irateb correct well).
i think exercise, otherwise, should add authorid original data, , modify functional dependencies.
Comments
Post a Comment