Day 2 of the Mini Data Science Bootcamp introduces SQL and relational databases. The session moves from database diagrams and table relationships to basic queries for choosing columns and filtering rows. SQL can help people work with structured data, but learning it does not guarantee a job or a particular career outcome.
What SQL does
SQL stands for Structured Query Language. It is used to define, query and manage data in relational database systems. A database stores information in tables; a table contains rows, and each row contains values for its columns.
Read a database diagram
An entity-relationship diagram, or ER diagram, shows the main entities in a data model and how they relate. For example, a database for students and classes might store students in one table and classes in another, then use a third table to record which student takes which class.
A primary key identifies a row in its table. A foreign key refers to a key in another table and helps preserve the relationship between them. A one-to-many relationship means that one row in one table can relate to multiple rows in another—for example, one class may have many enrollment records.
Start with SELECT, FROM and WHERE
A basic query names the columns to return, the table to read and the conditions a row must meet:
SELECT customer_name, order_date
FROM orders
WHERE status = 'paid';
SELECT lists the output columns, FROM identifies the table, and WHERE filters rows. The exact fields and table names depend on the database you are querying.
Choose columns and label results
SELECT * requests every column and can be convenient while exploring a small dataset. For repeatable work, listing the columns you need is clearer and avoids unexpected output if the table changes. An alias can give a calculated or selected column a readable label:
SELECT order_total AS total
FROM orders;
SQL dialects differ. The syntax for combining text, handling dates and using certain functions may vary between PostgreSQL, SQLite, MySQL and other systems. Check the documentation for the database you use.
Use comments and statement endings
In PostgreSQL, a double dash begins a single-line comment:
-- Return only paid orders
SELECT order_id
FROM orders
WHERE status = 'paid';
A semicolon commonly marks the end of a statement in interactive tools and scripts. Follow the conventions of your database client and SQL dialect.
How SQL differs from a spreadsheet
A spreadsheet is useful for viewing and editing a grid of data. SQL is a language for asking a database to return or change structured data. They can work together, but neither is simply a more powerful version of the other. The right tool depends on the size, structure and workflow of the data.
A practical learning sequence
- Identify the tables and the meaning of their columns.
- Use
SELECTwith explicit columns and aFROMtable. - Add a
WHEREcondition and check that the returned rows match your question. - Learn keys and relationships before joining tables.
- Practice on a sample database and consult the documentation for its SQL dialect.
Frequently asked questions
Is SQL only for data scientists?
No. Analysts, researchers, software developers and many other roles use SQL. The level of SQL required differs by job.
Does learning SQL guarantee a data job?
No. SQL is one useful skill, but hiring also depends on the role, experience and other qualifications.
Are SQL commands identical in every database?
Many basic commands are similar, but databases have differences in functions and syntax. Verify examples in the documentation for your system.