Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Perl DBI and Foreign Keys

by Marshall (Canon)
on Apr 08, 2019 at 07:24 UTC ( [id://1232270]=note: print w/replies, xml ) Need Help??


in reply to Re: Perl DBI and Foreign Keys
in thread Perl DBI and Foreign Keys

Yes, of course that occured to me.
{write ScoreCard, readback ScoreCard for that Url to get the unique id, write Participants, write Participants, write Participants, etc.}

So what happens if I don't have a unique field like Url?
In this case, I ScoreCard table did and I of course I used it to allow the tables to be joined.
My application works...but, I am curious how to do this better and in other circumstances.

Update: Perhaps think about it this way..I have a piece of paper A. It is like any other piece of paper that I have except that this particular piece of paper is associated with the finger prints from people X,Y,Z. I have other pieces of paper with other fingerprints. In this case the only thing that is unique about this piece of paper is that is a thing from a crime scene (will get evidence label of #1, #2,etc) on the bag. I asked this question to some Oracle gurus and there is a way to do this, but it is not standard SQL.

Replies are listed 'Best First'.
Re^3: Perl DBI and Foreign Keys
by hdb (Monsignor) on Apr 08, 2019 at 07:51 UTC

    Well, there must be some piece of information that is the same in both tables. Otherwise, why would you even think about linking those tables? If not you need to create such a link, say a time stamp or a case number.

    If you have such a piece of information, you could put it in a third table, with AUTOINCREMENT index, and then use that index in both tables with the data.

      I'm not sure if you saw my update with a "piece of paper" from a crime scene analogy?

      I used the Url as the link between tables because it was easily available and guaranteed unique.
      So why have 2 tables?
      Answer: I didn't want to set or declare a maximum number of columns in the main ScoreCard table.
      Each entry in the ScoreCard table can have an unlimited number of Participants.
      Why use integer id instead of Url?
      Answer: because it would save space. I didn't do it or need to do it in this case.
      Could a situation arise where a human shouldn't be required to enter a unique field for a row and where number of columns is not fixed?
      Answer:Absolutely.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1232270]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-16 19:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found