X hits on this document

496 views

0 shares

1 downloads

0 comments

98 / 142

XML and MySQL

<mysqldump> <database name="c <table name="it

atalog"> ems">

<field

name

<field

name

<field

name

<field

name

<field

name

<field

name

<field

name

<field

name

<field

name

<field

name

<field

name

<row>

</row>

="id">1</field> ="creator">Abraham, Gerald</field> ="title">The concise Oxford history of mus ="sort_title">concise Oxford history of mu ="subjects">Music; History and criticism;< ="publisher">Oxford University Press</fiel ="date">1979</field> ="call_number">ML160 .A27</field> ="extent">968 p. : ill., music ; 26 cm.</f ="notes">Includes index. Bibliography: p. ="responsibility">Gerald Abraham.</field>

ic</field> sic</field> /field> d>

ield> 864-912.</field>

<!-- many, ma <row>

ny rows deleted here. -->

<field

name

<field

name

<field

name

<field

name

<field

name

<field

name

<field

name

<field

name

<field

name

<field

name

<field

name

</row>

</table> </database> </mysqldump>

="id">567</field> ="creator">Zicree, Marc Scott.</field> ="title">The twilight zone companion</fiel ="sort_title">twilight zone companion</fie ="subjects"></field> ="publisher">Silman-James Press</field> ="date">1992</field> ="call_number">PN1992.77.T87 Z52 1992</fie ="extent">p. cm.</field> ="notes">by Marc Scott Zicree. Includes in ="responsibility">by Marc Scott Zicree.</f

d> ld>

ld>

dex.</field> ield>

While pretty vanilla, the output is a perfect representation of the database's content. Using XSLT it would be possible to reformat all or parts of this output into other textual representations.

The catalog database is a flat file. It contains only a single set of rows and columns. As such it does not provide the means to save redundant data very well. For example, each item in the catalog may have multiple authors as well as multiple subjects. These individual authors and subjects may appear in mul- tiple items. In relational database parlance, this is called a many-to-many relationship. In order to more efficiently represent this condition relational database applications support the creation of multiple tables within a single database. In this case, one table could contain information about items. Another could contain authors. A third could contain subjects. Finally, there could be "join" tables containing unique identifiers from the other tables facilitating relationships between them. The process of defining these relationships is called "normalization".

A true relational database is included in this workshop's distribution. The database is a small part of the author's water collection. ("Yes, I collect water.") Each water in the collection was collected by one or more persons, and each person may have collected many waters. Thus, the water collection includes at least one many-to-many relationship. Each water is uniquely identified with an ID, title, date, a short blurb, and a JPEG image. Each item is then "joined" to one or more collectors through a related table. Finally, the entire collection is described with a single metadata record. The database's entity relation- ship diagram looks like this:

90

Document info
Document views496
Page views502
Page last viewedTue Jan 17 02:26:14 UTC 2017
Pages142
Paragraphs3126
Words34660

Comments