Your latter idea, assigning ID numbers to people, having "number,name" in one file and "date,number(s),hours" in the other file, is definitely the way to go. This is called normalizing a database -- basically, don't store a piece of "mutable" data in more than one place.
For that matter, don't store more than one name/person-number in a single "hours" record: i.e., it should always be just "date,person_number,hours", one person mentioned per row.
As for better suggestions, try actually using a relational database (e.g. mysql), where this sort of thing is quite natural and easy. (But that's not essential -- for something on this scale, you could just as well use perl hashes to provide the same functionality without breaking a sweat.) | [reply] |
I would go with #2. In technical terms, this is referred
to as database normalization. See this blurb from devshed that explains the benefits.
I'd also recommend using a more easily updated datastore like a tied hash. That will make it easier for you to manipulate records without rewriting the whole file.
Last thought...you may want to look into some sort of
locking mechanism to handle multiple concurrent updates. | [reply] |
Why not database? This kind of flat file system is really difficult to maintain, change file format in the future would be a big hussle.
Using a database system, you would get the searching capability for free.
| [reply] |
| [reply] |
I use the members list for other pages, like the View Hours page and the Add Hours page. This keeps me from hardcoding names into the scripts.
Just Another Perl Wannabe
| [reply] |
Could you adapt the other scripts to use the records file instead of the members file? That way you'd only have to deal with one data source.
-Matt
| [reply] |
Yeah, I know, databases are the "bomb", but I don't have the funds to pay for a host that has databases. I'm working strictly with CGI on the internet, so installing mySQL or other is out of the question. I guess flat files are the only thing for me :-{...
Just Another Perl Wannabe | [reply] |
| [reply] |