What is a database
Part of the Fundamentals section of Coddy's SQL journey — lesson 2 of 72.
Databases are like large buckets that store data in an organized manner.
Here are two examples of when we would like to create a database:
- A database for a university to save data about students, courses, and lecturers.
- A database for a car agency to track sales, car storage, and employees.
- And many more
Inside a database there are tables, and each table has a name, column names, and rows.
For example, this is a workers table:
| firstname | lastname | age | exp_years | gender | |
|---|---|---|---|---|---|
| 1 | Ghully | Thuas | 29 | 2.3 | Female |
| 2 | Bostal | Shkolky | 32 | 0.2 | Male |
| 3 | Qaostu | Malop | 21 | 4 | Female |
The workers table has 5 data columns (firstname, lastname, age, exp_years, gender) and 3 rows. The first column (showing 1, 2, 3) is just a row number, not a data column.
We don't need any special tool to know that we have 3 workers, and it's easy to calculate the average age of all of them (29 + 32 + 21) / 3.
But what happens when we have a thousand or even a million rows?
That's where databases and SQL (Structured Query Language) come in.
SQL is a standard language designed specifically for managing and manipulating data in databases.
Databases store all of the tables, and SQL helps us extract and analyze the data we need.
To extract the whole table from the database, we need to specify which columns to SELECT and FROM which table to extract.
To do this we'll write:
SELECT column1, column2, column3 FROM table_nameChallenge
EasyAvailable tables and columns:
workers:firstname,lastname,age,exp_years,gender
Write a query to extract the whole table (all of the columns) from the database.
Use SELECT * or list all columns explicitly to retrieve every column from the workers table.
Cheat sheet
Databases store data in organized tables with columns and rows. SQL (Structured Query Language) is used to manage and manipulate data in databases.
To extract data from a database table, use the SELECT statement with the FROM clause:
SELECT column1, column2, column3 FROM table_nameTry it yourself
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Fundamentals
4More Keywords
The IN keywordThe BETWEEN keywordThe LIKE keywordThe AS keywordRecap - Cellphone Models2Conditions
Conditions BasicsThe AND keywordThe OR keywordThe NOT keywordMultiple Conditions CombinedParenthesisBooleans5Arithmetic Operations
Mathematical OperatorsMathematical ColumnsThe Modulo OperationThe ROUND() Function3Specific Return Format
Null valuesSort Results Part 1Sort Results Part 2Recap - Cyber Security FirmLimit number of recordsRecap - Vehicle Factory6Intro Challenges
Recap - Parliamentary ElectionRecap - Police Criminal ArrestRecap - Bar Beverage ContainerRecap - Engineer new columns