Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Update XML Values using two primary keys

by jcb (Parson)
on Jan 06, 2021 at 03:24 UTC ( [id://11126408]=note: print w/replies, xml ) Need Help??


in reply to Update XML Values using two primary keys

Other monks have given you help towards a solution, but I noticed a misunderstanding that will not help you: you do not have two primary keys, you have one primary key that happens to be a 2-tuple of (lat, lon) values. While you will have to match it piecewise, it is conceptually a single datum.

  • Comment on Re: Update XML Values using two primary keys

Replies are listed 'Best First'.
Re^2: Update XML Values using two primary keys
by GrandFather (Saint) on Jan 06, 2021 at 03:38 UTC

    In the context of database like storage they are indeed two primary keys even though they represent one point. That single point may be associated with multiple entries in the "database" even if it is a single point (assuming of course it represents a point on a two dimensional substantially unfolded surface).

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

      They could both be keys but I don't see how they could both be primary unless combined into a single primary key as jcb suggested. Do you happen to use or know of a database that supports multiple primary keys on the same table?


      🦛

        Logically, the primary key here is a "geographic point" type, but SQL does allow a primary key to be declared as an arbitrary tuple of multiple columns in the same table. The PRIMARY KEY constraint must be written as a table constraint instead of a column constraint to do this.

        For our questioner's example, and assuming a database that does not directly support lat/long coordinates (i.e. not Postgres with PostGIS installed), there could be a table like: (untested)

        CREATE TABLE tags ( lat numeric(24,20), lon numeric(24,20), name text, PRIMARY KEY(lat, lon));
Re^2: Update XML Values using two primary keys
by pratikpooja (Novice) on Jan 06, 2021 at 15:41 UTC
    Thank you for the Information. Since I am new to Perl so I don't know whether the tuple datatype can be used but anyways thank you.

      There is no explicit tuple data type in Perl; you will need to either track both pieces in separate variables or use an array, but note that there are no builtin operators for comparing arrays elementwise: == on arrays compares their lengths (because it imposes scalar context on its operands) and == on array references checks for object identity (true if both references refer to the same object).

      However, while the 2-tuple nature of your primary key will not be directly reflected in your program, properly understanding it will help you to maintain clear thinking and accurate reasoning about your code.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-25 08:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found