Database Reference
In-Depth Information
If you organize your access to the database through functions, it is often possible
to do even large rewrites of business logic without touching the frontend application
code. Your application still does SELECT * FROM
do_this_thing_to_customers(arg1, arg2, arg3) even after you have re-
written the function five times and changed the whole table structure twice.
SOA - service-oriented architecture
Usually when you hear the acronym SOA, it comes from Enterprise Software people
selling you a complex set of SOAP services. But the essence of the SOA is organiz-
ing your software platform as a set of services that clients and other services call for
performing certain well-defined atomic tasks, such as:
• Checking a user's password and credentials
• Presenting him/her with a list of his/her favorite websites
• Selling him/her a new red dog collar with complementary membership in
the red-collared dog club
These services can be implemented as SOAP calls with corresponding WSDL defin-
itions and Java servers with servlet containers, and complex management infrastruc-
ture. They can also be a set of PostgreSQL functions, taking a set of arguments and
returning a set of values. If arguments or return values are complex, they can be
passed as XML or JSON, but often a simple set of standard PostgreSQL data types
is enough. In Chapter 9 , Scaling Your Database with PL/Proxy , we will learn how to
make such PostgreSQL-based SOA service infinitely scalable.
Type extensibility
Some of the preceding techniques are available in other databases, but Post-
greSQL's extensibility does not stop here. In PostgreSQL, you can just write User-
defined functions (UDFs) in any of the most popular scripting languages. You can
also define your own types, not just domains, which are standard types with some
extra constraints attached, but new full-fledged types too.
For example, a Dutch company MGRID has developed value with unit set of data
types, so that you can divide 10 km by 0.2 hour and get the result in 50 km/h. Of
course, you can also cast the same result to meters per second or any other unit of
speed. And yes, you can get this as a fraction of c —the speed of light.
Search WWH ::




Custom Search