What Is a Database
How a Database Organizes Information
What is a database? A database is an organized collection of electronically stored data that software can add, search, change and delete. It works like a digital filing system with strict rules about how each item is labeled and where it is kept.
Data in a database is grouped into structures, most often tables. Each table holds one kind of information, such as customers or products. A row is one record, such as a single customer, and a column is one attribute of that record, such as an email address. Learn more in database tables, rows and columns.
Databases are built for three jobs: storing data reliably, retrieving exactly the subset you need, and letting many people or programs use the same data at once without corrupting it. A spreadsheet can hold similar information, but it has few built-in rules that protect the data from conflicting edits.
Why Websites Depend on a Database
Many websites are dynamic, which means their pages are assembled from stored data each time someone visits. A news site, an online shop or a members-only forum keeps its content in a database rather than in fixed HTML files.
A content management system such as WordPress stores posts, page text, comments, menu settings and user accounts in database tables. When a visitor opens a page, the application asks the database for the matching post, places it into a template and sends the finished page to the browser.
An online shop uses the same approach for its product catalog, stock levels, customer accounts and orders. Because all of this sits in one place, a stock change made in the admin area appears immediately on the product page and at checkout.
A static website, by contrast, serves prepared files and may need no database at all. The choice depends on how often content changes and whether visitors need logins, search or transactions.
Frequently asked questions
Do all websites need a database?
No. A static website made of fixed HTML, CSS and images can run without one. Sites with user accounts, comments, search, shopping carts or frequently updated content usually rely on a database to store and retrieve that information.
Where is a website's database stored?
It runs on a database server, such as MySQL or MariaDB, on the hosting server or on a managed database service. Hosting control panels usually let you create databases. The website connects to its database using a database name, a user and a password. The database management system is the software that runs that server.