Database¶
This section is for database related topics.
What is a database?¶
A database is a collection of information that is organized so that it can be easily accessed, managed and updated. Data is organized into rows, columns and tables, and it is indexed to make it easier to find relevant information.
Goal
Goals for this section:
- Learn what a database is
- Setup your first database
Why do we need databases?¶
Normally, when we create data in a program, it is stored in the memory of the computer. But when the program is closed, the data is lost. To prevent this, we need a database. The database stores the data on the hard drive of the computer, so it is not lost when the program is closed.
Why not just use files?¶
You could just use files to store data, but that would be very inefficient. You would have to write a lot of code to read and write the data from the files. You would also have to write a lot of code to search for data in the files. Databases are much more efficient than files.
They also structure the data in a way that makes it easier to work with. For example, if you have a database of customers, you can easily find all the customers who live in a certain city, or all the customers who have bought a certain product.