Question about storage

frxq

Developer
Supreme
Feedback score
27
Posts
479
Reactions
186
Resources
3
Hi,

Im currently working on a project in my free time which is a custom gangs core, I had a question relating to player storage, gangs and players are stored in sql, however i dont know what the best way would be to get all of the gang members? my thought was obviously to run an async query through the members and return everyone with the requested gang id, but im unsure if this is the best way to go about this? any advice would be lovely :)
 
Type
Requesting
Provided by
Individual
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

Casey.

Voltix Labs
Premium
Feedback score
0
Posts
145
Reactions
39
Resources
0
Depends how you store the data. Can you provide us with an example of your data model.
 

GabyTM

@gabytm / gabytm.me/discord
Supreme
Feedback score
44
Posts
425
Reactions
191
Resources
6
you can have a table for gangs with an integer primary key, and one for players, with a foreign key that points to the id of a gang (if they are in one). Then the query would be
SQL:
SELECT * FROM players WHERE gang_id = id-here;
 

frxq

Developer
Supreme
Feedback score
27
Posts
479
Reactions
186
Resources
3
Depends how you store the data. Can you provide us with an example of your data model.
you can have a table for gangs with an integer primary key, and one for players, with a foreign key that points to the id of a gang (if they are in one). Then the query would be
SQL:
SELECT * FROM players WHERE gang_id = id-here;
Sorry if i was unclear i kinda meant is there a better solution than querying every player in the db every time the gang info command is ran?

My storage looks like this
Gangs:
1690731323381.png

Players:
1690731339081.png
 

Casey.

Voltix Labs
Premium
Feedback score
0
Posts
145
Reactions
39
Resources
0
Honestly, I'm not 100% but is there anyway to get some form of array functionality within SQL. I'm sure there is one way or another to do it. Then you'd simply store all of the players in an "Array" in the gang table.
 

kacperm

Premium
Feedback score
3
Posts
823
Reactions
130
Resources
1
Well, I prefer you to switch to Mongo, However not sure if it is in MySQL however what i do in mongo is I just store their UUIDS in the Gang collection it self

private String leader;
private String name;
private List<String> members;
private int kills;
private int deaths;
private boolean pvp;


example from my Clan class
 
Top