Reputation: 774
I'm creating a web app and I must store all data in files (instead of MySQL). And now I have few questions:
Upvotes: 2
Views: 274
Reputation: 2145
As told before... JSON ...
besides the complex data, using JSON you can use javascript (and its frameworks like jquery or extjs ) to process the data on client's side ... what in my opinion its a big goal
Upvotes: 0
Reputation: 30436
Here is the best information I have about your 3 sub questions.
1) XML files will let you leverage other tools like XSLT and XPath to search and manipulate your data. It will come at the expense of size and performance (which might not be that big of a deal if the size is manageable. XML will also give you more flexibility if you want to add new data to subsequent rows and not reprocess old data (you can achieve this with a format version number at the beginning of each row but your code could get ugly fast).
2) Stick with what works, CSV is well supported with great libraries
3) You have two limits to consider here.
Size of the file) The maximum size of a file (depends on the File System) and what implication a large file has on backing up or splitting the data later.
Quantity of the files) There is an upper limit to the number of files you can have in one folder (again depends on the file system, but there are limits)
I tend to prefer 1 file per asset. You can solve a lot of other problems more easily if you can split the data into manageable chunks. Also in agreement with Mike's answer, JSON is a much better serialization formation when you don't need XSLT or XPath like abilities. It's easy to reason-about and smaller.
Upvotes: 3
Reputation: 71414
You might consider using JSON as your serialization in the text files as it will allow you to store more complex data relationships.
That being said. If you expect your system to have any sort of load at all, reading and writing to text files will be insane to scale.
If you are restricted to only using the file system SQLite as mentioned in other comments might be your best bet.
Upvotes: 1