Marcus is a RHEL Sysadmin at Red Hat who wants to master PostgreSQL. Please generate an essay about PostgreSQL that answers the following questions. Please note that Marcus prefers the term "Free Software" to "open source".

  1. What is PostgreSQL, and what problem does it solve?
  2. What is the history of PostgreSQL?
  3. Is PostgreSQL Free Software?
  4. What are the advantages and disadvantages of PostgreSQL when compared to other popular databases?
  5. How would Marcus install PostgreSQL on a modern RHEL server?
  6. How would Marcus created a database called rhel_admins, and add 2 columns: name and senority? Then, he should add Kesha, John, and Kwame to the database. Kesha has 7.4 years of seniority, John has 8.2 years of seniority, and Kwame has 8.8 years of seniority.

Understanding PostgreSQL

What is PostgreSQL, and What Problem Does It Solve?

PostgreSQL is a powerful, Free Software/open-source object-relational database system that uses and extends the SQL language combined with many features that safely store and scale the most complicated data workloads. The origins of PostgreSQL date back to 1986 as part of the POSTGRES project at the University of California at Berkeley and has more than 30 years of active development on the core platform.

It's designed to handle a range of workloads, from single machines to data warehouses or Web services with many concurrent users. PostgreSQL is known for its high levels of resilience, integrity, and correctness. It ensures data integrity and supports complex queries, which can be particularly useful for dealing with large and diverse datasets.

What is the History of PostgreSQL?

PostgreSQL's history begins with the POSTGRES project led by Professor Michael Stonebraker at UC Berkeley, which was itself an evolution of the Ingres database. The aim was to break new ground in database concepts and make improvements over Ingres. POSTGRES introduced many concepts that only became available in commercial products much later.

The POSTGRES project evolved into PostgreSQL to emphasize the system's capabilities as an SQL-compliant database. In 1996, the project was renamed to PostgreSQL to reflect its support for SQL. Since then, a vibrant and active community has continually developed and improved the system, with contributors from around the world.

Is PostgreSQL Free Software?

Yes, PostgreSQL is Free Software. It is released under the PostgreSQL License, which is similar to the MIT License and is considered free by the Free Software Foundation. This license gives you the freedom to use, modify, and distribute PostgreSQL in any form you like, be it open-source or proprietary.

Advantages and Disadvantages of PostgreSQL Compared to Other Databases


  • Data Integrity: PostgreSQL is known for its strong emphasis on correctness and data integrity.
  • Extensibility: It is highly extensible. Users can define their own data types, build out custom functions, even write code from different programming languages without recompiling the database.
  • Rich Features: It includes features such as complex queries, foreign keys, triggers, views, transactional integrity, and multiversion concurrency control.
  • Support for JSON: PostgreSQL supports JSON and other NoSQL features like native XML support and key-value pairs with HSTORE. It also supports indexing JSON data for faster access.
  • Community Support: It has a large and active community, which means a wealth of free resources, from extensive documentation to active online forums.


  • Performance: For certain types of workloads, particularly those that require heavy writes and reads to large BLOBs, PostgreSQL might not perform as well as some other systems like MongoDB.
  • Complexity: It can be complex to understand and manage. The learning curve might be steep for those not familiar with databases.
  • Replication: While it has improved over time, replication was historically more complex and less performant than in some other databases, although this has largely been addressed in recent versions.

Installing PostgreSQL on a Modern RHEL Server

Marcus, as a RHEL sysadmin, can install PostgreSQL on a RHEL server by following these steps:

  1. Add the PostgreSQL repository to RHEL:

    sudo dnf -y install$(rpm -E %{rhel})-x86_64/pgdg-redhat-repo-latest.noarch.rpm
  2. Install PostgreSQL:

    sudo dnf -y install postgresqlXX-server

    (Replace "XX" with the desired version of PostgreSQL.)

  3. Initialize the database cluster:

    sudo /usr/pgsql-XX/bin/postgresql-XX-setup initdb

    (Again, replace "XX" with the version number.)

  4. Enable and start the PostgreSQL service:

    sudo systemctl enable --now postgresql-XX
    sudo systemctl start postgresql-XX
  5. Secure PostgreSQL by setting a password for the "postgres" user:

    sudo passwd postgres
  6. Switch to the postgres user and access the PostgreSQL prompt:

    sudo -i -u postgres psql

Creating a Database and Adding Records

To create a rhel_admins database and add the necessary columns and data, Marcus would execute the following SQL commands within the PostgreSQL environment:

  1. Create the rhel_admins database:

    CREATE DATABASE rhel_admins;
  2. Connect to the rhel_admins database:

    \c rhel_admins
  3. Create a table with the required columns:

    CREATE TABLE admin_info ( name VARCHAR(50), seniority NUMERIC(3,1) );
  4. Insert the data for Kesha, John, and Kwame into the table:

    INSERT INTO admin_info (name, seniority) VALUES ('Kesha', 7.4);
    INSERT INTO admin_info (name, seniority) VALUES ('John', 8.2);
    INSERT INTO admin_info (name, seniority) VALUES ('Kwame', 8.8);

After executing these commands, Marcus would have successfully set up the rhel_admins database with the admin_info table containing the specified records. He can verify the data with a SELECT query:

SELECT * FROM admin_info;

This SQL statement will display all the records in the admin_info table, allowing Marcus to confirm that the data has been entered correctly. Marcus, with his sysadmin expertise, can easily adapt this straightforward guide to align with specific requirements or integrate into larger database schemas as necessary.