What is the best method for saving datas

Discussion in 'Spigot Plugin Development' started by dunklesToast, May 13, 2015.

  1. Hey,

    I want to make a money system and I can't decide whether to save the money datas.

    What is better?
    - file
    - mysql

    I'm for the file because it's only for one Server and with a file I can easily change the money.

    What is your opinion?
    (I would like to add a poll but I am on my mobile with tapatalk. Sorry)
     
  2. If you anticipate that there will be many entries, sql is a better solution. Using a file will get out of hand quickly.
     
    • Agree Agree x 1
  3. If the MySQL db is on the local machine than both are actually the same. The MySQL db has to store the data somewhere and that somewhere is a bunch of files. Of course it has a lot of optimizations built in but it is in essence a glorified file storage system. If you are doing a lot of db lookups then i would say yes go with the sql. If you want this compatible over a few different servers save yourself some trouble and again go with sql. If you are loading player data on join and saving on leave consider a file base. Take the opertunity to experiment. Gson is an easy to use json parser that you could try out. Maybe see what you can do with a randomaccessfile. Just please do use the yml parser for player data :p best of luck!
     
  4. A MySQL database can be faster or slower depending on where you are hosting the database. If it's on the same system as the server, well you've got pretty much the same effect as file saving. If it's hosted elsewhere you might experience slower read/write rates. But a MySQL does come with a lot of options. If you are looking at distributing your plugin, then I'd suggest MySQL since most servers prefer to store via MySQL and reduce their server storage, but file storage is pretty good if the data is barely going to amount to a few kB's. For a more commercial aspect, I'd suggest giving multiple options. As in, enable both file storage and MySQL storage in your plugin. This would give the user an option to choose whichever suits him or her best. And if you've written a MySQL code once, it's pretty easy to standardize. But again, choosing appropriate storage comes down to the amount of data you need stored. Choose wisely.
     
  5. Personally i think MySQL or MongoDB are the best ways to store credential data due to the fact, if your server is a standalone server, if you ever think about going bungeecord this wouldn't be a problem with MySQL.
    The only let down is the time it can take to connect to the database..
    Although even this isnt that big of a problem as you could save all the players data within the code once connected.

    Hope this helped :)
     
  6. Once the server is running, in many cases, you won't want to edit the files by hand anyway. You will have commands to add currency where needed. On my project, we are using a combination of both, based on what we need.

    MySQL is great for information storage - money, player progress, server stats. Generally anything that has set structure and will have many entries of the same kind.

    File has the benefit of being writeable by hand and easily modifiable by multiple members of staff. It may also be useful when the data structure is significantly different between entries. For us, it makes a nice solution for custom items, setting up information for world zones, custom music settings, etc.

    Compare the benefits and see what makes sense for what you need. If you simply want to store and trade currency, then MySQL may be a nice solution.
     
    • Like Like x 1
  7. You could of course use an SQL editor like SQL Workbench ;)
     
  8. Answer is very simple. MySQL for more organized storage but you need to know how to use it well. Or File storage if you want messy and unorganized but easy to code storage.
     
  9. That is a good point. I am using SQL editor myself. It is a great option for those who understand how databases and servers work.

    In reality, those on my team who usually want to define new items, are often not the developers, but lore writers. A file storage system has the benefit of being really accessible by anyone, regardless of their knowledge of databases or servers. They can simply take an example item file and send back their new files, with no need of installing anything or having to get into SQL syntax. In those cases, file storage is very useful (and also quick, as everything gets loaded once on the server startup).

    This may not be a useful example to the OP, as he is likely only interested in a static currency system that stores straight forward information. If you simply want to edit numbers and store data, SQL is a good option.
     
    • Like Like x 1
  10. SQL is great for storing data across multiple servers (like a Bungee Network) or one server if you have a lot of players. YAML is a little faster connecting(technically), and is probably better for a smaller single server.
     
  11. Nooo yml is such a slow parser. It looks nice but isnt for large data storage. You may think its faster because you arent connecting to a different machine but if the sql server is hosted locally than it beats yml everytime.
     
  12. Hense the "technically" and I said its for small servers, not large. Read my post before replying please.
     
  13. I did and I have the same response. If the sql server is hosted locally... as in on the same machine... as in the same damn place the yml files would be, it is going to be much faster. There is no need to ever use yaml for data storage.
     
  14. MySQL = On local, fast, not local, slower than YAML. MySQL = Great for networks or servers with large amounts of players. YAML = Great for small servers because of it's simplicity.
     
  15. You cant compare them like that... obviously if one has to travel from one machine to the next its going to be slower. But you cant say that you have to use mysql over multiple machines!!! If you are going to compare two methods you have to keep the external factors the same. Dont sit here and say that yaml is faster than sql... it isnt and there is no way you can spin it to make it true.
     
  16. look at Essentials..its default flat file is fine with regards to the performance. use flat file with java.nio.
     
  17. @MrBlobman @BetaNyan You both have valid arguments about different topics. AS much as I'd like to listen out to see who wins, the original poster doesn't need to see you both argue. He has mentioned what the plugin is for (A currency / economy type plugin). You should either give the pros and cons of both data storage options and let him choose or suggest one and say why. Please refrain from making OPs read through personal arguments.
     
  18. @MrBlobman on a single server, MySQL is slower than yaml when it comes to player-based load/save. You probably need multiple servers to actually find use for a database.
     
  19. I never said YAML is the faster than MySQL. I said in some cases it can be, in some cases not. I've said in basically all my posts, how many times do I need to say it?
     
  20. To note: File saving is not faster than using a database, especially when scaled. DBMS systems are (quite literally) designed for one specific goal in mind: storing and accessing data.

    Different DBMS solutions can have differing speeds, and lack of optimization/indexing/relational mapping (for RDBMS) will slow down your database. Configured correctly you won't have those problems.