Hello Richard,

Yes, this is how AD also approached the solution. I think i would
investigate the performance of the solutions being posted by AD and
Shiono(the solution of maintaning a seperate table of links for the valid
images).

@AD:
This is not about knowing/not knowing MySQL. its about how databases
operate. I always prefer searching by a primary key because only in that
case database performs O(1) search. In case you search by some other keys,
then B+ Trees come into picture and may hit performance which i want to
avoid.

Any ways thanks for all the thoughts. For now i will change the subject of
the query to resolved.

Thanks.


On 1/27/08, RichardAtHome <[EMAIL PROTECTED]> wrote:
>
>
> How do you determine if an image is invalid?
>
> You may be able to apply this criteria to your SELECT statement
> without any additional fields.
>
> On Jan 27, 2:50 pm, Takuo SHIONO <[EMAIL PROTECTED]> wrote:
> > Hello,
> >
> > If you do not want to keep unnecessary fields for almost 50% of images,
> > you can use image_link table, which contains 3 fields(image_id, next_id,
> > previous_id). You maintain this table in afterSave function only when
> > you edit or add valid images.
> >
> > You can define the HASONE relationship between image model and
> > image_link model. I think this makes your code smart like below:
> >
> > // Controller
> > $image = $this->Image->findById($id);
> > $this->set('image', $image);
> >
> > // View
> > <?php echo $html->link('next', '/images/view/'.
> > $image['ImageLink']['next_index']); ?>
> >
> > Best Wishes,
> >
> > Takuo Shiono
> >
> > Novice Programmer wrote:
> > > Hello Shiono,
> >
> > > When i tried to add the two fields, it seemed like an overhead to me
> because
> > > almost 50% of the images would be invalid, so adding two fields to
> database
> > > design will lead to addition of these fields in these invalid images
> as well
> > > and hence occupy more space in database. I want to avoid that if
> possible.
> >
> > > Thanks.
> >
> > > On 1/27/08, Takuo SHIONO <[EMAIL PROTECTED]> wrote:
> >
> > >> Hello,
> >
> > >> I often use solution 1. I think this solution can be applied in
> almost
> > >> all cases. However I have another solution. How about this:
> >
> > >> 1. add 2 fields (prev_valid_index and next_valid_index) in table.
> > >> 2. update these fields in afterSave function.
> > >> 3. show image with the next/previous link according to the fields.
> >
> > >> Best Wishes,
> >
> > >> Takuo Shiono
> >
> > >> Novice Programmer wrote:
> > >>> Though this is less of a database question. but i am still posting
> it
> > >> here
> > >>> since I think we can discuss the design as well.. :).
> >
> > >>> I am maintaining a adresses of images stored on my filesystem in a
> > >> database.
> > >>> I have designed a system to show those images to the user. This
> > >> interface
> > >>> has the next and previous button as well. When user clicks on next
> he
> > >> goes
> > >>> to the *next valid image*. Note the difference here. I have to show
> only
> > >>> valid images. This means that all the images in the database are not
> to
> > >> be
> > >>> shown. Lets consider an example. Say that my database consists of
> > >> following
> > >>> images:
> >
> > >>> 1. Image1(Valid)
> > >>> 2. Image2(InValid)
> > >>> 3 Image3(Invalid)
> > >>> 4. Image4(Valid)
> >
> > >>> so when user is viewing image 1 and clicks on next he goes to image4
> > >>> directly even though image2 is stored in the next index on the
> database.
> > >> I
> > >>> have thought of following solutions but none of them are appealing
> me:
> >
> > >>> 1. Maintain a variable which tells the index of next valid image.
> > >> Maintain a
> > >>> variable which tells me the index of last valid image and when next
> > >> valid
> > >>> image comes, update the index of the last valid image with this new
> > >> image.
> > >>> Similarly maintain the previous variable.
> > >>> 2. I am storing time stamp along with the images. On clicking next,
> I
> > >> load
> > >>> the image having the most recent time stamp after this image. but
> still
> > >> I
> > >>> dont like this query as this may be slow.
> >
> > >>> Please help.
> >
>


-- 
Thanks & Regards,
Novice (http://ishuonweb.wordpress.com/).

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to