Jump to content

[SOLVED] Using a flat file for large queries.


pocobueno1388

Recommended Posts

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?

 

 

 

 

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.

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 :\

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.

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.