in reply to Flat File Database
Flat File Databases Indexed by SDBM Databases - An ISAM, NoSQL, Embedded Database System:
Follow first post in thread to find code examples: http://www.perlmonks.org/?node_id=1121222
SDBM databases of Key/Value pairs (tied to program hash tables) may be used to persistently index the fixed-length records of a "text" Flat File database for immediate random access. Historically, Flat File databases and SDBM databases have proven to be relatively weak when used alone, but when combined, the two offer a relatively strong relational database system. The binary SDBM files can store as the KEY (in the Key/Value pair), one or more fields and/or partial fields (concatenated together) contained within the Flat File, fixed-length records. The VALUE would hold the byte location offset of each record indexed, for positioning the file pointer for Read/Write operations. Edits to records are made "in place" either overwriting the existing record in its entirety, or overwriting only a single field contained within a record. Multiple Indexes (varying Key formats and their accompanying byte offset, Values) may be stored in a single SDBM file. Example: a Unique Primary Key Index which may be used is Social Security Number, and relative to that, an Alternate Key Index (with Duplicates) may be used on a combination of the fields and partial fields {BirthDate|LastNameFirst4Chars|FirstNameInitial|SeqNbr} where Sequence Number(SeqNbr) is an incremented number used to make each duplicate instance of the KEY {BirthDate, LastNameFirst4Chars, FirstNameInitial} unique. This database system would be most practical and easy to implement for Read Only, Data Warehousing and Data Marts, but with the addition of exclusively locked and released semaphore files, employed to prevent race conditions from occurring to protect the Flat File data source, a concurrent multi-user, Read/Write Database System could conceivably be implemented. A Read/Write Database System of this sort would need to have controlled access by a Front-End Database Application User-Interface which enforced a manual record locking and release strategy, and which managed the use of semaphore files.
Win32::ShareFileOpen is a module that provides C function file locking which is NON-ADVISORY LOCKING. Only the OPEN statement is different, but other than that, you use the same unbuffered I/O syntax: sysseek, sysread, syswrite.
The MLDBM::Sync module offers safe concurrent access to persistent binary external DBM (SDBM, etc.) key/value stores. I use these for indexing to FLAT FILE records. These key/value stores are tied to in-memory hash tables at run-time.
SEE Semaphore Files Perl article at: http://www.informit.com/articles/article.aspx?p=28258&seqNum=3
PARENT/CHILD one-to-many record relationships may also be managed. The Parent records would be stored in a separate Flat File from that of the Children. Example: If the Parent records are LOANS, and the Child records are the individual COLLATERAL (say motor vehicles) securing those loans, then the Unique Primary Key for the Child records could be on VIN (Vehicle Identification Number), and an Alternate Key with Duplicates could be the Loan Number of the Parent record. Added to the Loan Number (Alternate Key with Duplicates), would be a sequence number incremented for each Child collateral item added to the database for each Loan (Loan_Nbr|SeqNbr). Thus, the Children are tied back to the Parent by the Loan Number (and vice versa). You would also want to store the LOAN NBR of the parent records within each of their child records so that you maintain the ties between parent and child Flat File records in the event the binary SDBM indexing becomes corrupt and needs to be rebuilt from the Flat File data.
Redundant data typically stored in Flat File databases can also be eliminated. Now, a Part Number alone need be stored in each record of a Flat File typically containing both Part Numbers and Part Descriptions. A Look Up of a single instance of the Part Description (by Part Number) is all that is required.
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Joint Database Technology
by roboticus (Chancellor) on Jun 18, 2017 at 18:08 UTC | |
by Anonymous Monk on Jun 18, 2017 at 18:32 UTC | |
by locked_user erichansen1836 (Sexton) on Jun 21, 2017 at 14:54 UTC | |
by locked_user erichansen1836 (Sexton) on Jun 22, 2017 at 09:58 UTC | |
by hippo (Archbishop) on Jun 22, 2017 at 12:48 UTC | |
by erix (Prior) on Jun 22, 2017 at 11:02 UTC | |
|
Re^2: Joint Database Technology
by erix (Prior) on Jun 17, 2017 at 18:41 UTC | |
by Anonymous Monk on Jun 18, 2017 at 17:50 UTC | |
by erix (Prior) on Jun 19, 2017 at 04:18 UTC |