<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5828628185220859202</id><updated>2011-10-31T03:06:23.672-07:00</updated><category term='Adjacency List'/><category term='Nested Set Model'/><category term='MySQL'/><category term='Database'/><category term='Hierarchy'/><title type='text'>donatoaz</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://donatoaz.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5828628185220859202/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://donatoaz.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Donato Azevedo</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp3.blogger.com/_0FsBb0BqlY4/R86l0oC1Z8I/AAAAAAAAAEI/ndA4tfCJnno/S220/key.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5828628185220859202.post-8112351661641333864</id><published>2011-05-30T14:27:00.000-07:00</published><updated>2011-05-30T14:28:32.924-07:00</updated><title type='text'>Cell Phone Interface for PBX use</title><content type='html'>&lt;table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-xP1fB9y07_0/TeQKyrCMimI/AAAAAAAAAQ8/9OkreVY_O9c/s1600/cellphone.jpg" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="150" src="http://2.bp.blogspot.com/-xP1fB9y07_0/TeQKyrCMimI/AAAAAAAAAQ8/9OkreVY_O9c/s200/cellphone.jpg" width="200" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Cellphone interfaces for PBX are&lt;br /&gt;a good way to reduce costs&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;After realizing that over 50% of the company's cell phone bill is due to local to mobile calls I decided to investigate the possibility of using a Cell Phone Interface for our PBX (generaly called PABX in Brazil).&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;We have a Digital Telephone Central model Intelbras 141. Which, according to the companies website, supports the ITC 4000 Cellphone Interface.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;However, this model is priced nearly twice as much as a model from a different manufacturer (Naccell, ITS, Plugcell).&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;These are said to be compatible with *any* PBX on the market, however I fear they might only be compatible with Analogic or Hybrid Telephone Centrals.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;Another issue involved is the selection of the carrier plan: one major catch here: STATIC USE CLAUSE.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;Most carriers, on their general purpuse plans, have a clause on their contract stating the following (extracted from TIM contract for a Liberty plan) that is said to void the contract and cause loss of benefits:&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;3.3.1.3. Uso estático (sem mobilidade) do aparelho celular em cerca de 60% do tráfego originado pelo CLIENTE e recebimento de ligações em proporção inferior a 33% do volume originado, por&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;mês.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;Meaning:&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;3.3.1.3. Static Use (no mobility) of the celular device in around 60% of traffic originated by the client and receival of calls in proportion inferior than 33% of the originated volume, each month.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;With that in mind, I have to find a plan that does not forbid you from having a staticaly allocated sim card carrying calls for my PBX.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5828628185220859202-8112351661641333864?l=donatoaz.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://donatoaz.blogspot.com/feeds/8112351661641333864/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://donatoaz.blogspot.com/2011/05/cell-phone-interface-for-pbx-use.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5828628185220859202/posts/default/8112351661641333864'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5828628185220859202/posts/default/8112351661641333864'/><link rel='alternate' type='text/html' href='http://donatoaz.blogspot.com/2011/05/cell-phone-interface-for-pbx-use.html' title='Cell Phone Interface for PBX use'/><author><name>Donato Azevedo</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp3.blogger.com/_0FsBb0BqlY4/R86l0oC1Z8I/AAAAAAAAAEI/ndA4tfCJnno/S220/key.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-xP1fB9y07_0/TeQKyrCMimI/AAAAAAAAAQ8/9OkreVY_O9c/s72-c/cellphone.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5828628185220859202.post-8695124962612244554</id><published>2011-05-16T06:29:00.000-07:00</published><updated>2011-05-16T06:31:19.028-07:00</updated><title type='text'>Hiring a webdesign company and giving straightforward intelligible guidelines</title><content type='html'>&lt;table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-XxKgFFNyUdQ/TdEmCOrzD5I/AAAAAAAAAQ0/FvXlHpQcrrk/s1600/website-design.jpg" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="200" src="http://1.bp.blogspot.com/-XxKgFFNyUdQ/TdEmCOrzD5I/AAAAAAAAAQ0/FvXlHpQcrrk/s200/website-design.jpg" width="198" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Gathering successful examples is&lt;br /&gt;a great way to start&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;Being an ordinary software developer involves knowing your deficiencies and not being a wiseass who thinks he knows about everything.&lt;br /&gt;&lt;br /&gt;And that means, sometimes, you will hire someone to do a better job than you would. Or maybe you just don't have the time and need it done fast. Or even further, sometimes it needs to be cute, and let's face it, it is yet to be born a software developer who grasps the concepts of cuteness.&lt;br /&gt;&lt;br /&gt;That said, we're in the process of hiring a web designing company to refurbish our web site.&lt;br /&gt;&lt;br /&gt;The Marketing and Creative Director (MCD) has scheduled a meeting between me and the designer, because, from their conversations, some technical details surfaced, and I am supposed to interface them in this matter.&lt;br /&gt;&lt;br /&gt;I recognize that criticizing design is one of my weaknesses, however, I might as well meander in the usability issues given that, to the least, I am a well experienced "user" of websites.&lt;br /&gt;&lt;br /&gt;I gathered, in a short time, a couple of references that are quite good and that I summarize below.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://mashable.com/2011/04/10/5-web-design-mistakes/"&gt;Top Five Web Design Mistakes Small Businesses Make&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;1) Poor navigation: p&lt;span class="Apple-style-span" style="color: #474747; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 21px;"&gt;eople visit your site for specific information, and if they cannot find it they will quickly go elsewhere, leaving with the impression that your business is disorganized in more than just its website.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;2) No clear calls to action: i&lt;span class="Apple-style-span" style="color: #474747; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 21px;"&gt;f you aren’t leading users to commit to an action (buy a product, contact you or subscribe, for example), then you are losing them.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: right; margin-left: 1em; text-align: right;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-A-fUwnKUjKI/TdEmIM6OVEI/AAAAAAAAAQ4/L3o2ctD_GYU/s1600/recruitment_website_design.jpg" imageanchor="1" style="clear: right; margin-bottom: 1em; margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="200" src="http://3.bp.blogspot.com/-A-fUwnKUjKI/TdEmIM6OVEI/AAAAAAAAAQ4/L3o2ctD_GYU/s200/recruitment_website_design.jpg" width="187" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Choosing colours may be&lt;br /&gt;the most dificult task&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;3) Color and contrast: i&lt;span class="Apple-style-span" style="color: #474747; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 21px;"&gt;f your website text does not have sufficient contrast compared to its background, people will have difficulty reading your content.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;4) Content: p&lt;span class="Apple-style-span" style="color: #474747; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 21px;"&gt;eople visit your website for its content, and how that is structured is a huge factor in its success or failure.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;5) Clutter: c&lt;span class="Apple-style-span" style="color: #474747; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 17px;"&gt;hallenge every item on each page and ask, “Does it really need to be there? Does it serve a specific purpose? Can I live without it?”.&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #474747; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 21px;"&gt;Even the greatest content can become lost in a mess of words and graphics, so de-cluttering is essential.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://developer.apple.com/library/safari/#technotes/tn2010/tn2262/_index.html"&gt;Preparing Your Web Content for iPad&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;1) Test your web site in iPad, iPhone and desktop. Update user agent detection code if necessary&lt;br /&gt;&lt;br /&gt;2) Use W3C standards instead of plugins. Prefer HTML5. (and by plugins, yes, we mean Flash and Java)&lt;br /&gt;&lt;br /&gt;3) Check viewport settings. Do not hardcode width elements&lt;br /&gt;&lt;br /&gt;4) Modify code that relies on CSS fixed positioning. These do not work *as expected* on iPhone and iPad, because the viewport is the window and window size is set to the size of the physical screen and is, therefore, not resizable on these devices.&lt;br /&gt;&lt;br /&gt;5) Prepare for touch interface. Most importantly: avoid hovering actions or any other *typical mouse* related features.&lt;br /&gt;&lt;br /&gt;6) Use textareas instead of contenteditable elements.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5828628185220859202-8695124962612244554?l=donatoaz.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://donatoaz.blogspot.com/feeds/8695124962612244554/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://donatoaz.blogspot.com/2011/05/hiring-webdesign-company-and-giving.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5828628185220859202/posts/default/8695124962612244554'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5828628185220859202/posts/default/8695124962612244554'/><link rel='alternate' type='text/html' href='http://donatoaz.blogspot.com/2011/05/hiring-webdesign-company-and-giving.html' title='Hiring a webdesign company and giving straightforward intelligible guidelines'/><author><name>Donato Azevedo</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp3.blogger.com/_0FsBb0BqlY4/R86l0oC1Z8I/AAAAAAAAAEI/ndA4tfCJnno/S220/key.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-XxKgFFNyUdQ/TdEmCOrzD5I/AAAAAAAAAQ0/FvXlHpQcrrk/s72-c/website-design.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5828628185220859202.post-5181861267505017768</id><published>2011-05-10T07:22:00.000-07:00</published><updated>2011-05-10T12:04:41.147-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MySQL'/><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><category scheme='http://www.blogger.com/atom/ns#' term='Nested Set Model'/><title type='text'>Implementing complex pricing schemes using a Nested Set Model</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;To accomplish the &lt;a href="http://donatoaz.blogspot.com/2011/05/estudo-sobre-modelos-para-composicao-de.html"&gt;proposed pricing scheme&lt;/a&gt;&amp;nbsp;which would allow for arbitrary multiplication of any given factor by a detirmined index, the model has to be adjusted accordingly.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;m&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;ysql&amp;gt; describe nested_set;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;+----------------+---------+------+-----+---------+&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;----------------+&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;| Field &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| Type &amp;nbsp; &amp;nbsp;| Null | Key | Default | Extra &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;+----------------+---------+------+-----+---------+----------------+&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;| id &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | int(11) | NO &amp;nbsp; | PRI | NULL &amp;nbsp; &amp;nbsp;| auto_increment |&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;| name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | text &amp;nbsp; &amp;nbsp;| YES &amp;nbsp;| &amp;nbsp; &amp;nbsp; | NULL &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;| additive &amp;nbsp; &amp;nbsp; &amp;nbsp; | int(11) | YES &amp;nbsp;| &amp;nbsp; &amp;nbsp; | 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;| multiplicative | int(11) | YES &amp;nbsp;| &amp;nbsp; &amp;nbsp; | 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;| lft &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| int(11) | NO &amp;nbsp; | &amp;nbsp; &amp;nbsp; | NULL &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;| rgt &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| int(11) | NO &amp;nbsp; | &amp;nbsp; &amp;nbsp; | NULL &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;+----------------+---------+------+-----+---------+----------------+&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;As evidenced, I droped the value field and added a couple more, namely: additive and multiplicative. This way, the pricing view is now described as follows:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://1.bp.blogspot.com/-8qHjnyKb9is/TclF7dvGJ1I/AAAAAAAAAQo/4KX7yB7Nofc/s1600/mixed_coin_stack_2lrg.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-8qHjnyKb9is/TclF7dvGJ1I/AAAAAAAAAQo/4KX7yB7Nofc/s1600/mixed_coin_stack_2lrg.jpg" /&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;CREATE VIEW `pricing` AS select `node`.`id` AS `id`,`node`.`name` AS `name`,sum((`children`.`multiplicative` * `children`.`additive`)) AS `price` from (`nested_set` `node` join `nested_set` `children`) where (`children`.`lft` between `node`.`lft` and `node`.`rgt`) group by `node`.`name` order by `node`.`id`&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;However, it makes sense to have an independent factor entity given that one single factor may apply to several diferent node values. The following modifications make this feasible:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;mysql&amp;gt; describe factor;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;+-------+---------+------+-----+---------+----------------+&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;| Field | Type &amp;nbsp; &amp;nbsp;| Null | Key | Default | Extra &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;+-------+---------+------+-----+---------+----------------+&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;| id &amp;nbsp; &amp;nbsp;| int(11) | NO &amp;nbsp; | PRI | NULL &amp;nbsp; &amp;nbsp;| auto_increment |&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;| name &amp;nbsp;| text &amp;nbsp; &amp;nbsp;| YES &amp;nbsp;| &amp;nbsp; &amp;nbsp; | NULL &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;| value | int(11) | NO &amp;nbsp; | &amp;nbsp; &amp;nbsp; | 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;+-------+---------+------+-----+---------+----------------+&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; text-align: left;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-Ou2ohPd1obo/TclXnwV0O0I/AAAAAAAAAQw/Uf3VGV-x330/s1600/coin_stack.jpg" imageanchor="1" style="clear: right; margin-bottom: 1em; margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/-Ou2ohPd1obo/TclXnwV0O0I/AAAAAAAAAQw/Uf3VGV-x330/s1600/coin_stack.jpg" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Add caption&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;and the new view as follows:&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;CREATE VIEW `pricing` AS select `node`.`id` AS `id`,`node`.`name` AS `name`,sum((`factor`.`value` * `children`.`additive`)) AS `price` from (`nested_set` `node` join (`nested_set` `children` join `factor` on((`factor`.`id` = `children`.`multiplicative`)))) where (`children`.`lft` between `node`.`lft` and `node`.`rgt`) group by `node`.`name` order by `node`.`id`&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;With this, I am able to have this sort of formulas implemented on a tree structure:&lt;br /&gt;&lt;br /&gt;Node_Price = Sum(1,N) [ Child1 * Factor_for_child1 + Child2 * Factor_for_Child2 + ... ChildN * Factor_for_ChildN)&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5828628185220859202-5181861267505017768?l=donatoaz.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://donatoaz.blogspot.com/feeds/5181861267505017768/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://donatoaz.blogspot.com/2011/05/implementing-complex-pricing-schemes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5828628185220859202/posts/default/5181861267505017768'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5828628185220859202/posts/default/5181861267505017768'/><link rel='alternate' type='text/html' href='http://donatoaz.blogspot.com/2011/05/implementing-complex-pricing-schemes.html' title='Implementing complex pricing schemes using a Nested Set Model'/><author><name>Donato Azevedo</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp3.blogger.com/_0FsBb0BqlY4/R86l0oC1Z8I/AAAAAAAAAEI/ndA4tfCJnno/S220/key.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-8qHjnyKb9is/TclF7dvGJ1I/AAAAAAAAAQo/4KX7yB7Nofc/s72-c/mixed_coin_stack_2lrg.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5828628185220859202.post-159520529471408266</id><published>2011-05-10T06:19:00.000-07:00</published><updated>2011-05-10T06:19:17.971-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Adjacency List'/><category scheme='http://www.blogger.com/atom/ns#' term='Hierarchy'/><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><category scheme='http://www.blogger.com/atom/ns#' term='Nested Set Model'/><title type='text'>Estudo sobre modelos para composição de preço de produtos manufaturados</title><content type='html'>&lt;table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-EWV2O7qhvNA/Tcf6orYYxHI/AAAAAAAAAQc/F9h5XdTsZOw/s1600/various-tree-designs-vector-illustraion.jpg" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="318" src="http://2.bp.blogspot.com/-EWV2O7qhvNA/Tcf6orYYxHI/AAAAAAAAAQc/F9h5XdTsZOw/s320/various-tree-designs-vector-illustraion.jpg" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;[Fonte:&amp;nbsp;http://www.revistamedievo.com]&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;Hoje vou tentar criar um modelo simples para composição de preços para produtos manufaturados com múltiplas matérias primas e mútiplas etapas de trabalho. E que suporte historiamento de precificação, ou seja, parâmetros variáveis com o tempo afetam a determinação de um preço e a cada determinação de preço deve ser mantido um histórico.&lt;br /&gt;&lt;br /&gt;Ademais, cada precificação é composta, além da matéria e do trabalho, de outros fatores mercadológicos, que incidem sobre o preço final ou sobre cada elemento da composição sob forma de um índice de correção. Cada aplicação de índice deve também também ser historiada e rastreável, ou seja, a aplicação de um desconto sobre uma determinada matéria por razão X deve ser armazenada para futura auditoria.&lt;br /&gt;&lt;br /&gt;Estou estudando os modelos de relacionamento em árvore e se eles serão capazes de implementar este modelo, e sobretudo, se serão escaláveis para futuras adições de complexidade.&lt;br /&gt;&lt;br /&gt;A questão é se seria possível modelar em uma entidade só "coisas" que são diversas (mão de obra VS matéria prima).&lt;br /&gt;&lt;br /&gt;From now on, it's about to get technical, so I decided to write in plain english.&lt;br /&gt;&lt;br /&gt;1st attempt: simple hierarchical tree model:&lt;br /&gt;&lt;br /&gt;Every tree has a root, roots might have zero or more nodes and nodes might have zero or more nodes. Each node has only one parent node.&lt;br /&gt;&lt;br /&gt;In this model, the price composition is as follows:&lt;br /&gt;&lt;br /&gt;Given a node, its price is the sum of the price of each individual children multiplied by a factor inherent and unique to this node.&lt;br /&gt;&lt;br /&gt;The exception being for those nodes that *do not* have children, in which case, their price is explicitly assigned and multiplied by a factor inherent and unique to itself.&lt;br /&gt;&lt;br /&gt;The simplest representation for this model would require a single entitie: Node.&lt;br /&gt;&lt;br /&gt;Node&lt;br /&gt;--------------------&lt;br /&gt;id&lt;br /&gt;parent_id&lt;br /&gt;price&lt;br /&gt;factor&lt;br /&gt;&lt;br /&gt;This model may, howerver, be further normalized, considering several nodes might share the same factor and would benefit from depending on a single entry of a different entity. Thus:&lt;br /&gt;&lt;br /&gt;Node&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;--------------------&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;id&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;parent_id&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;price&amp;nbsp;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;factor_id&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Factor&lt;/div&gt;&lt;div&gt;--------------------&lt;/div&gt;&lt;div&gt;id&lt;/div&gt;&lt;div&gt;factor&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Howerver, it gets misty as to how the price property behaves given that there is no easy awareness of the tree's depth, and the aggregate calculations might get nasty.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;2nd Attempt: Nested Set Model&lt;br /&gt;&lt;br /&gt;Nested set models use two properties, lft and rgt, to localize each node in its set hierarchy. This localizations makes for an easier querying when dealing with unlimited depth sets (and thus, trees).&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-8Y8hctG1wqY/Tck53DeOVRI/AAAAAAAAAQg/NgHAKLpGbU4/s1600/hierarchical-data-3.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="120" src="http://2.bp.blogspot.com/-8Y8hctG1wqY/Tck53DeOVRI/AAAAAAAAAQg/NgHAKLpGbU4/s400/hierarchical-data-3.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Graphical representation of Nested Set Model, with lft and rgt properties depicted. [source:&amp;nbsp;dev.mysql.com]&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;MySQL has a good descritption of &lt;a href="http://dev.mysql.com/tech-resources/articles/hierarchical-data.html"&gt;Nested Set Models&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;With this Model, I am able to easily query prices as aggregate functions using one single entity:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;CREATE TABLE `nested_set` (&lt;br /&gt;&amp;nbsp;&amp;nbsp;`id` int(11) NOT NULL AUTO_INCREMENT,&lt;br /&gt;&amp;nbsp;&amp;nbsp;`name` text,&lt;br /&gt;&amp;nbsp;&amp;nbsp;`value` int(11) DEFAULT NULL,&lt;br /&gt;&amp;nbsp;&amp;nbsp;`lft` int(11) NOT NULL,&lt;br /&gt;&amp;nbsp;&amp;nbsp;`rgt` int(11) NOT NULL,&lt;br /&gt;&amp;nbsp;&amp;nbsp;PRIMARY KEY (`id`)&lt;br /&gt;) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Querying a price is as simple as creating the following view:&lt;br /&gt;&lt;br /&gt;CREATE VIEW `pricing` AS select `node`.`id` AS `id`,`node`.`name` AS `name`,sum(`children`.`value`) AS `price` from (`nested_set` `node` join `nested_set` `children`) where (`children`.`lft` between `node`.`lft` and `node`.`rgt`) group by `node`.`name` order by `node`.`id`&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5828628185220859202-159520529471408266?l=donatoaz.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://donatoaz.blogspot.com/feeds/159520529471408266/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://donatoaz.blogspot.com/2011/05/estudo-sobre-modelos-para-composicao-de.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5828628185220859202/posts/default/159520529471408266'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5828628185220859202/posts/default/159520529471408266'/><link rel='alternate' type='text/html' href='http://donatoaz.blogspot.com/2011/05/estudo-sobre-modelos-para-composicao-de.html' title='Estudo sobre modelos para composição de preço de produtos manufaturados'/><author><name>Donato Azevedo</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://bp3.blogger.com/_0FsBb0BqlY4/R86l0oC1Z8I/AAAAAAAAAEI/ndA4tfCJnno/S220/key.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-EWV2O7qhvNA/Tcf6orYYxHI/AAAAAAAAAQc/F9h5XdTsZOw/s72-c/various-tree-designs-vector-illustraion.jpg' height='72' width='72'/><thr:total>0</thr:total></entry></feed>
