Databases versus plain text

后端 未结 14 1647
我在风中等你
我在风中等你 2020-12-04 22:01

When dealing with small projects, what do you feel is the break even point for storing data in simple text files, hash tables, etc., versus using a real database? For small

相关标签:
14条回答
  • 2020-12-04 22:41

    Do you need/want SQL queries?

    Are multiple people going to want to access the data?

    Is your data relational?

    If you answered no to those questions, you (probably) don't need a full on database.

    0 讨论(0)
  • 2020-12-04 22:42

    It depends entirely on the domain-specific application needs. A lot of times direct text file/binary files access can be extremely fast, efficient, as well as providing you all the file access capabilities of your OS's file system.

    Furthermore, your programming language most likely already has a built-in module (or is easy to make one) for specific parsing.

    If what you need is many appends (INSERTS?) and sequential/few access little/no concurrency, files are the way to go.

    On the other hand, when your requirements for concurrency, non-sequential reading/writing, atomicity, atomic permissions, your data is relational by the nature etc., you will be better off with a relational or OO database.

    There is a lot that can be accomplished with SQLite3, which is extremely light (under 300kb), ACID compliant, written in C/C++, and highly ubiquitous (if it isn't already included in your programming language -for example Python-, there is surely one available). It can be useful even on db files as big as 1GB, possible more.

    If your requirements where bigger, there wouldn't even be a discussion, go for a full-blown RDBMS.

    0 讨论(0)
  • 2020-12-04 22:46

    I would only write my own on-disk format under very special circumstances. Reusing someone else's code is nearly always faster.

    For relational data, I would use SQLite. For key/value pairs, I would use BerkeleyDB (perhaps via KiokuDB). For simple objects, I would use JSON or YAML, but only if I only had a few.

    With SQLite and BDB, "a real database" is literally two lines of code away. It is hard to beat that.

    0 讨论(0)
  • 2020-12-04 22:48

    First, I'd consider:

    1. How large will the database initially be: # of tables, # of rows
    2. How quickly will it grow?
    3. Is the data frequently queried?

    If I were to create a personal recipe app, for example, I know I might add 50 favorite recipes to start and add no more than 5 recipes a year. With that being said, I could easily get by without a database since the size of the data store will have minimal impact on queries.

    That said, I would probably use a database for any application where data entry and queries occur (even a small personal recipe app). I don't think it adds a lot of overhead especially when your framework (e.g. Rails) allows you to keep your database dumb (primarily tables, indexes, and constraints). It alleviates the chance that I'll have to eventually port to a database if I decide to scale up.

    0 讨论(0)
  • 2020-12-04 22:48

    If you know the format of your data, flat files, if faster/easier to develop with, will be fine. If you expect your record formats to change frequently during development then I'd suggest that ALTER TABLE is your friend. Flat files will also tend to be faster (if you care about speed) unless you expect to implement the equivalent of joins across many combinations of files.

    The real benefit of using a RDBMS during development is the flexibility with which you can modify your data schema and the ease with which you can access your data via queries.

    Good design will ensure that you keep your data access layer relatively isolated (because of separation of concerns) so it should be a fairly straightforward (if tedious) matter to rework to a database later should it be worthwhile. Or, of course, if you use a database to develop your structures you may subsequently take the app back to flat/indexed files once those structures are crystallized in order to gain performance.

    0 讨论(0)
  • 2020-12-04 22:49

    As someone also doing research in Bioinformatics, I would suggest NOT using a database for these kinds of prototype projects unless you are sure it needs it. If you are on the fence, go with the databaseless solution and stick with flat files. It is also important to note that traditionally Bioinformatics researchers have go the flat file route, which means there are well defined file formats for most types of data in the feild. If you decide to go with a database solution, it may hurt your compatibility with existing research projects.

    0 讨论(0)
提交回复
热议问题