I am very curious as to how databases are used in the real world, whether you’re using MySQL and what not, how does it all come together in a real world business? Banking and gaming I know, but is it something that gets stored on data centres and then put into a VM?

I might be overcomplexing this but I understand the good use cases with VMs and containers etc just not with databases.

I’d google, but I’d like a ELI5 due to my smooth brain with these concepts, thank you.

  • Max-P@lemmy.max-p.me
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 month ago

    A good ELI5 is to imagine a couple of Excel sheets. Each sheet is a “table” and each row is a record. So you’re gonna have a column for the first name, a column for the last name, a column for the email address and so on. That’d be your users table/sheet.

    Then you would have another Excel sheets that contains posts. Each post record references the row number of the users sheet so you can cross-reference the user record of the author of the post record.

    And so on. It’s a way to store, lookup and retrieve records, usually cross-referencing other records until you have all the information you need to serve a particular request. There’s an index like the table of content of a book that lets you quickly find on which page the record you’re looking for is.

    We use databases because they’re engines designed to ensure data consistency, and fast access to the data in a structured manner. Usually that runs on some server that other servers connect to to access the database, so all servers can have the same view of the data. That can be a VM in the cloud, that can be a cluster of VMs in a cloud, it can be Docker containers. It’s just software that manages data so we don’t have to reinvent the wheel everytime we need to store stuff. Then you just ask questions to the database, like, “what’s all the last 50 posts made by this user number” (SELECT user.username, post.title FROM posts LEFT JOIN users USING (user_id) WHERE posts.user_id = 42 ORDER BY posts.date_inserted ASC LIMIT 50).

  • 667@lemmy.radio
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    1 month ago

    Computing without databases is like going into a grocery store and all of the items are in one great pile. Sure, given enough time (CPU) and resources (RAM) you could find what you’re looking for, but it’s horribly inefficient.

    Instead, things which are similar are grouped together, like the baking aisle (tables) and if you have to get most of the items for a cake, you know it’s on a specific shelf.

  • subversive_dev@lemmy.ml
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    1 month ago

    ELI5: a database is the “memory” of a program.

    Every piece of data that any software uses almost certainly comes from and goes to multiple databases.

    Once the data is stored, you can execute “queries” to have powerful access to update many records at a time, read particular records based on their relationship to other records, and so much more.

    Your bank balances, your purchase history, your emails, every part of your digital life is almost certainly spread across a constellation of databases.

    Bonus Fediverse content:

    Lemmy itself uses the Postgres database extensively. Posts, users, comments, votes and more are all individually stored in the database.

    Mastodon also uses Postgres. If a post goes up on Lemmy, and a Mastodon server is federated with it, the Lemmy server will send out a HTTP request to the Mastodon server containing the contents of the post. The Mastodon server will use this information to write its own record of the post in its own database.

    Regarding your question about VMs: You can run a database inside a VM, or give the VM access to an outside database via queries, or both! You might run SQLlite (a small and excellent embedded database) on the VM to track its local state, while also running queries against a large postgres database to synchronize with other services in the cluster.

  • AlternateRoute@lemmy.ca
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 month ago

    ELI5 due to my smooth brain with these concepts

    Database is a board term, nearly any computer system that stores structured data like lists of names or transactions has a database of some kind. Dedicated database platforms like MySQL just make it more efficient / faster / easier to query and store data.

    • 𝒎𝒂𝒏𝒊𝒆𝒍@sopuli.xyz
      link
      fedilink
      English
      arrow-up
      0
      ·
      edit-2
      1 month ago

      Yeah, even the file system is a hierarchical database, same with Windows registry, Internet domain registry too, not any database has to be SQL or relations based. There also are time based databases like influxdb for storing time based data, like metrics, logs

  • cy_narrator@discuss.tchncs.de
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 month ago

    If I understood your question correctly,

    A database is a base for your data, its where your data lives.

    A data is the most important thing for most modern applications. You have an account in Lemmy. You have made posts and comments. All that post texts, images, etc has to be recorded somewhere in the server. Thats what a database does.

  • rottingleaf@lemmy.zip
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 month ago

    I don’t think many businesses use MySQL when they can use PostgreSQL. Oracle is used very often. MSSQL in stupid cases.

    You obviously need databases to, eh, store data, index it, process it, access it.

    Also, as others say, it’s a wide concept. A file system is a database. In some sense BitTorrent DHT is a database.

  • expr@programming.dev
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 month ago

    Databases aren’t related to VMs or containers.

    https://en.m.wikipedia.org/wiki/Database does a good job of describing what a database is. That page also has a lot of examples of uses of databases.

    To answer your question about MySQL: in my experience it’s rarely used outside of classrooms or archaic systems. Postgres is a much better general-purpose option for SQL. Sqlite is also nice for different use cases (such as a database on a mobile device).

    • Max-P@lemmy.max-p.me
      link
      fedilink
      English
      arrow-up
      0
      ·
      1 month ago

      MySQL is unfortunately still rather popular. Loads of PHP based sites like Wikipedia and WordPress are all MySQL still.

      It’s catching up a bit, especially the forks like Percona Server and MariaDB.