A SQL database, also known as a relational database, is a system that stores and organizes data into highly structured tables of rows and columns. These databases offer Structured Query Language (SQL) to read and write the data, and are categorized as relational database management systems (RDBMS).
SQL statements are used to create and update the structure of tables, read and write data, manage user permissions, and perform administrative tasks. For example, a CREATE statement is used to create a table, an INSERT statement adds a new row to a table, and a SELECT statement performs a database query. Statements that make structural or administrative changes are usually reserved for software developers and administrators, while read and write operations are performed by end-user applications.
A relational database maintains the ability to link information across multiple tables. This format makes it easy to quickly gain insights about the relationships between various columns or data points in these tables. A relational database can create indexes for particular columns for faster lookups.
For example, a healthcare facility might maintain a table containing rows of patient information, where each row is one patient and the columns contain data points, such as the patient’s name, insurance information, and contact details. There may be a second table that stores visit information. A relational database uses a unique ID for each row to maintain the linked patient information across the two tables. This way, you can quickly look up the visits of each patient.
Sign up for a free trial for any of Google Cloud’s SQL databases, which include AlloyDB, Cloud SQL, and Spanner.
SQL (Structured Query Language) is a programming language used to store, retrieve, and manage data in a relational database. SQL statements are English-like, making the language accessible to software developers, data analysts, and other practitioners.
Enterprises choose SQL databases for being:
There are numerous SQL database engines (products) used to build software applications. Some of the most popular include PostgreSQL, MySQL, SQL Server, and Oracle. Some database engines are open source while others are commercial offerings.
PostgreSQL is an open-source, object-relational database (ORDBMS) designed for enterprise-level performance and is valued for its reliability and robust features. Its long history of development and its use of SQL makes it one of the most popular open source databases worldwide.
Its default procedural language is an extension of pgSQL (PL/pgSQL), with procedural language extensions of Tcl, Perl, and Python included in the standard distribution (written as PL/Tcl, PL/Perl, and PL/Python). Many more languages are supported through extensions, including Java, Ruby, C, C++, Delphi, and JavaScript.
For a more in-depth comparison, visit our PostgreSQL versus SQL guide.
MySQL is a popular open source relational database created in 1995 and currently sponsored by Oracle. It supports SQL queries and can be administered either through a graphical user interface (GUI) or a command line.
MySQL can be deployed manually on a physical machine or through a cloud service provider. Enterprises are increasingly choosing fully managed services to reduce the maintenance burden of their databases.
SQL Server is a Microsoft-owned database that runs SQL queries. Dive into the differences between PostgreSQL and SQL Server.
There are many non-relational database engines in common use, many of which use a non-tabular format to store data. Some of them support SQL-like queries, which has given rise to the term “NoSQL”—”Not only SQL.”
Why do organizations use non-relational NoSQL databases for some applications but stick with relational SQL databases for others? Picking the right database often comes down to your use case. Here’s when to use SQL versus NoSQL.
SQL databases excel in managing structured, relational data, and complex queries. SQL databases are ACID compliant, making them suitable for transactional information where the data is highly structured. For example, sales orders are a good fit for a SQL database, because all orders contain the same columns and integrity is critical.
In contrast, NoSQL databases use a non-tabular format to store data. The data may be in the form of documents, key-value pairs, graphs, and any other format that doesn’t fit well into the relational model. For example, a website is a good fit for a document database, since different pages may have different structures.
Examples of SQL use cases include:
Unlike SQL databases, NoSQL databases don’t need to manage complex data relationships and extensive indexing, so they’re usually highly scalable and deliver consistent performance. NoSQL databases are typically implemented with scale-out architectures where the database can automatically add nodes whenever additional capacity is needed.
These properties of NoSQL databases make them ideal for applications that require large scale and frequent data changes. Since the database doesn’t have complex data relationships to maintain, adding nodes has little to no impact on query performance.
Common NoSQL uses include:
Read more about NoSQL databases.
Start building on Google Cloud with $300 in free credits and 20+ always free products.