Answer the question
In order to leave comments, you need to log in
Will it be correct if the coordinates are the primary key?
I want to store locations in the database, I came to the decision that it would be most normal to store longitude, latitude to identify a specific location (decimal field types). Is it normal if these two fields are a composite primary key (according to the performance in the sample on large volumes), or is it pointless, and should we go somehow differently?
Answer the question
In order to leave comments, you need to log in
If in doubt, make a surrogate key. Another question to check, will the location longitude, latitude always be constant or is it likely that they will need to be edited a bit?
I don't see much point.
Since, in most cases, it is not necessary to index longitude, latitude
. For example, there is a product, the product has a location.
How do you bind?
Two fields longitude, latitude
?
Create a foreign key and don't fool yourself.
By the way, let me give you an example.
Offhand, this immediately subscribes you to some additional hemorrhoids in the code without any significant gain.
Imho it is correct to do the usual auto-increment + if your business logic requires it, hang up a composite unique key for latitude-longitude.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question