Reputation: 3591
I have an App based around Events and Branches. I have two events ones with Branches and ones Without.
Both Events and Branches have a latitude and longitude.
An Event can have Multiple Branches. I want to sort these Events by Distance from another geo-coordinate.
For the Events with Branches it should use the location of its branches to work out how close it is and for the Events without it should use the location of the event itself.
Is this possible to do in MySQL without a performance hit ? Or am I using the wrong kind of Database ? Should I use another NOSQL database with a script to export the current MySQL and Pods data to it.
This is the basic query I'm using ATM with this Framework which adds a small bit of sugar (Obviously this wouldn't work in plain MySQL), Events without Branches don't seem to appear in the correct order.
SELECT
t.*,
DISTANCE(\"$latitude\", \"$longitude\",
IF(t.branches.latitude, t.branches.latitude, t.latitude),
IF(t.branches.longitude, t.branches.longitude, t.longitude)
) as distance
FROM table as t
ORDER BY distance.
Upvotes: 0
Views: 169
Reputation: 505
if there is any sort of relationship between entities, you want SQL to reduce the overhead of managing these relationships. (businesss logic, select name where event = something)
if you want to use a database for plain storage, and do all the business logic and relationship management on your server side language(php, ruby, c# whatever it is), then NOSQL is better.
Upvotes: 2