Tuesday, November 15, 2011

On the question of whether relational schemas can capture books with multiple authors

In the class, I said that XMLschema allows us to easily capture books with multiple authors in contrast to RDBMS. 

Two of you pointed out that RDBMS can handle multiple authors by storing authors in a table along  with book IDs (say isbn numbers)

<isbn1, author11>
<isbn1, author12>
<isbn2,author21> 

etc, with the isbn number working as a foreign key into table.

While this way of doing it allows books with arbitrary number of authors,  it does not allow us to constrain the number of authors (say to be always
between 1 and 3). 

To do that, you will have to either use extra-RBDMS ideas such as triggers, or put upto three columns in the book table, resigned to the fact that the when there are
no second or third authors there will be null values in the column.  This is the price we pay for writing a single table for data that essentially is a union of three schemas--books with 
one author, books with two authors and books with three authors. It is here that XMLSchema differs by allowing specification of disjunctive schemas.

Rao




No comments:

Post a Comment