What is a Database?

A database is a structured collection of data usually stored externally to a program or your code. Data is stored within a databases usually within tables, that have columns and rows. Indexing is usually used to identify specific data and make it easier to find the data you are want within your program. The tables contain different types of data, the columns of each table contain what fields each data has and what data type they are, and the rows contain entries for each database. You could have a database table for Users, with columns for their username, firstname, lastname, and age. Then each row would contain an individual user that fills in data for each field; a username, firstname, lastname, and age.

Image you have a list of users you wish to store within your program, or a list of films, music, people, etc. You could store all this data within variables inside the program, this is called storing in-memory. However, depending on the amount of data the computer could run out of memory and stop working. Also, when storing data within a database you can easier retrieve certain data. You could find names that begin with a certain letter, or get names in a certain order (e.g. alphabetically), limit the amount of data to return, etc. When storing data within variables, in-memory, you will have to process all these sorting and return queries yourself in code. When using a database you get the retrieving calculations and processing for free (e.g. you don’t have to write any code to sort data based on a query). A query is what we send to the database to retrieve certain data, such as a query that asks for all names in alphabetical order.

Databases also allow you to create new entries, retrieve entries, update existing entries, and delete entries. Imageine you are storing people, you can create new people, retrieve the people’s information, update someone’s name, and remove a person from the database. This is called CRUD, create, read, update, and delete.

There are also different types of databases, such as; sql, nosql, relational, non-relation, graph, etc. The choice of which type of database depends on what type of data you are storing and how you wish to access the data.

1 thought on “What is a Database?

Leave a Reply