Relational Databases
Relational Databases#
SQL is a language designed for a very specific purpose: to interact with relational databases.
Database: A database is a structured collection of data. There are various different ways of structuring the database, and there may or may not be information about the relationship between entities in the database.
Query: A query is a request for data from the database.
Database Management System (DBMS): A DBMS is a system of storing and managing databases, including querying the database.
Relational Database Management System (RDBMS): In an RDBMS, data records are stored in tables, each of which has a predefined set of columns, the pieces of information captured for each record in a table, and rows in the table, where each row has a place to store a value for every column in the table.
Tables, including their columns, column types and relationships with other tables, are defined in a database schema. Many times, tables will contain a primary key, one or more columns that uniquely define a row. You can think of the primary key as a kind of ID, in which each row is given a unique ID. Tables can also contain foreign keys, which are column(s) that comprise the primary key in another table and, thus, provides a way of matching between multiple tables.
Note: Normally, a database is stored seperately from the SQL that you use to query the database. However, for the purposes of this book, we have created a light-weight database and added some special tools that will allow you to run queries directly in the notebook. While the SQL commands you will use here are the same, keep in mind that interfacing with most production database systems is more complex and generally requires additional software tools or libraries.