On Sun, Jan 23, 2011 at 5:09 AM, Zaky Katalan-Ezra <[email protected]> wrote:
> Why do you need to save the paragraphs in the database at all?
> You are going to have a huge database.
> 1.If you are building a search engine consider a different design like
> saving words and the words line/position reference in each book.
> 2.Cache results for each word search or something like this.
It's not about search. The paragraphs need to be displayed individually.
I'd create a single table, books:
id
title
subtitle
author_id (if there's an authors table)
Then another table, quotes
id
book_id
chapter
paragraph_num (if necessary)
content
Assuming you're not storing *every* paragraph of each book, you could
then do a find on a particular book and have each quote included in
the data. The Quote model can be ordered by chapter and paragraph_num.
Only use a helper to do the display formatting, if at all. You could
have a method that takes as params the data, the chapter number, and
paragraph number, grabs the appropriate quote, and echoes the
marked-up content.
Just be sure to use 'recursive' so as not to fetch all quotes when
doing a find('all') on book (ie. on the index page) when you only want
to list the book titiles, and quotes are unnecessary.
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php