Coder12432f
Coder12432f

Reputation: 27

Tips to structure this database

I want to make a database for a plugin I am making for Minecraft. I've been trying to figure the best way to structure this but I have failed many times, could anyone give me some tips?

The idea is: There will be a active_shops table => this represents individual shops, saving the information about each shop.

I need a table called player_shops => this table will have an AI ID and store things like, members and the name of the shop.

Here is where the problem is, when adding the active shop I would need to include the ID from the player_shops as a secondary key.

But a player without a player shop can also make an active shop so instead of that ID I would need to store the player's UUID, which is a string of characters.

Please help to figure this out.

Upvotes: 0

Views: 64

Answers (1)

Nic3500
Nic3500

Reputation: 8621

The information provided is scarce so it might not apply to your context, but...

Your original DB structure looks like:

enter image description here

Besides the problem you stated, you will not be able to normalize this structure.

I propose something like this:

enter image description here

  • The relation Shop - Player is to designate the "owner" of the shop.
  • The Member link table is to link the players members of the shop.
  • Since I do not know the difference between an active shop, and a player shop, I isolated that characteristic into a ShopType table, allowing you to choose one or the other.
  • Doing it like this allows a player to have any type of shop he wants. A shop is a shop, from your description I do not understand why you need to have 2 tables for your 2 shop types. A shop is a shop, being Active or Player type.
  • This is not a complete, add the different missing fields for each table, this illustrates only the structure.

The other possibility is if you need a shop to be 1) player 2) active 3) both. Then the shop table should be modified like so:

enter image description here

  • the type concept is removed, and boolean attributes define the type of the shop.

This is obviously a work in progress, hopefully it helps enough to get you started thinking of your solution another way.

Upvotes: 1

Related Questions