Skip to content

6. SQL and Relational DBs

Ty Shaikh edited this page Jun 26, 2018 · 7 revisions

Learn how to store and retrieve data using SQL queries and relational databases.


SQL and Databases

Before diving into how to query any database, let's define what a database is. A database is a data store designed for storing, querying, and processing data. Databases store the data we want and expose an interface for interacting with that data. Most technology companies use databases to structure the data coming into the system and later query specific subsets of the data to answer questions or update existing data. Database systems also come with database management software with administrative controls, security and access controls, and a language to interface with the database. Read more about databases here.

In this module we will be learning about SQL (Structured Query Language), which is designed to query, update and modify data stored in a database. SQL is the most common language for working with databases and is an important tool in any data professional's toolkit. While SQL is a language, it's quite different from languages like Python or R. SQL was built specifically for querying and interacting with databases and won't have much of the functionality you can expect in traditional programming languages. Since SQL is a declarative language, the user focuses on expressing what he or she wants and the computer focuses on figuring out how to perform the computation.

A database is a collection of tables, where each table is made up of rows of data and each row has values for the same set of columns across the table. A table is very similar to a DataFrame in Pandas or how a regular CSV file is structured. Both have rows of values with a consistent set of columns.

Querying

SQL is the most popular database querying language on the web. A SQL query has to adhere to a defined structure and vocabulary that we use to define what we want the database to do. The SQL language has a set of general statements that you combine with specific logic to express the intent of that query. Its easy to read syntax makes it more English-like than programming languages.

Databases

There are many different implementations of Relational Database Management Systems. We will focus on SQLite so you can get up-and-running quickly. Later on in the course we will talk about more advanced relational databases. You can read a comparison about them here.


Assignments


Further Exploration

  1. Go through the introductory to advanced SQL training modules on Mode Analytics.