Does XML flat-file have disadvantages compared to MySQL database?

The data that would be contained is username, password (hashed), email, id and couple other data in one file. Another file would contain name, and huge text chunks (it’s content).

I assumed to using flat files would be easier than SQL database. Is XML faster/slower than MySQLi database, or it’s pure up to preference?

There has been some links and answers about it, but it was 7 years ago, and there are still people convoluted about it. Technology might’ve changed A LOT. But I trust SitePoint, so mind anybody share their opinion with me? Recent opinion? :smile:

I’d like to use XML flat database. Something that doesn’t go wrong on it’s own, rather than the server-side code.

Without a doubt, yes. Considerably slower. It also handles caching, large data sets, sequential reading/writing, complex data lookups, as well as a number of other things. Unless you are working with very infrequent use of very tiny data sets (rows you can count on your hands), then you should be using a DB of same sort. Even many standalone applications, like smartphone apps, use SQLite.

Okay. Kinda sucks. I really liked XML. But you’re an Advisor *some Godlike sounds with shining light*. :heart: (just kidding, I trust people from your kind :wink: ).

MySQLi that is. Are there any other free/paid alternatives that are actually known for being faster? I’m kind of tired of SQL databases (due to the language) so if they had ANY different language, I’d love to learn that.

IMHO XML is best for date transport

True, it can be used to store data but that is not it’s strength.

For example, to do a search you need to open the file, read it, parse it, then work with it’s contents.

With a database (which is also comprised of files BTW) you can put a lot of the heavy lifting on to the database.
Using a database will likely be both faster and more efficient than using XML files for data storage.

@mawburn types faster lol
As said, unless this is for a small amount of data that won’t be worked with that often, a database is the wiser choice.

As for things “going wrong” any file can be corrupted.

There’s CSV (Comma Separated Variables) files. But again, you probably want a database.

1 Like

There are a few alternatives to MySQL, but depending on what you’re working with, MySQL is probably the easiest solution as many hosts already provide support.

There are alternatives to using SQL. You could use an ORM, which will allow you to work with data in Object Oriented ways. But, I don’t know what the most popular are in PHP or where you’d get started.

I’ve worked with a few database languages Access, MySQL, SQLite, Postgres, etc.
IMHO they all have differences, but they also have a lot in common.

If it is that you are wanting to avoid using a database because you have trouble with SQL syntax, don’t be put off.
You don’t need to be an expert to get started with it.
Nothing says you need to be able to put together a complex query like @r937 can. and you can improve as you learn.
The more commonly used types of queries will likely come to you quickly

Take a read of this and it should help

1 Like

If it is that you are wanting to avoid using a database because you have trouble with SQL syntax, don’t be put off.

It’s not like I have that big of a problem with it. It’s just super-monotone :smiley:, makes me tired, it’s sucking my programming essence :smiley:.

Hundreds of thousands of websites use relational databases like MySQL.

I’d be more concerned with the idiot decision to store user data in flat files… that was stupid. Using MySQL or any other relational database for that type of data is smart.

I’m willing to bet SimpleXML or DOM Document is also being used to parse that data. Both of those do handle large XML files well since they both load the entire tree into memory. To handle large XML Documents XMLWriter and XMLReader are the only adequate solution. Those solutions can do partially reads and writes allowing for any XML file to be handled without memory issues.

I’d be more concerned with the idiot decision to store user data in flat files… that was stupid.
You’re a meanie, go away! :frowning:

I was just considering but if people say that it’s terrible idea then I’ll just go for databases.

I’m only mean because I’ve been fortunate enough to inherit code bases with these kind of stupid decisions in them. The kind of decisions made by short-sited development that end up having a significant impact on future development efforts. It isn’t that hard to just do things the right way. Honestly… and if you don’t know how to do things the right way than maybe you need to use Framework that puts you on that path.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.