Beginning XML Databases (Wrox Beginning Guides)

This is where I go off at what might appear to be a tangent, describing the object model for data. From what youve read so far, it might be apparent that the object data model has something to do with XML documents. However, without even a brief explanation of the object data model it is unlikely that XML documents can ever truly be understood as being object structured and perhaps never properly understood at all. The last thing you want is to create XML documents containing only single-layer hierarchies, as shown in the previous section. Why? Because a single-layer flat structure does not take advantage of the true power of XML hierarchies, where structure is included within the data itself. In other words, some data that is normally data in a relational data model is likely to become metadata in an object model.

The object model is somewhat different from the relational model. The relational model tends to simplify structures (some may say complicate them) by application of normalization. Normalization helps to remove duplication from data by dividing data into related sets. The object data model, much like object methodologies for application programming languages, tends to simplify by reducing information to the smallest possible parts . Each part can operate independently of every other part in the database. Relationships still exist in the object data model but they are different. The relational model makes a very distinct separation between metadata (tables) and data (values in fields in tables). The object model also links information together, but in addition it can apply structure to the values of data, as well as the metadata.

The structures, connections, and specific terms used for the object data model are as follows :

Creating an Object Model from a Relational Model

Unlike a relational model, an object model supports relationships between objects through the structure of objects and the classes defining those objects. Classes are defined as containing collections of pointers to other classes, as being inherited from other classes above in a hierarchy, or as being abstractions of other classes below in a hierarchy ( inheritees ).

The relational model forces dependencies to exist between the different tables; otherwise data in different tables might be meaningless. The object model allows each structure to be autonomous of all other structures (self-contained). There is much less inter-object dependency in the object model than for the relational model. This is because, as already stated, the object model includes relationships within the structure of the model itself.

The diagram shown in Figure 8-2 is an ERD showing an enhanced version of the demographics database, relational data model used in this book (see Appendix B). The only change in Figure 8-2, in addition to what appears in Figure B-1 in Appendix B, is that an ECONOMY table is added. The ECONOMY table can contain values such as 1 st World, 2 nd World, and 3 rd World. This implies that each country is classifiable into one of these three economic categories.

Figure 8-2: Enhancing the relational model shown in Figure B-1

Figure 8-3 shows an object data model for the relational model shown in Figure 8-2. The Occupation class in Figure 8-3 is ignored in this case because the diagram is getting a little too cluttered.

Figure 8-3: Converting the enhanced relational model of Figure 8-2 to an object model

Figures 8-2 and 8-3 enhance the relational and object data models, making it clearer how relational types and relational many-to-many relationships are managed by the object data model.

Data models shown in Figures 8-2 and 8-3 are not implemented in this book. These data models are included here merely to demonstrate the way that the object model can handle relational database issues.

You should be able to see some obvious differences between the two diagrams in Figures 8-2 and 8-3. This is because there are two ways in which the object model can help to reduce the complexity of the relational model. The object model does not need types or many-to-many relationships:

The following can be concluded from the example conversion shown between Figures 8-2 and 8-3, in which a relational data model is converted to an object data model:

Another form of a data model mixes both relational and object modeling methodologies. The result is the object-relational data model, which is irrelevant to this book and XML.

Категории