Database Reference
In-Depth Information
Other
ways
to
work
with
structured
data
We now have covered the traditional ways of returning sets of structured data from
functions. We will now start with the more interesting part. Other methods of passing
around complex data structures have evolved in the world today.
Complex data types for modern world - XML and
JSON
In the real world, most of the data is not in a single table and the database is not the
main thing that most programmers focus on. Often, they don't even think of it at all, or
at least would rather not think about it.
If you are a database developer working on the database side of things, it is often
desirable to talk to the clients (be it web or application developers as your client, or
programs as database clients) in the language they speak. Currently, the two most
widely spoken data languages by the web applications and their developers are XML
and JSON.
Both XML and JSON are text-based data formats, and as such, they can be easily
saved into fields of type text. PostgreSQL, being a DBMS built for being user-extend-
able, also has extensive support for both of these formats.
XML data type and returning data as XML from
functions
One of the extensions added to PostgreSQL to support XML data is a native XML
data type. While the XML data type is largely just a text field, it does differ from text in
the following ways:
• The XML stored in an XML field is checked to be well formed
• There are support functions for producing and working with known well-
formed XML
Search WWH ::




Custom Search