The Concept of the Database
Understand the basic concept of the database in this lesson.
Introduction to databases
A database is persistent storage that can be used for specific applications. It’s usually used to store a lot of data from a web application, including posts from a social media application and products from an e-commerce application. A database can also log data for debugging purposes. There are two main types of databases, relational and non-relational.
Relational database
A relational database is a database that is structured relationally using tables that can be interconnected using relation mechanisms. In relational databases, a single record or data is stored inside a table that contains many columns. The table inside the relational database is illustrated in this image.
As seen in the image above, the table called products
contains many columns that are related to product data, including the id
, name
, price
, and quantity
. Each column has a different data type and constraint. For example, in the id
column, the data type is an integer with a constraint as the primary key (illustrated in the PK
annotation). Another example can be seen in the name
column that has a VARCHAR(255)
data type, which means this column can be used for a string data type with a maximum length of 255 characters.
There are many examples of relational databases, such as MySQL and Postgres, to name a few.
In relational databases, many tables can be connected using different relationships. There are three main types of relationships: one-to-one, one-to-many, and ...