Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Learning PostgreSQL
Learning PostgreSQL

Learning PostgreSQL: Create, develop and manage relational databases in real world applications using PostgreSQL

Arrow left icon
Profile Icon Juba Profile Icon Achim Vannahme Profile Icon Volkov
Arrow right icon
$19.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2 (5 Ratings)
Paperback Nov 2015 464 pages 1st Edition
eBook
€24.99 €36.99
Paperback
€45.99
Subscription
Free Trial
Renews at $19.99p/m
Arrow left icon
Profile Icon Juba Profile Icon Achim Vannahme Profile Icon Volkov
Arrow right icon
$19.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2 (5 Ratings)
Paperback Nov 2015 464 pages 1st Edition
eBook
€24.99 €36.99
Paperback
€45.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
€24.99 €36.99
Paperback
€45.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Learning PostgreSQL

Chapter 2. PostgreSQL in Action

PostgreSQL (pronounced Post-Gres-Q-L) or postgres is an open source object relational database management system. It emphasizes extensibility, creativity, as well as compatibility. It competes with the major relational database vendors such as Oracle, MySQL, SQL servers, and others. It is used by different sectors including government agencies and the public and private sectors. It is a cross-platform DBMS, and runs on most modern operating systems including Windows, MAC, and Linux flavors. It conforms to SQL, and is ACID compliant.

An overview of PostgreSQL

PostgreSQL (http://www.postgresql.org/) has many rich features. It provides enterprise level services including performance, unique features, and scalability. It has a very supportive community and very good documentation.

PostgreSQL history

The name PostgreSQL is derived from post-ingres database. PostgreSQL history could be summarized as follows:

  • Academia: University of California at Berkeley (UCB)
    • 1977-1985, the Ingres project: Michael Stonebraker created an RDBMS based on the formal relational model.
    • 1986-1994, postgres: Michael Stonebraker created postgres in order to support complex data types and the object relational model.
    • 1995, Postgres95: Andrew Yu and Jolly Chen changed the postgres POSTQUEL query language with an extended subset of SQL
  • Industry
    • 1996, PostgreSQL: Several developers dedicated a lot of labor and time to stabilize postgres95. The first open source version was released on January 29, 1997. With the introduction of new features, enhancements, and...

PostgreSQL capabilities

PostgreSQL provides enterprise-level services which guarantee the continuation of the business.

Replication

Replication allows data from one database server to be replicated to another server. Replication is used mainly to achieve the following:

  • High availability: A second server can take over if the primary server fails.
  • Load balancing: Several servers can serve the same requests.
  • Faster execution: A query is executed on several machines at once to gain performance.

PostgreSQL supports replication out of the box via streaming replication. Streaming replication is a master-slave replication that uses file-based log shipping. Streaming replication is a binary replication technique, because SQL statements are not analyzed. It is based on taking a snapshot of the master node, and then shipping the changes—the WAL files—from the master node to the slave node and replaying them on the slave. The master can be used for read/write operations, and the slave can be...

Installing PostgreSQL

PostgreSQL can be installed on almost all modern operating systems. It can be installed on all recent Linux distributions, Windows 2000 SP4 and later, FreeBSD, OpenBSD, Mac OS X, AIX, and Solaris. Also, PostgreSQL can work on various CPU architectures including x86, x86_64, IA64, and others. One can check if a platform (operating system and CPU architecture combination) is supported by exploring the PostgreSQL Build farm (http://buildfarm.postgresql.org/).

One can compile and install PostgreSQL from the source code or download its binary and install it.

Tip

In order to automate PostgreSQL installation and to reduce server administrative tasks, it is recommended to use PostgreSQL binaries, which come with the operating system packaging system. This approach normally has one drawback: not up-to-date binaries.

Installing PostgreSQL on Ubuntu

Ubuntu is a Debian-based widely spread Linux operating system. Ubuntu uses the Advanced Packaging Tool (APT), which handles software...

Summary

PostgreSQL is an open source, object-oriented relational database system. It supports many advanced features and complies with the ANSI-SQL:2008 standard. It has won industry recognition and user appreciation. The PostgreSQL slogan "The world's most advanced open source database" reflects the sophistication of the PostgreSQL features. It is a result of many years of research and collaboration between academia and industry. Startup companies often favor PostgreSQL due to low licensing costs. PostgreSQL can aid profitable business models. PostgreSQL is also favored by many developers because of its capabilities and advantages.

PostgreSQL can be used for OLTP and OLAP applications. It is ACID compliant; thus, it can be used out of the box for OLTP applications. For OLAP applications, PostgreSQL supports the Windows functions, FDW, and table inheritance. Also, there are many external extensions for this purpose.

Several proprietary DBMSs are based on PostgreSQL. In addition...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Learn about the PostgreSQL development life cycle including its testing and refactoring
  • Build productive database solutions and use them in Java applications
  • A comprehensive guide to learn about SQL, PostgreSQL procedural language and PL/pgSQL

Description

PostgreSQL is one of the most powerful and easy to use database management systems. It supports the most advanced features included in SQL standards. The book starts with the introduction of relational databases with PostegreSQL. It then moves on to covering data definition language (DDL) with emphasis on PostgreSQL and common DDL commands supported by ANSI SQL. You will then learn the data manipulation language (DML), and advanced topics like locking and multi version concurrency control (MVCC). This will give you a very robust background to tune and troubleshoot your application. The book then covers the implementation of data models in the database such as creating tables, setting up integrity constraints, building indexes, defining views and other schema objects. Next, it will give you an overview about the NoSQL capabilities of PostgreSQL along with Hstore, XML, Json and arrays. Finally by the end of the book, you'll learn to use the JDBC driver and manipulate data objects in the Hibernate framework.

Who is this book for?

If you are a student, database developer or an administrator, interested in developing and maintaining a PostgreSQL database, then this book is for you. No knowledge of database programming or administration is necessary.

What you will learn

  • Learn concepts of data modelling and relation algebra
  • Install and set up PostgreSQL database server and client software
  • Implement data structures in PostgreSQL
  • Manipulate data in the database using SQL
  • Implement data processing logic in the database with stored functions, triggers and views
  • Test database solutions and assess the performance
  • Integrate database with Java applications
  • Detailed knowledge of the main PostgreSQL building objects, most used extensions
  • Practice database development life cycle including analysis, modelling, (documentation), testing, bug fixes and refactoring

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Nov 30, 2015
Length: 464 pages
Edition : 1st
Language : English
ISBN-13 : 9781783989188
Category :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Nov 30, 2015
Length: 464 pages
Edition : 1st
Language : English
ISBN-13 : 9781783989188
Category :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 107.97
Troubleshooting PostgreSQL
€24.99
PostgreSQL Replication, Second Edition
€36.99
Learning PostgreSQL
€45.99
Total 107.97 Stars icon

Table of Contents

15 Chapters
1. Relational Databases Chevron down icon Chevron up icon
2. PostgreSQL in Action Chevron down icon Chevron up icon
3. PostgreSQL Basic Building Blocks Chevron down icon Chevron up icon
4. PostgreSQL Advanced Building Blocks Chevron down icon Chevron up icon
5. SQL Language Chevron down icon Chevron up icon
6. Advanced Query Writing Chevron down icon Chevron up icon
7. Server-Side Programming with PL/pgSQL Chevron down icon Chevron up icon
8. PostgreSQL Security Chevron down icon Chevron up icon
9. The PostgreSQL System Catalog and System Administration Functions Chevron down icon Chevron up icon
10. Optimizing Database Performance Chevron down icon Chevron up icon
11. Beyond Conventional Data types Chevron down icon Chevron up icon
12. Testing Chevron down icon Chevron up icon
13. PostgreSQL JDBC Chevron down icon Chevron up icon
14. PostgreSQL and Hibernate Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2
(5 Ratings)
5 star 60%
4 star 20%
3 star 0%
2 star 20%
1 star 0%
Zoltan Dec 31, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The book starts out with a nice and conveniently brief but concise summary of all the main terms and concepts of database theory, including NoSQL and (object)relational databases. One does well to read up on the former (NoSQL) concept on the web since there are more than 225 of them as of today (nosql-database.org), whereas the book will focus on the SQL concepts afterwards. I really liked the fact that the authors do not shy away from explaining even the most basic terms in significant detail; this way absolute beginners will also fully benefit from the book, whereas more experienced programmers and administrators can simply just skim through these parts for a quick refresher. As an example, the often problematic concept of "unknown" (NULL) values and their relationship with TRUE and FALSE values is very nicely handled, including the truth tables for OR, AND and NOT.The basic concepts are also put into context via a well-detailed example application of a car web-portal, including detailed flow- and relationship charts (ER diagrams), which will help even the very beginners to understand the way of thinking required in database design. All code is available from the publisher, which saves the programmer a lot of typing time and typos.The detailed description of PostgreSQL is very complete, with history, concepts and sample applications. I would add to their "Success stories" the very popular and well established image database application OMERO (http://www.openmicroscopy.org/site), which has been around for 10 years and is being used by hundreds of research labs and institutions around the world, as well as by scientific journals. I personally installed OMERO, and thus PostgreSQL, many times and always found installing PostgreSQL very straightforward. The book will also guide the readers through these steps, including server settings, adding users, administration, etc. The setting up of clients is described in great detail, rightly so since this is the key concept for main users of databases once the installation is done.The book does a great job in explaining all the details of setting up the database, editing and acquiring its data, at the same time pointing out the most typical mistakes that users and administrators will encounter. Special emphasis is given to the various data types in relation not only to fitting the task at hand, but also to maintain and adjust the database to future demands. E.g., the great flexibility of the "text" type is given properly detailed description in Chapter 3. Using the same database example of the car web-portal throughout the book helps the reader to relate all new theoretical information easily to practicality.The later chapters (from Chapter 4) deal with more advanced concepts. These are crucial for those developing more demanding database applications and thus are very useful for the more experienced developers as well. For example, VIEWS are especially nicely described, which demand-dependent web application developers will certainly appreciate. Similarly well treated are the details of the very important concept of indexing.Those who want to go even further and extend the default functionality of PostgreSQL, may do so by writing their own FUNCTIONs in various languages. This is a difficult concept even for experienced developers, but the book does a great job by presenting these via simple yet realistic examples, including concrete code snippets in C and SQL (PL/pgSQL is described in Chapter 7). For me this came very handy with the OMERO database system, where I often needed to add server functionality for various research applications.Naturally, the book also handles the more generic advanced concepts that are used to automate databases, most importantly TRIGGERs.In Chapters 5 and 6 the readers will get a nice summary of the SQL language itself, and of advanced query writing. These concepts may already be familiar to many advanced readers, who may wish to give these chapters just a quick read.In Chapter 7 the authors describe PostgreSQL's default server-side programming language, PL/pgSQL. The advantage of using PL/pgSQL instead of SQL becomes clear very quickly and then the reader is happily immersed in the details of this powerful yet simple language. This chapter is quite long, but worth the effort.No such book would be complete without discussing the subject of data security, and Chapter 8 takes care of this in great detail. Especially nowadays, when hacking is exceptionally common, every database application developer needs to be very careful about security, and this chapter covers this task very well. Those readers who are completely new to the subject may also want to read a more detailed work on general web security, or rely on the experience of professional IT personnel when setting up their servers that will be open to the Internet.When administering a database, we face a certain group of standard tasks, and the book teaches the reader this subject in a cookbook format in Chapter 9. I love this, because here one really appreciates a well described and concrete action plan, rather than lots of theory. Find the task, follow the steps in this chapter, done! For those who want to know more, "There is more..." as the extra paragraphs at the end of each recipe are called; these describe additional ways to achieve the goal, or give more details.For more demanding applications, database optimization is especially important. This may not be a developer's favorite task, but the material in Chapter 10 will help us through it. Lots of ideas about common mistakes, streamlining queries, finding bottlenecks, these are all there. I found many new ideas here, even though I've been coding for databases for many years.The chapter on unconventional data types (Chapter 11) really helps those who customize their database applications heavily. The OMERO example cited above comes to mind here, especially in relation to XML and JSON data handling.A very important but often (somewhat) overlooked part of a developer's job is testing the application. This will be greatly helped by reading Chapter 12 for PostgreSQL coders. Once again a difficult subject, but handled well and smoothly here.Accessing your PostgreSQL database from external applications will be made much easier by Chapter 13, which describes JDBC, a platform that allows communication with PostgreSQL from a Java application. The examples are well structured and cover the most common users' needs.On the related subject of Object-relational mapping, Chapter 14 gives a nice review, including an introduction to the Hibernate framework. This a very advanced subject, but great to have for those on a more advanced level, or those who are aiming for this level.Overall, a well written book with a very wide range of subjects within the realm of PostgreSQL database management and development. Easy to read, free source code for the samples (this is automatic if one buys the book from the publisher, which is what I do; otherwise easily received via e-mail per request), which saves a lot of typing, and great examples throughout.
Amazon Verified review Amazon
O. COSTA Dec 18, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
After a quick read and practicing some sample code, I can say this is a great learning guide for database programming with PostgreSQL.Some valuable information well explained as :relational database compared with others (graph, NoSQL, ...), relational algebra, installation, using client tools, objects in PostgreSQL as SQL components (tables, views, ...) and Object in PostgreSQL as an ORDBMS, DDL, DML and DCL, advanced queries, Common Table Expressions, window functions, UDF in C, encryption (one-way and two-way), unit testing, queries rewriting, optimization in many aspects, user datatypes, benchmark ... java with JDBC api (install, connect, static statement, prepared statements, cursors, calling stored functions) and finally ORM and Hibernate.Authors present an overview of PostgreSQL for developers. Each topic is clearly explained and accompanied by functional and realistic examples, some based on a case study (The car web portal database). This example follows the reader through chapters.Reading this book is pleasant. I enjoyed an easy and very smooth reading for non-English-speaking people. Examples are numerous and facilitate understanding of concepts.It would have been nice to explain inheritance not only for partitioning but also with an example of a specialized child table from a generic table ... as in OOP.Finally, a great book if you are student or professional developer who want to start learning PostgreSQL.
Amazon Verified review Amazon
Oleg Okun Jan 16, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
PostgreSQL is an open source object relational database management system and as open source it is popular in academia and industry. This book provides a solid description of PostgreSQL in one volume that covers many topics that beginners and experienced users likely face at their daily work. At the same time, authors succeeded to put a lot of material into a not too lengthy book. The book is useful for both a BI engineer whose bread-and-butter is SQL programming and a system administrator maintaining, monitoring, and tuning databases. Advanced topics such as views, functions, user-defined data types, database security, database performance optimization, and unit tests for databases are described in sufficient details.
Amazon Verified review Amazon
Andrea Dec 31, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Book purpose is clear: Create, develop, and manage relational databases in real-world applications using PostgreSQL. And the author has over 10 years of experience in industry and academia (you can notice in the first chapter, with a great overview of relational databases).For sure the book is rich of information (with 464 pages and 14 chapters) useful both for admins and developers.Admins can use the first chapters (from 2) to better understand PostgreSQL, but the installation part remain little poor, and some parts, like system related optimization (chapter 10 is dedicated to the optimization aspects, but more at developer level) or high availability deployment are totally missed. Security is covered in chapter 8, both for admins and developers point of view.For sure will be more useful for a developer, also at a beginner level on this DMBS, with lot of information on the SQL and the PL/pgSQL languages and how writing better and advanced queries.There is also a chapter dedicated on Server-Side Programming with PL/pgSQL, useful for complex applications.
Amazon Verified review Amazon
C. Barker Apr 26, 2016
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
I have no idea how this book got 5 stars. The book is a non-stop string of informational tidbits with no coherent direction. There seems to be no plan to progress the reader through learning PostgreSQL in any sort of structured way. You'd be better off downloading the PostgreSQL code and trying to understand PostgreSQL that way.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.