Database Basics
About 2 min read
A database is an organized collection of data stored so it can be easily searched, retrieved, and updated. SQL (Structured Query Language) is the standard language used to communicate with a relational database — the most common kind, in which data is held in tables made up of rows and columns. This lesson introduces the basic structure of a relational database so the rest of the series makes sense.
Questions you may have include:
- What is a relational database?
- What is SQL used for?
- What does a sample table look like?
Relational databases
A relational database stores information in one or more tables. Each table holds data about one kind of thing — customers, orders, products, and so on.
- A column (or field) defines one piece of information, such as a customer’s last name, and has a fixed data type (text, number, date, and so on).
- A row (or record) is a single entry — all the values for one customer.
- A primary key is a column whose value uniquely identifies each row, such as a customer ID, so no two rows can be confused.
Because each table has a clear structure, you can ask precise questions of the data and get reliable answers.
What SQL does
SQL lets you tell the database what you want without describing how to find it. Its commands fall into two broad groups: those that define the structure of tables, and those that work with the data inside them. This series focuses on the everyday data commands: retrieving rows, sorting them, filtering them, and updating them.
SQL keywords are not case sensitive, and most statements end with a semicolon. The same core commands work across popular database systems — such as MySQL, PostgreSQL, Microsoft SQL Server, Oracle, and SQLite — though each has small dialect differences.
A sample table
The lessons that follow use a simple customers table as an example:
customers ---------------------------------------------- id first_name last_name city state 1 Maria Lopez Austin TX 2 James Carter Denver CO 3 Aisha Khan Austin TX 4 Liam O'Brien Reno NV
Here id is the primary key, and each remaining column stores one kind of detail about a customer.
Summary
A relational database organizes data into tables of rows and columns, with a primary key identifying each row. SQL is the standard language for working with that data, using a small set of readable commands that behave consistently across the major database systems. The next lessons show how to retrieve, sort, filter, and update data using a sample customers table.
