Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML vs JSON vs SQLite for only reading data

Tags:

java

android

I have a collection of 350 locations in the United States with each containing about 25 subcategories. The data structure looks something like this:

Location (ex: Albany, NY)
    --> Things to do
    --> Population
    ... 23 More

Which of the following would be best for loading this data into the app: JSON, XML, or SQLite? Just to clarify, I don't need to edit this data in any way. I simply need to read it so that the information can be loaded into TextView's.

Edit:

I'm attempting to implement Room and XML and so far the XML seems to be the simplest to implement. Is it bad practice to use the XML solution? It doesn't seem to be using too many resources and it isn't running slow at all when tested on a few devices. Would it still be a better practice to implement the Room solution?

like image 907
Brandon Cornelio Avatar asked Nov 18 '18 17:11

Brandon Cornelio


People also ask

Is XML more readable than JSON?

Dating back to 2001, JSON (JavaScript Object Notation) has emerged as a rival to XML. Although it is supported inside JavaScript, JSON is language-independent. Compared to XML, it's much shorter and easier to read.

Is XML or JSON easier to parse?

XML is much more difficult to parse than JSON. JSON is parsed into a ready-to-use JavaScript object.

When should I use XML over JSON?

Simply put, XML's purpose is a document markup. Always prefer to use XML, whenever document markup and meta-data are an essential part of data and cannot be taken away. JSON's purpose is structured data interchange. It serves this purpose by directly representing objects, arrays, numbers, strings, and booleans.

Is SQLite good for data analysis?

Although database systems all have the same basic functionality, those designed for OLTP are less good at OLAP applications and vice versa due to the way data is stored — in a way that easier to access columns or one that easier to access rows. So SQLite is good for OLTP and DuckDB is better for OLAP.


1 Answers

Undoubtedly, among all of these RDB is the most efficient one, both in terms of storage and query response. I personally do not see any point in using xml and json as these have been traditionally used for exchange of data and are inefficient for storage and queries.

I would suggest that you evaluate the following:

a) how are you going to store the data: single file vs multiple files(for example by subject)

b) are you going to be doing updates on the strings or just appending(SQL will be better suited for updates but if it just reading data after a batch processing flat files might be better suited)

c) How complex are the queries that you want to implement.XML and SQL are better suited for queries that might try to address metadata (date stored, original location address, etc.) than JSON

Once you determine what you want to optimize: whether it is on adding metadata, fast updates, fast querying, ease of storage, fast retrieval of subject files, etc. then you can decide the tradeoffs with other less important goals. In this specific instance the devil is very much in the details.

like image 91
Saddam Avatar answered Oct 19 '22 13:10

Saddam