I agree (responses within email).

Jim Flannery wrote:
Tuesday, May 30, 2006, 5:59:09 PM, one spoke:

AD> Agreed.  I would be very interested in hearing the advantages of
AD> converting a query to an array of structs given you can access
AD> rows and columns from a query "natively".

Well, if your child tables have child tables, or if there are multiple
child tables, it can help a lot to have the actual hierarchy parceled
out once.

e.g. my never-ending bugbear, the quiz: a quiz is a bit of metadata,
with a collection of questions hanging off of it, each question with a
collection of answers hanging off of it ... (I won't even get into
userresponse and userselection records here :^>).

Grabbing the third option to the fifth question is pretty
straightforward in a struct of structs; it's a PITA in a recordset.
I was thinking that a "list of child data" should be stored in the simplest form (ie a query) - as it will be used primarily for display purposes. I do not remember having to have direct access to discrete elements within "lists of" child data. (And wholeheartedly agree it would be a PITA using a query). As soon as I need to deal with an individual child's data, the user is directing me to the appropriate child, and I can grab that record (and all the information I need) to do the processing required.

I have <entity>list and <entity> "classes" for the purpose of <entity> representation.

And if I'm in authoring mode, what would I be doing, using
QuerySetCell() and QueryAddRow() etc.? If I added three Q/A sets in a
session, how would I be able to go back and revise them before I
roundtripped to the db to get new primary keys for them?
I guess in your case you couldn't. I wrote a quiz development tool and quizzes were developed one question at a time, with multiple choice answers supplied as individual lines in a memo. When the user wanted to [save] the question, or [add another] they did so, and I dealt with the question and its associated answer list then, as a discrete question entity and possible multiple choices, save to DB, etc.

I did not have to deal with the complete list of [questions -- answers] until they were displayed in quiz form.

When a user did the quiz, their answers were processed via form fields - so the collection [quiz -- question -- answers -- userresponse] was contained within the form scope and processed accordingly. When redisplaying the quizz, its questions, answers and the user's responses, I did not need direct access to individual elements, so the query approach worked fine (cfoutput group etc).
The question (and mine too), is whether those collections are arrays
of objects, or structs of objects, or arrays of structs, or structs of
structs, when they get populated, how they get populated, where the
save() methods go, what object knows the sequence (i.e. what object
does the controller talk to when the author decides to move a question
from #4 to #8) -- the quiz object has the whole collection but the
_seq column's in the question record in the db ...). etc. etc.  (Can
you tell how many times I've refactored this app in the last three
years?)
The original question  I answered :
["I have a one to many relationship between two tables, or objects. I assume I should somehow store the many in the bean of the one.
What is your preferred way of handling this?"]

is a little different to the question posed here:
1. MVC - specific framework implementation (persist 3 Q/A before saving to DB)
2. 1 :: many :: many :: many data structure vs 1 :: many

I cannot speak to the framework you are using, but it sounds like you are persisting records before comitting to database, which would definitely be easier with a non-query approach.

Having had more time to think about this, I would change my statement to say something along the lines of "if you do not need direct access to individual elements, leave it as a query". This, however, sounds too bleedingly obvious to bother with writing. Perhaps I should have asked "it's a list, do you need direct access to discrete elements within that list?". I have never retrieved list(s) of child data for the purposes of discrete child data access, always prefering to retrieve an individual child for such purposes. Hence my lack of understanding as to why you would retrieve a list and then ask for an individual (ie need to munge that query into an array of structs, etc). I think the answer to that question is "because my framework demands it", in which case queries would probably be inefficient.

Hope that made sense
Aaron


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to 
[email protected] with the words 'unsubscribe cfcdev' as the subject of the 
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting 
(www.cfxhosting.com).

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]


Reply via email to