in reply to access array of values without a loop

It is perfectly possible to insert this into a database, provided the database structure allows "one-to-many" relationships. You will need at least two tables for this to work: one to hold the key and individual data for this key and another table to hold the repeated data.

A typical example would be: one table to hold the ISDN code (key) and title of a book and another table to hold a sequence number, the ISDN code and the name of the authors (one author per record). Thus it is easy to accommodate multiple authors for one book.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics
  • Comment on Re: access array of values without a loop

Replies are listed 'Best First'.
Re^2: access array of values without a loop
by sundialsvc4 (Abbot) on Feb 20, 2015 at 00:52 UTC

    I suspect you hit the central problem square on the head.   And, just for completeness:   you can also represent many-to-many relationships in an SQL database ... this requires three tables.   For example:
    INVOICE <-> INVOICE_LINEITEMS <-> ITEMS.

      Yes and that is even the better solution in case (returning to my example) one has authors which have authored multiple books.

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      My blog: Imperial Deltronics

        You probably know this but I want to clarify for other readers. Many to many works, and is a more flexible idea, but only necessarily applies when a book has more than one author (and an author has more than one book of course). One author has many books v many books have many authors.