跳至主要内容

Database Schema

This chapter will explain the implementation details of QuickShop Hikari's database storage format.

Tables

This section explains the database tables created by QuickShop-Hikari.
Unless otherwise specified, the initial qs_ in table name is the table prefix.
For the latest code definition for each table, see: DataTables.java

data

This data table stores all the existing store data on this server or the store data that has been deleted but is still referenced in a specific form, and does not contain coordinate information.
No matter what, a data record should not be modified after it is created, until it got deleted.
Any new changes to the shop should create a new copy, apply the changes to the copy, and insert it as a new record.

Basiclly, Copy-on-write.

A data record only be deleted from the database when no any table references their data_id.

Column NameDataTypeDefaultDescription
idINT UNSIGNED Primary KeyAuto IncrementRecord ID (aka. data_id)
ownerVARCHAR(36) NOT NULLN/AThe shop owner unique id (aka. UUID)
itemTEXT NOT NULLN/AYAML serialized ItemStack for this shop data entry
typeINT NOT NULL0The shoptype id, Indicates the store type
currencyVARCHAR(64)NULLThe currency name for this shop data entry. NULL if using Vault or not supported
priceDECIMAL(32,2) NOT NULLN/AThe price per stack for this shop data entry
unlimitedBIT NOT NULL0Indicates whether this store is an unlimited store, 0=Limited, 1=Unlimited
hologramBIT NOT NULL0Indicates the suspension status of this store's display item, 0=Follow global settings, 1=Disabled
tax_accountVARCHAR(36)NULLThe uuid for tax account, If it is not NULL, tax will be paid to the specified account
permissionsMEDIUMTEXTEmpty JsonIndicates the override status of the store player permission group, serilized to JSON string
extraLONGTEXTEmpty YamlUsed to store experimental settings of QuickShop Hikari or persistent data of other plugins
inv_wrapperVARCHAR(255) NOT NULLN/AUnique identifier for InventoryWrapper for this shop data entry
inv_symbol_linkTEXT NOT NULLN/AUnique Inventory symbol used to pass to InventoryWrapper, for locating inventory
create_timeDATETIME NOT NULLDataset Insert TimeIndicates when this store was created
benefitMEDIUMTEXTN/ASetup of Benefit Allocation after JSON Serialization

shops

This table is used to store shop to shop data mapping, so that shop ID will not change when shop data changes.
Multiple shop_id can correspond to the same data_id.

Column NameDataTypeDefaultDescription
idINT UNSIGNED Primary KeyAuto IncrementRecord ID (aka. shop_id)
data_idINT UNSIGNED NOT NULLN/AData Record ID (aka. data_id)

shop_map

This table is used to store shop_id to shop location in Bukkit mapping. At the same time, this is also the key record of loading the store into the game world.

Column NameDataTypeDefaultDescription
worldVARCHAR(32) NOT NULLN/AThe world name in Bukkit
xINT NOT NULLN/AThe block X position for this shop
yINT NOT NULLN/AThe block Y position for this shop
zINT NOT NULLN/AThe block Z position for this shop

messages

This table is used to store offline messages.

Column NameDataTypeDefaultDescription
idINT UNSIGNED Primary KeyAuto IncrementRecord ID
receiverVARCHAR(36) NOT NULLN/AThe unique id for receiver
timeDATETIMEDataset Insert TimeThe time that this message created
contentMEDIUMTEXT NOT NULLN/ASerialized Adventure Component

metadata

This table is used to store the metadata, e.g database schema version.

Column NameDataTypeDefaultDescription
keyVARCHAR(255) NOT NULL Primary KeyN/AThe key
valueLONGTEXT NOT NULLN/AThe value

player

This table is used to store the player data, e.g locales.

Column NameDataTypeDefaultDescription
uuidVARCHAR(36) NOT NULL Primary KeyN/AThe player unique id
localeVARCHAR(255) NOT NULLN/AThe player's client locale
cachedNameVARCHAR(255) NOT NULLN/AThe player's username last known

external_cache

This table is stored cached shop space/stock for WebUI or what else other pure database apps.

Column NameDataTypeDefaultDescription
shopINT UNSIGNED NOT NULL Primary KeyN/AThe id of shop (aka. shop_id)
stockINT NOT NULLN/AThe stock for this shop
spaceINT NOT NULLN/AThe space for this shop

log_purchase

This table records all history purchases activities on this server.

Column NameDataTypeDefaultDescription
idINT UNSIGNED Primary KeyAuto IncrementRecord ID
timeDATETIME NOT NULLDataset Insert TimeThe time that this purchase created
shopINT UNSIGNED NOT NULLN/AThe shop id (aka. shop_id)
dataINT UNSIGNED NOT NULLN/AThe data id (aka. data_id)
buyerVARCHAR(36) NOT NULLN/AThe purchaser unique id, In fact, it is more accurate to call it a purchaser, not only selling but also buying
typeVARCHAR(32) NOT NULLN/AThe ShopType enum name
amountINT NOT NULLN/APurchased stack amount
moneyDECIMAL(32,2) NOT NULLN/ATotal balance in this purchase
tax_amountDECIMAL(32,2) NOT NULL0The tax in this purchase

log_transaction

TODO

log_changes

TODO

log_others

TODO