I am new to programming and am learning ruby as my first language. I
want to use a database to keep track of client information in a program
I am working on. I considered just using text files and folders to keep
track of data, but this creates an ugly solution. I need to balance
having a nice program with security though, and I think adding database
software is going to increase complexity and thus inherently decrease
the over all security of the finished program. I have thought of a
potential way to have both minimal complexity and nice organization of
data.
For example lets say I have a multi user program that needs to keep
track of each users contact list, amongst other things. Is there
anything wrong with making a hash for user data, and keying it with
things like
database = {}
database.store(user + “_contact”, contact)
and then when it is time to get the users contact list, I will search
the hash with a regular expression looking for the current users chunk
of _contact entries, and then return each of them to get the full list
of contacts. But I will have multiple sorts of information stored in one
hash, that I will also write to the disk and load from disk into a hash
when the program is running (or maybe when it is time to use it only?).
I think this sort of database structure will be much less complex than
trying to use something like MySQL, and since I already use ruby hashes
in other parts of the program it really isn’t even adding any more
complexity (and potential for things to go wrong) than I already had
before. I think my entire hash will never get over 100,000 entries, and
that is being generous in itself.
Hm one issue I just noticed is the problem of only being able to map one
key to one value, where as I will need to do multiple in some cases
(although not contacts). Maybe I can put array inside the hash?
Anyway I just want to know if I am going about this in the right way,
for a secure , simple, not complex database with Ruby, or should I go
with something else? Any suggestions?