# Newbie question: How to represent parent-child denormalizati

**URL:** <https://www.ruby-forum.com/t/newbie-question-how-to-represent-parent-child-denormalizati/54585>\
**Category:** Rails\
**Created:** [March 9, 2006, 5:35am UTC](https://www.ruby-forum.com/t/newbie-question-how-to-represent-parent-child-denormalizati/54585 "2006-03-09T05:35:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![elegant](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/3ab097/32.png) [@elegant](https://www.ruby-forum.com/u/elegant)\
**Post date:** [March 9, 2006, 5:35am UTC](https://www.ruby-forum.com/t/newbie-question-how-to-represent-parent-child-denormalizati/54585/1 "2006-03-09T05:35:45Z")

</div>

I am building a relatively trivial application to try to learn my way  
around Rails. I am having difficulty understanding how to navigate a  
heavily denormalized hierarchy. Could someone direct me to a bare-bones  
explanation of using rails to navigate database hierarchies?

I am an experienced developer. Most of my work has been desktop client  
server, high performance, or server to server interprocess work in large  
scale systems (8K plus users).

However, I am new to Ruby and the rails environment. Furthermore, I  
have never been comfortable with html development. My idea of a perfect  
screen is plain white that is sparsely populated with black text with a  
single font and no effects. The default stylesheets that rails  
generates are quite a bit more elaborate than I would choose to  
build :o)

I am trying to build a flash-card application that contains quizzes,  
questions, possible answers, and presentations, plus historical records  
of users’s answers over time (quiz\_instances, question\_instances,  
response\_instances).

I have been working from Thomas and Hansson (Agile Web D. With  
Rails), but I appear to be missing something in the move from the famous  
“depot” example into real life. I cannot for the life of me figure out  
how to navigate from parent objects (such as a quiz) to child objects.  
I find a lot of what I generally consider “fluff” - adding pictures and  
fonts, and tweaking positions on the screen, but I am not finding how to  
build controls to navigate a hierarchy.

I could either be having issues with some web development fundamental,  
or my own misunderstanding of how Rails is supposed to work.

What I have now is a skeleton that allows me to create, edit, and  
destroy quizzes.

I have created the question controller, model, and views. However, I  
can’t seem to be able to redirect to the list of questions from the quiz  
controller. I think I understand how to nest lists once I understand  
how to navigate a hierarchy.

Since questions have no content of their own, I will also need to  
navigate to the presentation level to get the actual text for the  
question. This is a simple hierarchical structure, with the only twist  
being that a presentation (text, audio, and graphic) may be owned by  
either a quiz (preamble and postamble), a question (preamble, body,  
postamble), or a possible answer (body).

This chart may make it more clear (or not):

(quiz) 1…n (question) 1…n (possible answer) 1…n (presentation)  
(question.preamble) 1…1 (presentation)  
(question.body) 1…1 (presentation)  
(question.postamble) 1…1 (presentation)  
(quiz.preamble) 1…1 (presentation)  
(quiz.postamble) 1…1 (presentation)

At present, I have defined quiz and question. I believe that once I  
have these under control I will be able to move forward.

Thanks in advance.  
David J.

---

<div class="post-metadata">

**Author:** ![elegant](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/3ab097/32.png) [@elegant](https://www.ruby-forum.com/u/elegant)\
**Post date:** [March 9, 2006, 6:32pm UTC](https://www.ruby-forum.com/t/newbie-question-how-to-represent-parent-child-denormalizati/54585/2 "2006-03-09T18:32:29Z")

</div>

Hi David, you may want to look into the acts\_as\_tree structure

---

<div class="post-metadata">

**Author:** ![elegant](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/3ab097/32.png) [@elegant](https://www.ruby-forum.com/u/elegant)\
**Post date:** [March 10, 2006, 12:03am UTC](https://www.ruby-forum.com/t/newbie-question-how-to-represent-parent-child-denormalizati/54585/3 "2006-03-10T00:03:12Z")

</div>

I will try that as soon as I can.

Thanks!
