What Is a Database, and Why Does Your Website Need One?

The place where your website remembers things

6 min read

Imagine you build a website on Gwecode where people can sign up and leave comments. The moment someone signs up, your website needs to remember their name and email. The moment they leave a comment, your website needs to remember what they wrote. Where does all of that information actually live?

It lives in a database. A database is a place, separate from your webpage code, where information is stored in an organized way, safely, for as long as you need it. Your website's code asks the database questions like "who is this user?" or "what are the latest posts?" and the database answers.

This matters because code by itself has a short memory. When you write a variable in a script, it disappears the moment that script finishes running. A database is different. It keeps your data around between visits, between page loads, even between server restarts.

You can think of a database as a very well organized filing cabinet. Instead of loose papers everywhere, everything is sorted into labeled folders, and anyone with the right key can quickly find exactly what they need, even if thousands of people are looking at the same time.

SQL: the language you use to talk to a database

To ask a database a question, or tell it to store something new, you use a language called SQL, short for Structured Query Language. SQL is not like a general programming language such as JavaScript or Python. It is smaller and more focused. Almost everything you do in SQL is a short, readable sentence.

Here is a taste of what a question to the database looks like. Do not worry about the exact words yet, we will build up to this slowly over the whole course.

SELECT username, email FROM users;

That single line asks the database: "show me the username and email of every user you have stored." You will learn exactly how this works in the very next lesson.

Real examples you will recognize

A blog needs a database to store its posts and comments. An online shop needs a database to store its products, its customers, and every order that gets placed. A simple to do list app needs a database to remember your tasks even after you close the browser tab. Almost any website that feels alive, that remembers you, is backed by a database.

Over this course you will learn to create tables to hold your data, ask for exactly the information you need, add new data, change existing data safely, and even combine information from two different tables. By the end, you will understand the data side of a real website.

You do not need to memorize any of this right away. Every lesson builds gently on the last one, and you can always come back and reread a lesson later.

Quick check

Q1 Why does a website usually need a database?

Q2 What language do you use in this course to ask a database questions and give it instructions?

Want to save your progress? It's free.

Create a free account