Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4543458
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:32:04+00:00 2026-05-21T15:32:04+00:00

I have a general gut feeling about the difference but I’m unable to pinpoint

  • 0

I have a general gut feeling about the difference but I’m unable to pinpoint exactly what makes a database different from global state.

With a naive definition of “global state”, a database is generally at least application-global. You could conceivably have an app that changes databases mid-execution, but in the general case it is used globally.

As for state, I don’t think I need to argue the case that a database contains state.

So what makes a database different from the “bad” kind of global state?

This question came up because I’m trying to avoid tight-coupling where an object needs to know about its parent.

For example, say you’re playing a strategy game, and one of your units have an ability that says when it deals damage to an enemy unit, that unit’s owner loses x gold where x is the amount of damage dealt.

Well, under normal circumstances, a unit shouldn’t have to know who it’s owner is. The owner is the one controlling the unit, so the owner just issues commands to the unit and it does its thing.

However because of external factors, there becomes a need to find out who the owner of a unit is. In this case, the attacking unit knows the unit it is attacking, that’s fine. But now in addition to knowing the unit it’s attacking it must further know it’s owner in order to cause the owner to lose 5 gold.

I’ve already diverged more from the original question than I intended, but if the state of the game was stored in a relational database it would be trivial to query for the owner of the target without units needing to know directly who their owner was. If such a database were an object, I would call that database a god-object in the sense that it knows the entire state of everything, and additionally is mutable.

What then makes a database different from global state?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T15:32:04+00:00Added an answer on May 21, 2026 at 3:32 pm

    You could equally ask, “Why isn’t an operating system considered a form of global state?” I guess depending on how you want to look at it, it is. But who cares? It’s not the kind of global state that causes so many problems, namely global variables in library code. Both databases and operating systems are enabling technologies for a huge variety of programs–they’ve proven their worth. This is not to say either is without its problems: databases can make unit testing more difficult (hint: try mocks), and the wide variety of operating systems can make it difficult to make a program that everyone can use equally well.

    Another way to look at it: there are valid alternatives to global state in most code, whereas the alternative to using a database would often be to effectively implement a database in your own code (whether you call it a database or not).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a general question about whether people think you should use a database
I'm about to start using location services, but have a general question about how
I have a general question about WPF performance. We have a relatively simple forms
I have a general question regarding table indices on foreign keys in database modeling.
I have a general question about desktop applications. My friend and I were discussing
This question is specific to Erlang, but may have general implications to other IO
I have a general question about php and mysql. So currently, I have a
I read about creating user groups, I think I have the general idea. For
I have a general doubt about how to design Android apps that use a
I have general question about Linux. Will the inode be created if I create

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.