SQL is a powerful programming language with an important role in today's world. It allows us to communicate with relational databases and gather information. You'll find SQL in use wherever there is data. That includes governments, public organizations, and businesses of all sizes and in all industries, from shipping to shoe sales.
You might have heard that data is now the world's most valuable commodity, meaning it's worth more than even fossil fuels such as oil. So how do we harness the power of this commodity and use it to gain insights and make savvy decisions?
That's where a language like SQL comes in. Here, we take a close look at SQL including what it is, what it does, who uses it, and this domain-specific language's history.
What is SQL?
SQL stands for Structured Query Language, and as its name suggests, you can use this programming language to ask questions (queries) of databases. You'll hear SQL pronounced as “sequel” or said as an acronym “ess-que-el.”
This programming language is primarily used to communicate with relational databases. With SQL's help, we can access, retrieve, sort, and update information. It's used with well-known relational database management systems (RDBMS) including:
Microsoft SQL Server
SQL was standardized by the American National Standards Institute (ANSI) in 1986. It also gained an International Standard designation from the International Organization for Standardization (ISO) and has been adopted as a standard by numerous governments and organizational bodies worldwide.
SQL and relational databases
Databases store information in a digital format that ensures data is easy to access. Relational databases are table-based and allow us to manage and examine the relationships between data types.
We can do this in one database's tables or we can examine the relationship between data in multiple relational databases.
One of the primary benefits of the relational model is that we can join tables and understand the relationship between data types.
Let's say that you own an e-commerce shoe store. If you want to know the relationship between your customers' location and sales volume, you can use SQL to query the customer table and generate a report.
Or let's say you own a physical shoe store and you want to know which of your team members sells the most shoes. You can also find this information using SQL, provided your database has the right parameters.
You can think of a relational database somewhat like a simple table with columns and rows that you might create in Word or Excel. But relational databases contain several tables and unlike the tables you can create in Excel, a large relational database can contain millions of fields.
Depending on one's business or data requirements, the data points within the database will vary. Shoe sellers might want customer locations or information on employee sales while another business or organization might want other data points.
SQL can be used to create new databases and modify the schema (structure) of existing databases according to need.
Why is SQL so popular?
SQL remains popular nearly 50 years after its inception because it simply works. Relational databases were invented to fill a need, and SQL was invented to communicate with these databases, meaning it quickly became the de facto language.
In many ways, SQL is synonymous with relational databases, one reason why RDBMS are often called SQL databases (and other non-relational databases are called NoSQLs).
There would be little point in trying to reinvent the wheel, right? It's rather the same with relational databases and SQL—neither are going anywhere because they work perfectly!
And these two tools working in tandem ensure that a great many of our technologies continue to work reliably, from back-end systems that keep businesses running smoothly through to structured internet architecture and much more.
Its ubiquity is not the only reason SQL is popular, though. SQL is also powerful and allows developers and analysts to query large amounts of data in complex ways, and solve tricky analytical questions.
The 2021 Stack Overflow Developer Survey showed that SQL is the third most common programming language, used by 50.73% of the professional developers surveyed.
Of course, there are always new developments and technologies are changing quickly, but SQL has yet to be knocked off its favored perch.
NoSQL versus SQL
NoSQL databases provide other ways to store and manage data without the use of related tables. They started to become popular in the late 2000s as they offered a way to accommodate data without the structural effort that goes into SQL databases. NoSQLs can be easier for developers to create, may offer faster query speeds, and allow for a flexible approach.
In many ways, NoSQL turns its head on the traditional database goals of atomicity, consistency, isolation, and durability (ACID) and suggests a more open approach to data storage.
SQL databases, on the other hand, are used for relational data, which requires a highly structured approach from the outset. They offer flexible query use, a lower data-storage footprint, consistent data integrity (a matter of key importance in several industries such as finance), and more safeguards than NoSQL.
SQL databases are far more common than NoSQL databases, but each has its own place, benefits, and drawbacks.
When was SQL created?
SQL's history is closely linked to the inception of relational databases. This history stretches back to the late 1960s when an IBM mathematician and researcher named Edgar Frank Codd formulated the relational database model.
A major breakthrough at the time, the model linked pieces of information (keys) with various types of data. For instance, a person's name could be linked to their shoe size or their phone number.
In 1970, Codd published his seminal paper, A Relational Model of Data for Large Shared Data Banks, which later provided other researchers with the basis for the SQL language.
Prior to Codd's work, retrieving information from a database was an arduous task that required sophisticated knowledge of computers. Codd's idea removed the need for specialist knowledge and made it far easier for anyone to access information.
Despite the model being revolutionary, there were criticisms. As Jim Gray, the author of Database Systems notes: “people thought that the model was too simplistic and that it could never give good performance.”
With its clever use of elegant mathematics, Codd's model proved its detractors wrong many times over.
Who invented SQL?
IBM researchers Donald D. Chamberlin and Raymond F. Boyce invented SQL after learning about Codd's work on the relational model.
“Ray Boyce and I wanted to design a query language that had the expressive power of Ted Codd's relational languages but was easier to understand by users who were not experts in set theory or formal logic.” - Donald Chamberlin
Chamberlin notes that their first attempt at a relational database language was called Square. Based on the notion of mapping, Square used a subscript notation that presented difficulties. So in 1973, when the pair moved to IBM's San Jose Research Laboratory, they began work on a sequel language, which they aptly called Sequel.
Later, Sequel became the SQL we all know today.
After testing SQL and relational database systems, IBM began developing products that used the new technologies. System/38, a mid-range computer that featured an innovative database system, was released in 1978. Since then, IBM and other vendors such as Oracle have continued to release products featuring SQL.
How SQL has evolved over the years
One of the interesting things about SQL is that its fundamental basics remain the same, even close to 50 years since its inception. Commands such as SELECT, UPDATE, INSERT, DELETE, and so on are largely unchanged.
That doesn't mean there haven't been changes, though. New features that make using the basic commands easier have emerged, making SQL even more powerful and user-friendly. In addition, as new RBDMSs have emerged—both proprietary (belonging to a company like Microsoft) and open-source (free for anyone to use)—different dialects of SQL have appeared.
SQL dialects and syntax differences
All SQL languages have the same basic structure as standard SQL. And for the most part, the key commands are the same or very similar. However, there are a few differences in the syntax across dialects.
You can think of it somewhat like a natural language such as English. We have dialects such as American, British, and Australian, and we have standard English.
SQL has standard SQL and then dialects including PostgreSQL, MySQL, SQLite, and SQL Server. Each of these dialects is compatible with the corresponding RDBMS.
A great place to start learning SQL is with PostgreSQL. This dialect is closer to standard SQL syntax than others, so it's easy to then adapt your knowledge to other dialects and database systems.
Some Code Examples
This example shows querying on a patient database. To see the contents of a table:
SELECT * FROM patients;
The output shows the first 5 rows:
If you want to find the first and last names of all the male patients:
SELECT first_name,last_name, gender FROM patients WHERE gender = ‘M’;
The output will be as follows:
The rise of data science
One of the key roles of data science is to find and predict trends, as such, it has become a staple in the modern, data-driven world. In 2012, Harvard Business Review called data science ‘the sexiest job of the 21st century.' Fast forward to 2021 and Forbes reported that the data science field would grow by around 28% by 2026.
As the field of data science has become more prominent, so too have the programming languages data scientists use most often, this includes SQL.
Data and SQL go hand in hand. Anyone who wants to access, examine, manipulate, or otherwise gain insights from structured data (data that's stored in relational databases) needs to know SQL.
Data is now the world's most valuable commodity, and data science increases the value of data. As a result, SQL, which was always popular, has become even more important in recent years.
What is NewSQL?
NewSQL systems are the new kid on the block and are sometimes referred to as distributed relational database systems or more often, distributed SQL.
First appearing in the early 2010s, NewSQL systems aim to bridge the gap between traditional RDBMSs and NoSQL systems. They do this by offering the speed and scalability of NoSQLs combined with the relational model, transaction support, and ACID guarantees that RDBMSs offer.
Early vendors of NewSQL systems such as Xeround and GenieDB didn't really make much of an impression in the database market, perhaps because it was (and still is) heavily dominated by companies such as Oracle, Amazon Web Services, and Microsoft.
Cloud-based database services that embrace the NewSQL model include AWS Amazon Aurora and Google Cloud Spanner.
Who uses SQL?
Plenty of people use SQL on a regular basis, from those who work with data as a career to people who just want a better way to manage a small database or gain insights. After all, why turn to Excel when SQL and SQL databases offer a far more elegant way to examine data?
Businesses of all shapes and sizes use SQL, too. Companies that rely on SQL to manage their databases include Microsoft, Dell, and Google. It's not just tech companies either, any business that makes use of relational databases uses SQL, think big names like Nike and Spotify alongside smaller retail businesses and many others besides.
Anyone who needs to create, modify, or communicate with relational databases needs SQL. Because of the technology's prominence and importance, RDBMSs and SQL are found in all industries and fields.
Careers with SQL
Because of its data sorting and analysis powers, SQL is a must-have skill for many professionals, including (but not limited to):
Server management specialists
Business intelligence specialists
Having even a working knowledge of basic SQL is helpful in myriad other industries and professions, too. Given the importance of data today, it's no surprise that an increasing number of employers are looking for candidates with database skills listed on their CVs.
Sometimes these employers come from unexpected industries, for example, journalism. When journalists were faced with the Panama Papers, a huge mass of complex files and documents to unpack and analyze, they turned to database systems for help.
Likewise, marketers, advertisers, and digital marketing specialists often use relational databases to make sense of information such as bounce rates, scroll depth, and click-throughs. For these careers, which in many ways represent the future of marketing, knowing how to use SQL is particularly helpful.
Upskilling with SQL
No matter the business or industry you work in, there's a very good chance that SQL skills will put you ahead. Upskilling and learning SQL is a great way to advance your current career and add another skill to your technical toolkit.
Even learning basic SQL to query databases and find information can make you a more valuable employee, or help you land a new job if you're looking.
Examples of it being used. Code examples etc
SQL basics and advanced SQL
As with any skill, there's a big difference between what SQL beginners and experienced and knowledgeable SQL experts can do with this domain-specific language.
For instance, let's say you've signed up for DataCamp's Introduction to SQL course. You'll learn the fundamentals of SQL syntax and the basics of querying and aggregating information in relational databases—enough to begin working with databases immediately.
On the other side of the relational database equation, you have SQL experts (some of whom are DataCamp instructors) who have spent years working with the language.
With advanced SQL skills, people can quickly and accurately manipulate data, create databases, and perform complex queries without having to check if their code is correct. Along with doing stuff like creating entity relationship diagrams (ERDs), optimizing query indexes, and performing hierarchical queries.
SQL is a skill for life, though. Once you've mastered the basics it's easy to upskill and keep adding further SQL knowledge and learning how to do more advanced or complex things. Even if you're comfortable working with SQL, DataCamp can take you further with intermediate and advanced SQL courses.
Summing up SQL
As you can see, SQL is an important programming language. Without it, we wouldn't be able to communicate with relational databases, and we wouldn't be able to gather the kind of insights that give businesses and organizations a competitive edge.
SQL is a handy tool for anyone to have in their arsenal, and it's an absolute must-have for people who work with data, including data analysts and scientists, marketers, financial professionals, and more.
If you're ready to start learning SQL, check out DataCamp's comprehensive range of individual courses and career tracks.
Is SQL a programming language?
In the strictest definition of the term, yes SQL is a programming language. But it's not a general-purpose programming language like Python or Java. You can't build an app with SQL. Instead, SQL has a specific job to do: communicate with and manipulate data in relational databases.
Because it has a specific application, SQL is a domain-specific programming language. This language offers a flexible and powerful way to get information from data, making it an ideal language for data science and related fields.
Is learning SQL easy?
Yes, SQL is one of the easiest computer languages to learn. Its syntax is English-based and simple, meaning many people can master this language within weeks, even if they have no prior experience with programming languages.
Introduction to SQL, a free course from DataCamp, is a great way to begin learning SQL online and at your own pace.
Can I teach myself SQL?
Yes, but teaching yourself SQL will probably take a whole lot longer than if you followed a structured course from a recognized training agency such as DataCamp.
SQL is one of the easiest programming languages to learn, but that doesn't mean it's simple. There's still a lot of complexity to its use and application. The best way to get your head around SQL is through dedicated training.
What is SQL in simple terms?
SQL is a computer language that was invented so people could communicate with relational databases. Relational databases offer a way for people to examine the relationships between different types of data, for example, a person's height and weight or sales volume and location.
To gather this kind of information from databases and generate reports, we can use SQL.
Is SQL really better than Excel?
Yes, SQL is a much better way to view, manage, and examine data than Excel. Unlike the latter, an SQL database can contain millions of fields, and there is a lot more you can do with the data using SQL queries than you can do with Excel formulas.
Spreadsheets are helpful and are routinely used in many industries, but they do not offer the same analytical functionality as an SQL database system, nor the same level of data integrity.
Why is SQL still so popular today?
Because SQL is everywhere. This programming language is synonymous with relational databases, a technology that offers one of the very best ways to view, manage, and manipulate data.
Wherever you find data, there's a good chance it's stored in a relational database, and we need SQL to communicate with these databases. This level of ubiquity means SQL is likely to remain popular for many years to come.
Is it worth learning SQL in 2022?
If you want to pursue a career in data science or a related field, learning SQL is one of the best things you can do. SQL databases, or relational databases, are the most common way for businesses and organizations to store their data.
To communicate with relational databases and unlock the power of the data they contain, you will need SQL skills. Even if you don't want to work with data full-time, knowing your way around a few SQL queries is helpful. SQL is commonly listed in job postings as a required skill.
Which is easier to learn, SQL or Python?
SQL. Because SQL is designed for a specific application only (to communicate with relational databases), its grammar and syntax are simpler than general-purpose programming languages such as Python.
That's not to say that learning Python is hard. In fact, it's among the easier programming languages to learn. DataCamp offers introductory courses in both SQL and Python. Try both and see which path you'd like to take.
Should I learn MySQL or SQL?
Start by learning standard SQL or PostgreSQL, which is the closest SQL dialect to standard.
To work with any relational database management system (aka RDBMS) you will need to know standard SQL, then as you change systems, from PostgreSQL to MySQL for example, you'll need to learn the minor differences between the syntax for each system.
How much do SQL developers make on average?
Developers who work with SQL make an average of $88,125 per year, according to research from Indeed. These developers work with SQL databases and create applications that interface with these databases.
Other jobs that involve SQL as a primary skill include database administrator, data analyst, and data scientist. DataCamp has a range of SQL-based courses and career tracks that can get you started on the right foot in your new profession.