MyMisPal
← SQL lessons
Lesson 1 of 12

What is a database?

A relational database stores data in tables. Each table represents one thing from the business: employees, customers, products. Each row is one record (one employee), and each column is one attribute (name, salary).

A primary key is a column whose value never repeats and identifies each row, such as emp_id. A foreign key points to the primary key of another table; that is how tables connect. For example, dept_id in employees tells you which department an employee belongs to.

The language we use to talk to a database is SQL. Database management systems (DBMS) such as MySQL, Oracle and SQL Server all understand SQL with small differences. In these lessons we work on a small company database with six tables; you can browse it in the editor.

SQL
SELECT * FROM departments;

The star * means “all columns”. Press “Try it” on any example to load it into the editor and run it.

In MySQLIn MySQL you first pick a database: USE company; then list tables with SHOW TABLES; and see a table's columns with DESCRIBE employees;

Exercises

Exercise 1

Show all the data in the products table.

Spotted a mistake on this page, or have an idea to improve the site?