5.1. PostgreSQL tutorial

发布时间 :2025-10-25 12:30:50 UTC      

Image0

PostgreSQL is a free object-relational database server (ORDBMS) distributed under a flexible BSD license.

PostgreSQL developers pronounce it as post-gress-Q-L.

PostgreSQL’s Slogan is “the most advanced open source relational database in the world”.

Reference to: PostgreSQL 10.1 manual

5.1.1. What is a database?

Database (Database) is a warehouse that organizes, stores and manages data according to the data structure.

Each database has one or more different API for creating, accessing, managing, searching, and replicating saved data.

We can also store data in a file, but it is relatively slow to read and write data in the file.

So now we use a relational database management system (RDBMS) to store and manage large amounts of data. The so-called relational database is a database based on the relational model, which deals with the data in the database with the help of mathematical concepts and methods such as set algebra.

ORDBMS (object Relational Database system) is the product of the combination of object-oriented technology and traditional relational database. Query processing is an important part of ORDBMS, and its performance will directly affect the performance of DBMS.

ORDBMS adds some new features to the original relational database.

RDBMS is a relational database management system, which establishes the relationship between entities, and finally gets the relational table.

OODBMS object-oriented database management system regards all entities as objects and encapsulates these object classes. The communication between objects is essentially a relational database through the message OODBMS object relational database.

5.1.2. ORDBMS terminology

Before we move on to the PostgreSQL database, let’s take a look at some of the terms of ORDBMS:

  • Database: a database is a collection of associated tables.

  • Data table: a table is a matrix of data. A table in a database looks like a simple spreadsheet.

  • 列: 一列(数据元素) 包含了相同的数据, 例如邮政编码的数据。

  • Row: a row (= tuple, or record) is a set of related data, such as a piece of data that a user subscribes to.

  • Redundancy: twice as much data is stored, redundancy reduces performance, but improves data security.

  • Primary key: the primary key is unique. There can be only one primary key in a data table. You can use the primary key to query data.

  • Foreign keys: foreign keys are used to associate two tables.

  • Compound key: compound key (compound key) uses multiple columns as a single index key, which is generally used for composite indexes.

  • Indexes: use indexes to quickly access specific information in database tables. An index is a structure that sorts the values of one or more columns in a database table. A catalogue similar to a book.

  • Referential integrity: referential integrity requires that references to entities that do not exist are not allowed in the relationship. And entity integrity is the integrity constraint that the relational model must meet in order to ensure the consistency of the data.

5.1.3. PostgreSQL feature

  • Function: through the function, you can execute the instruction program on the database server side.

  • Index: users can customize the index method, or use the built-in B-tree, hash table and GiST index.

  • Trigger: a trigger is an event triggered by an SQL statement query. For example, an INSERT statement may trigger a trigger that checks data integrity. Triggers are usually triggered by INSERT or UPDATE statements. Multi-version concurrency control: PostgreSQL uses a multi-version concurrency control (MVCC,Multiversion concurrency control) system for concurrency control, which provides each user with a “snapshot” of the database, and every change made by the user within the transaction is invisible to other users until the transaction is successfully committed.

  • Rules: rules (RULE) allow a query to be rewritten and are usually used to implement operations on views (VIEW), such as INSERT, UPDATE, and DELETE.

  • Data types: including text, numeric arrays of arbitrary precision, JSON data, enumerated types, XML data, etc.

  • Full-text search: through embedded Tsearch2 in Tsearch2 or OpenFTS,8.3 versions.

  • NoSQL:JSON,JSONB,XML,HStore native support to the external data wrapper of the NoSQL database.

  • Data warehouse: can smoothly migrate to GreenPlum,DeepGreen,HAWK, which belongs to the same PostgreSQL ecology, and use FDW for ETL.

5.1.4. Related resources

PostgreSQL 10.1 manual online manual: http://www.runoob.com/manual/PostgreSQL/

Offline manual-PDF version: https://pan.baidu.com/s/1h1J14i8tzJUY3p9yyeW0mA , extraction code: xs7r.

Offline manual-CHM version: https://pan.baidu.com/s/1h1J14i8tzJUY3p9yyeW0mA , extraction code: tq4z.

Check out the latest version: https://github.com/postgres-cn/pgdoc-cn/releases

Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.