4.2 The archive persistence
Relational databases are not flexible enough to store a huge variety of structured data, since they work with a ridgid schema. Document databases are a better choice. They can hold data in JSON or XML format. JSON is great for data, XML is better for structured text content.
XML does not have great benefits over JSON concerning data; it's just more mature regarding
- query language
- schema for validation
JSON is improving in the meantime, time will tell, the situation might turn some day.
As we saw earlier, XML can hold hierarchical data, but it can also mimic relation data. Let's use the same travel report example:
This "database-XML" describes three tables. They have rows, and each row has values of the corresponding columns. Quite easy, still the hierarchical XML we've shown earlier was closer to the human logic.
Anyway, we can say, an XML database can be a good choice for an archive.
What about the unstructured data? XML can store any text or binary data embedded into XML documents (as base64 encoded), but it's not necessarily efficient to do so.
Archive systems usually use the file system to store unstructured (content) files.
Please note that these XML instances do not contain any information about the data type of the fields. Obviously, travel date must be date type; cost is decimal, names are string types.
Type information is either given separately as an XML schema or a metadata file.