• CELKO (3/30/2015)


    >> I have a list of paired row IDs in a Fake_Tape_1, e.g. <<

    I hope not! Lists are not part of SQL or RDBMS. Rows are identified by a key, not a physical row_id. Putting data in a temp table is how COBOL programmers fake a scratch tape, not how to program in SQL. Camelcase does not work; the eye jumps to the upperCase letters then back to the start.

    You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. We need to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL.

    And you need to read and download the PDF for:

    https://www.simple-talk.com/books/sql-books/119-sql-code-smells/

    Here is my guess:

    CREATE TABLE Something_Pairs

    (foo_id INTEGER NOT NULL UNIQUE,

    bar_id INTEGER NOT NULL UNIQUE);

    >> I need to do an INSERT SELECT [sic: this is just an insertion statement] where I take a table, and everywhere there is a record [sic: rows are not anything like records] (1 to many) that has an foo_id, I need to create a matching record [sic] for the bar_id. <<

    Where is this 1:m relationship? What does “matching record” mean? Since the goal of any database (not just SQL) is to reduce redundancy why are you increasing it?

    If you are trying to do a translation from one encoding to another, put this in a VIEW instead of thinking in pure physical solutions to mimic mag tapes.

    I needed to quick and dirty duplicate all the data for a single company in our system so we could film some tutorials. I needed actual data, but changed names and specifics so that I wasn't exposing private information in a tutorial. Thanks for the input though.