Search code examples
mainframeretro-computing

Database join in the '60s with tape / punch cards only?


We are a large company, selling frobnication services to tens of thousands of customers via phone calls. Orders get recorded on punch cards, featuring

  • a customer ID
  • a date
  • the dollar amount of frobnication bought.

In order to process these into monthly bills to our users, we're ready to buy computing equipment modern enough for the '60s. I presume we're going to store our user database on a tape (... since... that's where you can store a lot of data with 60s tech, right?).

Sales record punch cards are coming in unsorted. Even if the records on tape are sorted by e.g. customer ID, doing one "seek" / lookup for each punch card / customer ID coming in (to update e.g. a "sum" amount) would be very slow. Meanwhile, if you have e.g. 256k of RAM (even less?), significant parts of the data set just won't fit.

My question is: how can this database operation be done in practice? Do you sort the punch cards first & then go through the tape linearly? How do you even sort punch cards? Or do you copy all of them to a tape first? Do you need multiple batch jobs to do all of this? How much of this is code we'll have to write vs. something that's coming with the OS?

(... yes I've heard about those fridge-size devices with spinning metal disks that can randomly seek many times a second; I don't think we'll be able to afford those.)


Solution

  • In the 60's you would most likely

    • You store your data in a Master-File sorted in Key sequence
    • Sort the Punch-Cards to a temporary Disk file.
    • Do a Master-File Update using the Temporary Disk file (transaction File) and the master file.

    They might of used a Indexed-file or some Database (e.g. IMS) if online access is required.

    Master File Update

    For a Master File update both files need to be sorted in to the same sequence and you match on keys, it writes an updated master file using the details from the two. It Basically like a SQL Outer join.

    Logic

    Read Master-File
    Read Transaction-file
    
    While not eof-master-file and not eof-Transaction-file
       if Transaction-file-key < Master-File-key
          Write transaction-file details into updated-master-file
          Read Transaction-file
       else_if Transaction-file-key == Master-File-key
          update Master-File-Record with Transaction-file-details
          Write updated-master-file-record to updated-master-file
          Read Transaction-file
       else
          Write master-file-record to updated-master-file
          Read Master-File
       end_if
    end_while
    
    Process Remaining Transaction-file records
    Process Remaining Master-file records