A database is a place where structured data is stored. Entities are groups of objects that share common characteristics. Objects are individual instances of entities.
We are going to study relational databases, where entities are tables and table rows are their objects.
To work with databases you need a DBMS, or database management system. This is a set of programs that allows you to create a database, fill it with new tables, and edit and display the contents of existing tables. In our course we will use PostgreSQL, one of the most popular DBMS.
A table is a set of rows and columns. Columns are called fields. They contain the object's features. Each field has a unique name and a specific data type. Table rows are called tuples or records. Each row contains information about one particular object. A cell is a unit where a row and column intersect.
Primary keys are used to give each row a unique identifier. Some tables use several fields at once as their primary keys; in such cases, they're called composite primary keys.
SQL is a computer language designed for managing data in relational databases.. SQL syntax is different from Python's. Here are its basic characteristics:
---- a single-line comment in SQL
/* and */:/* a multi-line comment
has
several
lines */
SELECT, WHERE, FROM
; :SELECT
*
FROM
table_name;
-- A statement that requests all the data from the table ends with ";"
SELECT
*
FROM
table_name
WHERE
column_name IN (1,7,9);
-- A statement that selects data by condition also ends with ";"