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
| [reply] |
| [reply] |
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));
| [reply] [d/l] [select] |
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. | [reply] |
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.
| [reply] [d/l] [select] |