Re: Database optimisation (all comments in one table)
Interesting topic Luigi7up. I achieved exactly this in a very simple way with AD7six' Polymorphic behavior: http://bakery.cakephp.org/articles/view/polymorphic-behavior I successfully use it for tagging many models in my app and for geolocalization. In the first case, I can tag different models and create a common tag cloud for them all. Regarding geolocalization, it's pure magic to be able to associate users, videos, news, companies and whatever to geographic coordinates with almost a oneliner. I'm excited about trying rating and commenting too with polymorphic behaviors. Has anybody went further? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Database optimisation (all comments in one table)
Thank you all for reply... I'll organise all comments on articles model in one table because they will be all the same (BLOG, NEWS etc.) but keep others in seperate table. For what is worth, during college I had subject Databases and Program egineering. My database will be in 3NF in both cases but there is a rule in Program engeneering that says: Group all classes/objects that are same. In other words if you have class ORDER and GUEST_ORDER you should group them because they have same attributes. So, what I relized from this discussion is following: Both approaches are good if you know when to use them :) thanks everyoune On Sep 6, 5:49 pm, villas <[EMAIL PROTECTED]> wrote: > Teknoid and Crazy are right about the poor normalisation. > > However, I successfully used the idea once because it was necessary > for me to process all the 'comments' for 5 different models in > datetime order. If I had to go and get the comments from 5 different > tables before I could process them, it would have been a bigger > problem; so, I suppose it depends on what you are doing. However, in > this case, maybe going against the standard normalisation advice > wouldn't be such a good idea if there wasn't a good reason for it. > > If however, luigi7up still wishes to think about his idea, I notice > that Martin Westin's approach for linking addresses to different > models was a little similar in concept and that thread might be worth > a read:http://groups.google.com/group/cake-php/msg/75e6eb68be6b301a?hl=en > > For simply reducing the number of tables, luigi7up could of course > also consider the possibility of having a combined table, for example, > for News and Blog items. He could perhaps call it Articles and > specify whether the article is a News or Blog item with a simple > flag. He would then of course only require one Comments table too. > Of course he wouldn't be doing that if the fields are significantly > different, but I have noticed that some CMS systems successfully > simplify their schemas by combining their content types into as few > tables as possible. > > Best regards. > > On Sep 6, 3:48 pm, teknoid <[EMAIL PROTECTED]> wrote: > > > I see little benefit to this solution, having everything in one table > > is not necessarily a good thing. > > > There are a few drawbacks to this solution... > > > - Relying on two fields in order to establish an association > > - Lack of flexibility. What happens when you decide that Blog comments > > need to have additional fields? > > - Poor normalization > > - Possibly meaningless fields for certain records (i.e. > > blog_comment_vote) for Image comment (which does not require any > > votes) > > > On Sep 6, 5:43 am, luigi7up <[EMAIL PROTECTED]> wrote: > > > > hola everyone, > > > > while developing application something crossed my mind. What about > > > organizing all comments throughout application in one database table. > > > > What I mean is this: > > > > If application has some kind of Blog, News, picture gallery you woul > > > create blog_comments table, news_comments table etc. > > > What about table creating one table that would hold all comments ?!? > > > Table comments would have following fields (id, model_name, item_id, > > > author, text) > > > > This table would get pretty huge very soon but there is some logic in > > > this approach :) > > > > What do you think? > > > > thanks > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Database optimisation (all comments in one table)
On Sep 6, 4:48 pm, teknoid <[EMAIL PROTECTED]> wrote: > I see little benefit to this solution, having everything in one table > is not necessarily a good thing. > > There are a few drawbacks to this solution... > > - Relying on two fields in order to establish an association > - Lack of flexibility. What happens when you decide that Blog comments > need to have additional fields? > - Poor normalization > - Possibly meaningless fields for certain records (i.e. > blog_comment_vote) for Image comment (which does not require any > votes) FWIW I disagree. A comment is a comment a vote is something else. if a system has comments on several different objects and their structure is the same (title, user_id, body) it makes no sense to me to have duplicate tables. If their structure is not the same it probably means the name of the model doesn't depict what it is (like trying to merge ratings and comments ans still calling it "comment"). AD --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Database optimisation (all comments in one table)
Teknoid and Crazy are right about the poor normalisation. However, I successfully used the idea once because it was necessary for me to process all the 'comments' for 5 different models in datetime order. If I had to go and get the comments from 5 different tables before I could process them, it would have been a bigger problem; so, I suppose it depends on what you are doing. However, in this case, maybe going against the standard normalisation advice wouldn't be such a good idea if there wasn't a good reason for it. If however, luigi7up still wishes to think about his idea, I notice that Martin Westin's approach for linking addresses to different models was a little similar in concept and that thread might be worth a read: http://groups.google.com/group/cake-php/msg/75e6eb68be6b301a?hl=en For simply reducing the number of tables, luigi7up could of course also consider the possibility of having a combined table, for example, for News and Blog items. He could perhaps call it Articles and specify whether the article is a News or Blog item with a simple flag. He would then of course only require one Comments table too. Of course he wouldn't be doing that if the fields are significantly different, but I have noticed that some CMS systems successfully simplify their schemas by combining their content types into as few tables as possible. Best regards. On Sep 6, 3:48 pm, teknoid <[EMAIL PROTECTED]> wrote: > I see little benefit to this solution, having everything in one table > is not necessarily a good thing. > > There are a few drawbacks to this solution... > > - Relying on two fields in order to establish an association > - Lack of flexibility. What happens when you decide that Blog comments > need to have additional fields? > - Poor normalization > - Possibly meaningless fields for certain records (i.e. > blog_comment_vote) for Image comment (which does not require any > votes) > > On Sep 6, 5:43 am, luigi7up <[EMAIL PROTECTED]> wrote: > > > hola everyone, > > > while developing application something crossed my mind. What about > > organizing all comments throughout application in one database table. > > > What I mean is this: > > > If application has some kind of Blog, News, picture gallery you woul > > create blog_comments table, news_comments table etc. > > What about table creating one table that would hold all comments ?!? > > Table comments would have following fields (id, model_name, item_id, > > author, text) > > > This table would get pretty huge very soon but there is some logic in > > this approach :) > > > What do you think? > > > thanks --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Database optimisation (all comments in one table)
I see little benefit to this solution, having everything in one table is not necessarily a good thing. There are a few drawbacks to this solution... - Relying on two fields in order to establish an association - Lack of flexibility. What happens when you decide that Blog comments need to have additional fields? - Poor normalization - Possibly meaningless fields for certain records (i.e. blog_comment_vote) for Image comment (which does not require any votes) On Sep 6, 5:43 am, luigi7up <[EMAIL PROTECTED]> wrote: > hola everyone, > > while developing application something crossed my mind. What about > organizing all comments throughout application in one database table. > > What I mean is this: > > If application has some kind of Blog, News, picture gallery you woul > create blog_comments table, news_comments table etc. > What about table creating one table that would hold all comments ?!? > Table comments would have following fields (id, model_name, item_id, > author, text) > > This table would get pretty huge very soon but there is some logic in > this approach :) > > What do you think? > > thanks --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Database optimisation (all comments in one table)
It's a smart way to design your DB and works really well for simple tables such as comments. I think the main thing is to try and create all the fields that every kind of comment would ever need at the outset. In that way you will ascertain that the fields are similar enough to keep the data in one table and you won't have to keep adding extra fields later, although of course you can always do so if you've forgotten something. For example, for Blog comments you might foresee a requirement that people would like to rate the blog entries. Therefore make sure you have a rating field even though this might never be used or exposed for News comments. As always with DB design, a few extra minutes planning can save days of trouble and re-factoring later on :-) On Sep 6, 10:43 am, luigi7up <[EMAIL PROTECTED]> wrote: > hola everyone, > > while developing application something crossed my mind. What about > organizing all comments throughout application in one database table. > > What I mean is this: > > If application has some kind of Blog, News, picture gallery you woul > create blog_comments table, news_comments table etc. > What about table creating one table that would hold all comments ?!? > Table comments would have following fields (id, model_name, item_id, > author, text) > > This table would get pretty huge very soon but there is some logic in > this approach :) > > What do you think? > > thanks --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Database optimisation (all comments in one table)
Type in google: Database Normalization And you'll find your awnsers. The way you are want to do it is VERY bad. On 6 sep, 11:43, luigi7up <[EMAIL PROTECTED]> wrote: > hola everyone, > > while developing application something crossed my mind. What about > organizing all comments throughout application in one database table. > > What I mean is this: > > If application has some kind of Blog, News, picture gallery you woul > create blog_comments table, news_comments table etc. > What about table creating one table that would hold all comments ?!? > Table comments would have following fields (id, model_name, item_id, > author, text) > > This table would get pretty huge very soon but there is some logic in > this approach :) > > What do you think? > > thanks --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Database optimisation (all comments in one table)
hola everyone, while developing application something crossed my mind. What about organizing all comments throughout application in one database table. What I mean is this: If application has some kind of Blog, News, picture gallery you woul create blog_comments table, news_comments table etc. What about table creating one table that would hold all comments ?!? Table comments would have following fields (id, model_name, item_id, author, text) This table would get pretty huge very soon but there is some logic in this approach :) What do you think? thanks --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---