Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to store directions data in MySQL

Tags:

php

mysql

I am working on a app which requires me to store some directions for a location, below is an example of the data i'm trying to store:

Direction 1
From the WEST: Take 528 East (Beechline), pass the Airport Exit, then take exit #13 to Narcoossee Rd and turn LEFT, PARK TO FLY is located 1/4 mile on your left.

Direction 2
From the EAST: Take 528 West (Beechline), before the Airport Exit, Take exit #13 to Narcoossee Rd and turn RIGHT, PARK TO FLY is located 1/4 mile on your left.

Direction 3
From Florida Turnpike: Take Exit #254 to 528 East (Beechline), pass the Airport Exit, then take exit #13 to Narcoossee Rd and turn LEFT, PARK TO FLY is located 1/4 mile on your left.

Direction 4
From 417 (Greenway): Take Exit #26 to 528 West (Beechline), then take exit #13 to Narcoossee Rd and turn RIGHT, PARK TO FLY is located 1/4 mile on your left.

Direction 5
From 408 (East/West Expressway): Take Exit #16 to South S.R. 551 (Goldenrod Rd). Drive aprox. 4 miles, and Turn Left on Hoffner Rd. Hoffner changes to Narcoossee Rd. PARK TO FLY is located 2 miles on your right.


I was wondering if someone could tell me the best and recommended way of storing this data in MySQL.

I am thinking of first serializing the array that holds this data and then storing it into a single column, i don't think i need to worry about searching for this in the database so it should be good? i understand it won't be normalized.

But do you think storing this in a separate table would be the best for the long run?

Update

I have a mysql table named something like Locations, it has information regarding a particular location, now i want to associate some Directions with the locations that are also inputted by the user.

  • User inputs a location
  • User can then also at that time input info about directions.

UPDATE 2
I am asking about the best way to store the data in the database, currently i have no relation at the moment since i haven't created the table for it yet, that's what i am here to ask about.. Should i go and create a relational table as i described above or should i just create another column in the Locations table for the directions and serialize the array holding the directions data to be inserted into a single mysql column.

Thanks in advance!

like image 652
Zubair1 Avatar asked Nov 13 '22 07:11

Zubair1


1 Answers

If, when a user accesses each Location, you will always fetch all of the directions, then you can just stick them in the Locations table. If you ever might figure out where the user is coming FROM, and only select the right direction for that FROM, then you should stick the directions in another table.

like image 163
Aerik Avatar answered Nov 16 '22 02:11

Aerik