What’s a database and how do websites use them?

database

In simplest terms, a database is a collection of data and information.

There are many database systems and formats, but the thing they all share is that they’re a way to save information for later – in an organized manner that allows for orderly access in the future.

Conceptually, that much is pretty simple. Things get a lot more complicated when we start to consider different types of databases, exactly how the data is stored, and how we can later access and reference that stored information.

How Do Websites Use Databases?

A website built from simple HTML files on a public web server might not need a database at all. In its most basic form, this is a website that keeps all of its content as separate files, and it doesn’t need to store new information because the output of the website is static and does not change unless the site’s administrator changes those files.

Most websites these days are a little more complex, and they’re designed to use user input to influence the output of the website. Content management systems like WordPress use a database to store everything from the posts and user comments to account and login information and usage records.

So every time you create a new post in WordPress, a new entry is created in the database under the table wp_posts. That entry will include a field for the title, the date/time of the post, edit and revision history, the content of the post, as well as any excerpt, meta descriptions, or meta keywords that have been assigned to the post. Similarly, when a user makes a comment, this creates a new entry in wp_comments that details the user name, URL, timestamp, and the content of the comment. When a user clicks on a link to that post, the web server will go to the database and collect all of that information so that it can build the post and load any comments that are associated with it.

If your hosting is underpowered or your database and website aren’t configured well, this might take a few seconds. If you’re on a fast server with optimized code, it may happen so quickly that you don’t even notice a delay.

How Do Websites Interact with a Database?

While HTML code doesn’t support direct interaction with databases, there are a lot of ways around this limitation. The most popular solution is to use a secondary programming or scripting language like PHP or Python that is capable of both connecting to a database as well as generating “static” HTML output.

WordPress, for example, is basically a collection of PHP files that include instructions for setting up the database, modifying it as necessary, and recalling the information stored there when someone requests it over the internet.

In other words, this whole website is just a fancy database viewer.

Common Database Types

MySQL – MySQL is probably the most common database on the web. It’s free to use and open source, so a lot of projects have been built around it. This is the database system that WordPress and most of the popular content management systems use.

AzureSQL – AzureSQL is similar to MySQL, but it is optimized and designed to run on Microsoft Servers. Although similar, they are not fully compatible and migration can be difficult.

MongoDB – MongoDB is a little bit different. While SQL is a relational database, MongoDB is non-relational. A relational database stores multiple values for a single entry, while non-relational databases like Mongo focus on a document-per-entry style of approach. The advantage here is that these types of databases can be a little less intense on the server’s CPU, but the downside is that they tend to use more RAM and hard drive space.

Summary
What's a database and how do websites use them?
Article Name
What's a database and how do websites use them?
Description
A introductory guide to what databases are and how websites use them to provide dynamic content. Learn about the most common types of databases in use for web development, how they're different, and how they work with your website and web application projects to provide additional functions that static websites can't deliver.
Author
Publisher Name
WebsiteBuilding.biz

Be the first to comment

Leave a Reply

Your email address will not be published.


*