Code

How Databases Work with Ecommerce Applications

“Database-backed.” “Powered by PostgreSQL.” “Cloud database.” “Redundant, multi-zone NoSQL backend.”

Those are all terms that describe ecommerce systems that use databases. But, what, exactly, do those terms mean? Is it good or bad to have a database? What does a database do? Can you have an ecommerce store without a database?

In this article, I’ll review databases and their purpose for ecommerce sites.

Database Basics

I’ll start with a basic understanding of what a database is. There are many buzzwords and jargon around databases. It can be confusing to a storeowner and even to developers.

A database is just a system that organizes data. You have a set of data, perhaps some order transactions, and the database organizes those transactions based on settings you define.

In the context of ecommerce applications, data falls into two categories:

  • Site content;
  • Transaction data.

Site Content

Site content is what you see when you’re browsing a storefront. It’s the data that generates the dynamic HTML pages, including:

  • Content pages like about us, contact, FAQ, and shipping policies;
  • Product pages showing details — price, dimensions, weight, color, size — for the items you sell;
  • Category pages grouping similar products.

Transactional Data

Transactional data, on the other hand, is a result of users taking action on a page. A newly installed ecommerce application will have no transactional content. But it will, hopefully, as shoppers purchase products and as the merchant populates those products on the site.

Examples of transactional data include:

  • Customer orders: customer name, address, phone, email, products purchased;
  • Inventory updates: items sold, replenished, out of stock.

The design of your database will determine what it stores, how it’s organized, and how your application code can access it.

Databases for Ecommerce

The main purpose to a database is to store information. Have a question about a customer order? Check the database. Want to know a product price? Check the database.

By using a database, a web application can ignore the actual data and focus more on the presentation and behavior of that data. The end result is that the amount of code and logic in the web application is much smaller and easier to understand.

For example, if all products have images, then the web application just needs to ask for that data — i.e., an image — and show it as a product preview. It doesn’t care if there is one image, three images, or what the images actually are showing. The application just expects to get back an image URL, which it then displays.

The page for this hypothetical product, "Aerodynamic Concrete Lamp," has just one image.

The page for this hypothetical product, “Aerodynamic Concrete Lamp,” has just one image.

Same product page but showing a product with three images.

The product page for “Aerodynamic Aluminum Bench” has three images.

What a Database Can Do

Here’s what most ecommerce databases do.

  • Track transactions. One of the most important jobs of the database is to track and manage transactions. It needs to keep track of every order along with the details that your company needs to process the transaction. There is much data needed to process an order. This functionality dominates most ecommerce databases.

It’s common to see databases with millions and billions of separate data entries just to support order transactions alone.

  • Organize products. Another important database function is organizing products. Depending on the store, there could be millions of products, each with different variants and styles. Organizing this mix of products and options is a critical function of an ecommerce database.
  • Provide structure to your store data. Putting structure around vast amounts of data is one of the strengths of a database. It doesn’t matter if you have one product or a million, they are all organized the same. It makes creating the code to access that data easier. The ecommerce application doesn’t have to manage the data, just the structure.

Database Weaknesses

Databases have weaknesses, too, such as complexity and lack of analysis ability.

  • Complexity. If you’re only selling one product, you might not need a database. Your store would be pretty simple, code wise. But if you have millions of products, trying to organize them without a database is seemingly impossible.

There’s a real cost of adding a database to a store. Even if your needs are minor, there are still setup and management steps, including server setup, authentication, data organization (schema), data validation, and more.

  • Data analysis. Another weakness with the standard ecommerce database is that it’s geared towards orders. The data is organized in a way to make it easy to add and update transactions.

Unfortunately, this organization method is not ideal for data analysis.

For example, if you wanted to identify the top 10 percent of your customers, you’d likely organize the database differently. As is, your analysis and reporting programs have to reorganize the data on the fly, slowing down response times. This is why many larger databases are copied and reorganized into a different structure for reporting and analysis.

Necessity of Databases

Unless you have a very small ecommerce store on a custom platform, you’re probably using a database already. You don’t really have much of a choice. There is so much information that a store processes, it’s impractical to not use a database.

In short, databases are powerful, well-tested, and suitable for ecommerce.

See the second installment of Eric Davis’s series on databases, at “Understanding 4 Database Types, for Ecommerce.”

Eric Davis
Eric Davis
Bio


x