Home > Articles > Programming > Java

  • Print
  • + Share This
This chapter is from the book

8.4 Mapping to Tables

Mapping to tables is one of the most common patterns. Even in our purchase order application, the content of an <items>element is a repetition of the same element type, item, so this part can be naturally represented as a table (see Figure 8.4). From an application programming point of view, a table is a data structure that is suitable for operations such as searching, sorting, and totaling specific columns. In addition, table-represented data can be easily exported into and imported from applications such as databases and spreadsheets.

Figure 8.4Figure 8.4 Table data

In Chapter 11, we discuss how to store XML documents into a relational database and how to retrieve relational database contents as XML documents. In Section 11.5, refer to Listing 11.6, which decomposes XML documents and stores them into relational tables, and Listing 11.8, which generates XML documents from these tables. These programs correspond to unmarshaling and marshaling of table data. In both cases, we define mapping based on the database schema and the schema of XML documents. Some commercial database management systems have tools to generate such mappings automatically.

Mapping to tables is most suitable when your data consists of a set of records that all have a common structure. If your data is semistructured—that is, it is essentially tree-structured—mapping to hash tables (described next) is another candidate to consider.

  • + Share This
  • 🔖 Save To Your Account