Panini-Devs / bismarck

Multipurpose discord bot written in rust!
GNU General Public License v3.0
5 stars 5 forks source link

wish simulator sql added #20

Closed AimarIbarra closed 5 months ago

AimarIbarra commented 5 months ago

good heavens it was hard to get get the project running

Well then onto the explanation:

An user has an id, the currency, and some rolled wishes, nothing special.

An item has an id, name, rarity 3|4|5, an availability, and a kind, which can be weapon or character.

An user can have an indeterminate amount of items, and an item may have an indeterminate amount of users, to represent this we create a new table representing this relation. If we then want to query the items an user owns we would run the following:

SELECT *
FROM item
WHERE
  item.id IN (
    SELECT item
        FROM user_item
        WHERE user = <user_id>
  );

If we only wanted the item ids we would just use the inner query. SQL engines are optimized for this.

This relation logic is also applied to represent the item pools of any given wish.

paninizer commented 5 months ago

Merged Thanks 👍