1.12.2 One Table for everything (MySQL)?

Discussion in 'Spigot Plugin Development' started by TaskID, Oct 3, 2020.

  1. Hello.
    I currently have a Minecraft Server with some different tables. Clans, Users (BanSystem), Users (Coins), Users (PlayTime).

    Would it be better to make one table with everything (Bansystem, Coins, Playtime, etc.)?

    My Tables are looking like that right now:

    Table: Users
    Name, UUID, BanID, MuteID, Bans, Mutes

    (The BanID is always NULL, except a user gets banned. I have all bans with the details in another table, and this BanID just says: ok, you are currently banned with -BanID- Ban (Same with MuteID).

    Table: Coins
    UUID, Coins, CoinsHidden

    Table: Playtime
    UUID, CurrentPlaytime, FirstConnect

    Would it be better to make it for example like that:
    Table: Users
    Name, UUID, Coins, CoinsHidden, CurrentPlaytime, FirstConect, BanID, MuteID, Bans, Mutes

    I don't really know, I mean, Databases are very fast. Currently, when I need a Name from a UUID, I take it from the "Users" table. Now I wanted to make a coins toplist, and realized that it'd be maybe better if I could just select the Name CurrentPlaytime directly, without getting the name from another database table.
    Hope somebody can help :)
  2. It's basic database design.
    Always split your tables up, it's something called "Normalization" and makes things much more efficient. Doing this also helps with expanding down the line.

    EDIT: Your current multi-table design is fine. However you should have UUID as the first value as it's unique when Names aren't.
  3. You should really look into FOREIGN KEY and JOIN.
  4. Yes, I've got that. I only have UUID as "keys".
    But thanks, then I'm not going to change anything! :D