pocobueno1388 Posted July 14, 2007 Share Posted July 14, 2007 I have 13 rows of information, and instead of storing that little amount of data in the database, I figured I should save some storage and put the information in a flat file instead. Lets say my flat file looks like this: Account type (int) | amount (int)| more info Account type (int) | amount (int)| more info Account type (int) | amount (int)| more info Lets say my database table looks like this and there are about 5,000 rows. UserID Account_type Would it be insane to loop through the flat file for each individual DB entry and find the matching "account type" for that individual user, then add the "amount" field to a row in the DB according to what account type they have? Or would this be a lot easier if I just stored the flat file information in a table in the database? Link to comment https://forums.phpfreaks.com/topic/59896-solved-using-a-flat-file-for-large-queries/ Share on other sites More sharing options...
pocobueno1388 Posted July 14, 2007 Author Share Posted July 14, 2007 I've been thinking about it, and I am leaning more towards the flat file. It would be nice to get some second opinions though Link to comment https://forums.phpfreaks.com/topic/59896-solved-using-a-flat-file-for-large-queries/#findComment-297896 Share on other sites More sharing options...
infid3l Posted July 14, 2007 Share Posted July 14, 2007 I've been thinking about it, and I am leaning more towards the flat file. It would be nice to get some second opinions though You'll thank yourself later if you use a database. It's far more secure and way more efficient. Link to comment https://forums.phpfreaks.com/topic/59896-solved-using-a-flat-file-for-large-queries/#findComment-297898 Share on other sites More sharing options...
pocobueno1388 Posted July 14, 2007 Author Share Posted July 14, 2007 How is it more secure? It doesn't matter to me if the data in the flat file can be looked at, it really doesn't matter. If you are talking about it being insecure as people can hack into the file and change it, then that would probably convince me to go to a database. So please elaborate on the security issues you are talking about. I can understand the database being more efficient, and a lot easier to handle...but if a flat file will work for me, I would much rather use that. Link to comment https://forums.phpfreaks.com/topic/59896-solved-using-a-flat-file-for-large-queries/#findComment-297903 Share on other sites More sharing options...
infid3l Posted July 14, 2007 Share Posted July 14, 2007 How is it more secure? It doesn't matter to me if the data in the flat file can be looked at, it really doesn't matter. If you are talking about it being insecure as people can hack into the file and change it, then that would probably convince me to go to a database. So please elaborate on the security issues you are talking about. I can understand the database being more efficient, and a lot easier to handle...but if a flat file will work for me, I would much rather use that. I meant it could be easier to view via inclusion or something. And to be honest, just go ahead and make a flat file, query it, then try it with a database. I don't see why you wouldn't use a database, MySQL databases are easy enough to query through php :\ Link to comment https://forums.phpfreaks.com/topic/59896-solved-using-a-flat-file-for-large-queries/#findComment-297906 Share on other sites More sharing options...
pocobueno1388 Posted July 14, 2007 Author Share Posted July 14, 2007 Maybe I'm just paranoid that my database will get too full, so I am trying to keep as much information in other places as I can. Maybe I am being to cautious, this table would be so small it probably wouldn't even make a scratch on the DB. Well, let me get a couple more opinions before I make the final decision to use the DB. Thanks for your input. Link to comment https://forums.phpfreaks.com/topic/59896-solved-using-a-flat-file-for-large-queries/#findComment-297908 Share on other sites More sharing options...
Barand Posted July 14, 2007 Share Posted July 14, 2007 To process with a flat file for each of 5000 records get record get its type and lookup amount to be added update record to add the amount That's 10000 trips between php and mysql OR, you could put your flatfile data in a table (or a temporary table) then use a single query UPDATE user u INNER JOIN type_amount t ON u.account_type = t.account_type SET u.account_value = u.account_value + t.amount; Intermediate approach requiring 13 queries for each flat file record get type and amount update adding amount where account_type = flatfile type Link to comment https://forums.phpfreaks.com/topic/59896-solved-using-a-flat-file-for-large-queries/#findComment-298023 Share on other sites More sharing options...
pocobueno1388 Posted July 14, 2007 Author Share Posted July 14, 2007 Thanks Barand. for each flat file record get type and amount update adding amount where account_type = flatfile type That was my initial idea, but I think I will just go with the database. Thanks. Link to comment https://forums.phpfreaks.com/topic/59896-solved-using-a-flat-file-for-large-queries/#findComment-298145 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.