2 minutes to quickly understand what SQL is

Structured Query Language, or SQL for short, is the gold standard language for communicating with relational database management systems. Today, let’s quickly understand what SQL is. You can learn from the following text content, or you can learn from the video at the end of the article. I hope this article will be helpful to you.

You may have heard of databases such as MySQL, Postgres, Microsoft SQL Server, and Oracle, all of which are based on SQL but have their own slight variations. It was originally developed in the early 1970s to modify and retrieve data from IBM System R databases. By 1986, it was standardized as a syntax and is still very popular in technical applications today.

Relational databases organize data into tables, somewhat like an Excel spreadsheet, where columns contain attributes or types of data.

Each row represents an individual record or data point, with its own unique ID (called a primary key).

We can establish relationships between data points by taking the unique ID from one row and storing it in a special column called a foreign key in a different row of a different table.

In the team table, the team ID is the primary key, but in the players table, it is the foreign key.

What this data structure tells us is that a player belongs to a team, and a team can have multiple players.

What we are doing here is structuring the data in a minimal normal form to eliminate duplication and redundancy. Now, the role of SQL is not only to read, create, update, and delete data, but also to join data together based on the relationships embedded in the data.

SQL syntax consists of several key parts. If we zoom all the way down, we have a statement or a piece of code that does something, for example: read or write to the database.

In the statement, we have various keywords that can operate the database.

SELECTCan be used to query the required columns in the table. Column and table names are called identifiers

But we may not need every row in the table, so we use the WHERE keyword to filter the results to only include records that meet certain criteria.

This is like looping through each row in the table and returning only the rows for which the predicate in the query evaluates to true.

We can then use the JOIN keyword to join data from completely different tables by matching the primary key on that table with a foreign key on another table.

What we create is a collection of clauses that make up a complete SQL statement. We can now execute this code on hundreds of different databases that support SQL.

If you want to broaden your horizons and understand and discover more concepts and knowledge in the computer field, welcome to follow my continuously updated developer science column to help you explore more popular knowledge in the computer field!

Welcome to follow my public account: Programmer DD. If we had known about cutting-edge technology, there would be hope for overtaking on curves! To accumulate overtaking capital, start by paying attention to DD!

Guess you like

Origin blog.csdn.net/dyc87112/article/details/134797435