Friday, September 25, 2009

Database structure and json_encode()

I am creating an itinerary system where user will be able to record
his trips, add one starting point where his journey begins, unknown
number of stops on his way and finally one ending point. Now I am
wondering how to create a meaningful database structure so one will be
able to search every group of points: starting, trip stops and ending
point.

I am unsure how to model my database but I have two ideas I cannot
decide between:

A)
Table TRIPS which will contain columns:
start (one starting point)
via (x trip stops)
end (one ending point)

OR

B) (my preferred one) - one only column:
waypoints

My idea is to serialize array containing all trip points using
json_encode() and save it into "waypoints" column in json format,
because I have read it is quite faster than serialize() and I would be
able to use it in my jquery scripts. What bothers me though is how can
I search in those waypoints then? They will be mixed together - start,
stops and end.

What idea do you like most? Thanks for your comments guys.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: