<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Torkil Johnsen</title>
	<atom:link href="http://www.torkiljohnsen.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.torkiljohnsen.com</link>
	<description>My personal piece of cyberspace</description>
	<lastBuildDate>Tue, 17 Aug 2010 22:55:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>How to create—and remember—a different password for every single login</title>
		<link>http://www.torkiljohnsen.com/2010/08/18/how-to-create%e2%80%94and-remember%e2%80%94a-different-password-for-every-single-login/</link>
		<comments>http://www.torkiljohnsen.com/2010/08/18/how-to-create%e2%80%94and-remember%e2%80%94a-different-password-for-every-single-login/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 22:49:46 +0000</pubDate>
		<dc:creator>tj</dc:creator>
				<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.torkiljohnsen.com/?p=370</guid>
		<description><![CDATA[Here is a neat trick for how you can create and remember thousands of good, secure and UNIQUE passwords, using keys. No more identical passwords, and no more easily breakable ones either. Spend 5 minutes reading this blog post, you won&#8217;t regret it. Money back guarantee! The problems If you take security seriously, you&#8217;d want [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a neat trick for how you can create and remember thousands of good, secure and UNIQUE passwords, using keys. No more identical passwords, and no more easily breakable ones either. Spend 5 minutes reading this blog post, you won&#8217;t regret it. Money back guarantee!<br />
<span id="more-370"></span></p>
<h2>The problems</h2>
<p>If you take security seriously, you&#8217;d want to avoid for instance simple, short passwords and passwords that can be found in a dictionary. If someone gets hold of a user database with your username and hashed password in it, it&#8217;s just a matter of time before it can be cracked. And if you use the same passwords on all your logins all over the internet, you&#8217;ll be in real trouble.</p>
<h2>The challenge</h2>
<ol>
<li>Use both small letters, capital letters, numbers and symbols, and combine this into a password with minimum 12 characters.</li>
<li>Remember what you came up with in #1.</li>
<li>Repeat process for hundreds of logins with equally complex passwords, and still remember them all.</li>
</ol>
<h2>The solution</h2>
<p>Here is how…</p>
<h3>1. Create a memorable password</h3>
<p>Use some things you can relate to, stuff you remember, like a favourite movie quote, the first book you read, the number of dollars you stole from your mother that time, the opening lyrics to a song you once wrote, the first letters of the words of an opening sentence in a book. Anything goes!</p>
<p>I&#8217;ll take a piece of a quote from &#8220;<a href="http://www.imdb.com/title/tt0116908/quotes">The Long Kiss Goodnight</a>&#8220;:<br />
<strong>Alice, please. Your dog!</strong></p>
<p>Note how I managed to get both a comma, a period and an exclamation mark in there.</p>
<p>Now, I take away the spaces, because spaces cause issues with lots of databases it seems, so I end up with:<br />
<strong>Alice,please.YourDog!</strong></p>
<h3>2. Make the password more secure</h3>
<p>&#8220;More secure&#8221; does in this case mean: Less dictionary words, more length and/or more complexity. For instance I have not used any numbers yet. So I&#8217;ll convert the A to a 4, because they look similar. It&#8217;s also a bit long, so to shorten it (and give my blog a bit more hacker-like credibility!) I&#8217;ll change &#8220;please&#8221; to &#8220;plz&#8221;, &#8220;Your&#8221; to &#8220;Ur&#8221; and &#8220;Dog&#8221; to &#8220;Dwg&#8221;, which is short for &#8220;Dawg&#8221;. (of course!) I end up with this:</p>
<p><strong>4lice,plz.UrDwg!</strong></p>
<p>Swapping A for 4 is a bit obvious perhaps and it feels like it needs more numbers. So since we&#8217;re talking about dogs, I&#8217;ll also add the age my first dog was when he died:</p>
<p><strong>4lice,plz.UrDwg!12</strong> </p>
<p>That&#8217;s actually 18 characters long, so I&#8217;ll stop there before I scare you readers off. I&#8217;d recommend a phrase of at least 12 characters though.</p>
<p>Work the phrase like this, adding or substituting stuff, until you have something that looks like nonsense, but makes perfect sense to yourself. Don&#8217;t worry if it takes a long time to type. You&#8217;ll be typing it a lot in the time to come, so soon you&#8217;ll hammer it down in milliseconds.</p>
<h3>3. Memorize it</h3>
<p>Yes, you have to memorise it, sorry. It&#8217;s hopefully a hard one, but step #2 should however make it easer for you.</p>
<p>Oh, and keep it secret too!</p>
<h3>4. Add keyholes</h3>
<p>Here comes the part that makes it interesting. We are going to make parts of our password variable, by adding two keyholes. You can use one or five too, that&#8217;s up to you. A keyhole is an opening where we will insert keys. The keys are what will make our passwords unique.</p>
<p>Here, I&#8217;ve inserted two underscores to represent my keyholes:<br />
4lice,plz.<strong>_</strong>UrDwg!12<strong>_</strong></p>
<p>These two keyholes will change according to where we are logging in. Keep reading, you&#8217;re almost there!</p>
<h3>5. Add keys</h3>
<p>Keys are what goes into the keyholes, and we want to vary these as much as possible. They need to be <strong>different, but predictable</strong>, so we determine these by rules. </p>
<p>Here are some examples of rules you can use to create keys for two keyholes:</p>
<ol>
<li>The first + second letter of the domain name of the website you&#8217;re logging into.</li>
<li>The first letter of the first syllable of the sitename you are accessing + the capitalised first letter of the second syllable.</li>
<li>The number of letters in the domain name + the first vowel in the sitename.</li>
<li>The two last letters of the domain name + the two first letters of the sitename.</li>
<li>etc…</li>
</ol>
<p>Spend some time on this part to make one fun and unique rule for yourself. Keep this secret. </p>
<p>Rule #1 here was the first rule I tried when experimenting with this way of making passwords, and it is not very good. The reason is that I log in at many websites that have domain names that begin with the word &#8220;joomla&#8221;, thus my keys became &#8220;j&#8221; and &#8220;o&#8221; very often. </p>
<p>So base your rule on something that&#8217;s mostly static for each website, but not similar to many websites. </p>
<h3>6. Start creating passwords</h3>
<p>Let&#8217;s say I was going to use rule #4 with my password from above. My password, with two keyholes, was this:<br />
4lice,plz.<strong>_</strong>UrDwg!12<strong>_</strong></p>
<p>If I was logging into digg.com, which has the sitename Digg. Using rule #4 then the two keys would be &#8220;gg&#8221; and &#8220;Di&#8221;, where &#8220;gg&#8221; are the two last letters of the domain name, and &#8220;Di&#8221; are the two first letters of the sitename. When I insert these two keys into my keyholes, I get this password for logging into digg.com (keys are underlined):</p>
<p>4lice,plz.<u><strong>gg</strong></u>UrDwg!12<u><strong>Di</strong></u></p>
<p>Here are some passwords for some other sites:<br />
joomla.org: 4lice,plz.<u><strong>la</strong></u>UrDwg!12<u><strong>Jo</strong></u><br />
wordpress.com: 4lice,plz.<u><strong>ss</strong></u>UrDwg!12<u><strong>Wo</strong></u><br />
drupal.org: 4lice,plz.<u><strong>al</strong></u>UrDwg!12<u><strong>dr</strong></u><br />
twitter.com: 4lice,plz.<u><strong>er</strong></u>UrDwg!12<u><strong>Tw</strong></u><br />
facebook.com: 4lice,plz.<u><strong>ok</strong></u>UrDwg!12<u><strong>Fa</strong></u></p>
<p>So I end up with 22 character long passwords, and most of them will be unique, and some will be the same, depending on the rules and keys you use. </p>
<p>Most important of all though: They will be complex, but I will still remember every single one of them.</p>
<h3>7. Ideas to complicate things even more</h3>
<p>For those of you who really want to be totally paranoid about it:</p>
<ul>
<li>Use variable keyholes too. If the sitename starts with a vowel, add a keyhole to the front of the password. If not, add a keyhole to the end.
</li>
<li>Base key rules on stuff that changes now and then. For instance a website&#8217;s main colour, or the number of main menu items it has. This will occasionally break your password, and you&#8217;ll have to use the &#8220;forgot password&#8221; function to reset it and change now and then, which can be a healthy thing to do.
</li>
<li>Have different usernames too, but perhaps not too obvious, since these often are visible to others. &#8220;torkilDIGG&#8221; is not a too good digg.com password. When people also see my Joomla forum username being &#8220;torkilJoomla&#8221;, then they&#8217;ll know the pattern straight away. Numbers could be good though, like torkil4 for digg.com and torkil6 for joomla.org, since digg has four letters and joomla has six. It gives you some variation at least.
</li>
<li>Keep a list of random keys. Yes, a list. Write them down. Your list could look like this:<br />
Digg: x76T<br />
Facebook: pOw2<br />
Stumbleupon: 99!b</p>
<p>Only you would know what to do with these four characters. And then store this file in an encrypted format on a computer not connected to the internet, buried six feet under your house. ;)</li>
</ul>
<p>Got any ideas on how to make a memorable but complex and unique password? An idea on how to obfuscate common words? Perhaps a genius rule for creating keys? A way to make things more complex? Share below!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.torkiljohnsen.com/2010/08/18/how-to-create%e2%80%94and-remember%e2%80%94a-different-password-for-every-single-login/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Taking Joomla Forward</title>
		<link>http://www.torkiljohnsen.com/2010/08/13/taking-joomla-forward/</link>
		<comments>http://www.torkiljohnsen.com/2010/08/13/taking-joomla-forward/#comments</comments>
		<pubDate>Fri, 13 Aug 2010 13:24:26 +0000</pubDate>
		<dc:creator>tj</dc:creator>
				<category><![CDATA[joomla]]></category>

		<guid isPermaLink="false">http://www.torkiljohnsen.com/?p=329</guid>
		<description><![CDATA[I write code, so I care mostly about what&#8217;s happening to the Joomla Framework. Or should I say not happening? The Joomla project needs more coders and less talkers, to put it bluntly, much like a boat won&#8217;t get anywhere with just captains and no rowers. More and more people in the Joomla community seems [...]]]></description>
			<content:encoded><![CDATA[<p>I write code, so I care mostly about what&#8217;s happening to the Joomla Framework. Or should I say not happening? The Joomla project needs more coders and less talkers, to put it bluntly, much like a boat won&#8217;t get anywhere with just captains and no rowers. More and more people in the Joomla community seems to realise this and are taking up responsibility and working outside the core code to make the improvements needed in various areas. Let&#8217;s take a look…<br />
<span id="more-329"></span></p>
<h2>The frameworks and the CCKs</h2>
<p>The Joomla Framework and the Joomla content component are two of the most vital parts of Joomla if you ask me. Now, look at the number of extensions that exists that are replacing these core parts in improved ways: </p>
<p>K2, jSeblod, FLEXIcontent, Sobi2 and others are dominating in the CCK/ACL section of things, improving content management in Joomla greatly. Gantry, Morph and T3 are template frameworks looking to make template production easier and templates more stable and feature rich. And for the core framework itself there are multiple replacements available, like <a href="http://nooku.org">Nooku</a>, which is Joomla flavoured and my favourite. Others again, like <a href="http://jomsocial.com">JomSocial</a>, are just to replacing the Joomla core framework with <a href="http://www.jomsocial.com/docs/Installation">something entirely different</a>.</p>
<p><strong>So what am I really saying here?</strong></p>
<p>This shows that Joomla is not providing the functionality that the community needs. It is not able to keep up with the pace of which the world is moving, so people go elsewhere to get their fix, or they create their own solutions to scratch their own itch. Joomla is, as Hannes Papenberg points out, <a href="http://groups.google.com/group/joomla-dev-cms/browse_thread/thread/286c8777f46b7527/1e9bc2e240295fbd?#1e9bc2e240295fbd">already years behind</a> in development, and while Joomla 1.6 may and may not be too far away, it is still outgunned by solutions already available to us. Even by Joomla extensions.</p>
<h2>So, development is too slow. What can we do?</h2>
<p>A clear choice, as <a href="http://groups.google.com/group/joomla-dev-cms/browse_thread/thread/a477a550bb051f29/8d6104dbe4b804d5?lnk=gst&#038;q=years+behind#8d6104dbe4b804d5">suggested by Daniel Chapman</a> and others, is for Joomla to pick up existing best-of-breed GPL frameworks that are Joomla compatible, and integrate them into the core, to make up for lost time.</p>
<blockquote><p>This would bring J! up to date almost overnight, and reduce the confusion and bloat of having different fw&#8217;s for every major extension you install.<br />
<em>- Daniel Chapman</em></p></blockquote>
<p>Don&#8217;t get me wrong: I&#8217;m a supporter of the idea of a slim and light core. Today&#8217;s core is packed with outdated extensions that have passed their expiration date a long time ago. When the framework changes, very often all the components have to be changed too. I hardly ever even use them personally. They have become a burden, and should be removed:</p>
<p>The content component is poor on features compared to most of the CCKs, and don&#8217;t get me started on com_contacts or com_weblinks. Com_search does an awful job at searching and does not prioritise the search hits at all. Routing is a pain, <a href="http://twitter.com/nikosdion/statuses/20960916821">even for seasoned developers</a>. Com_mailto, com_newsfeeds, com_contact, com_banners… They all have extensions that does the job better.</p>
<p>I&#8217;m not saying we should pack Joomla with cool new extensions, just that we need a solid foundation to build on and make it easier to create cool, quality extensions. <a href="http://www.torkiljohnsen.com/2010/07/15/what-is-nooku-framework-and-why-should-i-care/">And that&#8217;s where frameworks come in handy</a>.</p>
<p><strong>So why won&#8217;t Joomla adapt external frameworks?</strong></p>
<h2>Volunteer contributions are worthless</h2>
<p>I am no Deep Throat insider, but in my opinion, <a href="http://community.joomla.org/blogs/leadership/1074-investing-in-joomlas-development.html">the decision</a> to give a salary to two core developers and not any other contributors at all, was a landmark in Joomla history. With this, Joomla effectively put a price tag on the projects estimated value of volunteer community contributions, and the value was $0. If I had still been a working group member and contributor, and then suddenly seeing Open Source Matters decide that two people should be paid for their work while the rest of us were deemed unworthy, I would not be very happy.</p>
<p>Paying developers like this can also get in the way of the natural flow of contributors in FOSS projects. A paid developer suddenly has lots of reasons to cling on to his job and shut other contributors out. Instead, lead developers should be encouraged to open things up, or even pass on their responsibility at some point to someone with new ideas and loads of fresh motivation. Money just may be too good of a motivation not to do so.</p>
<p>I think this is part of the cause of Joomla&#8217;s low <a href="http://en.wikipedia.org/wiki/Bus_factor">bus factor</a>. The decreasing community contributions is a problem that is <a href="http://groups.google.com/group/joomla-wg-production/msg/fd610ace7e13d650?">beginning to sink in with the leadership too</a>. Strength may not necessarily be in numbers, but a lack of numbers is taking it&#8217;s toll. </p>
<h2>Community is taking charge</h2>
<p>This and other things, for instance the Joomla leadership&#8217;s deliberate ignoring of the first community organized international Joomla event, <a href="http://jandbeyond.org">J and Beyond 2010</a>, is truly a sad turn of events for the project itself. Not only was the JAB10 event ignored, it was also officially and directly counteracted, by <a href="http://www.joomla.org/announcements/general-news/5277-inaugural-joomla-world-conference-announced.html">joomla.org promoting other events instead</a>.</p>
<p>If someone decided to take it upon themselves to host an event to promote <strong>my</strong> product, and pay for it themselves too, I would make sure that they got as much attention and credit for their work as I could possibly give them.</p>
<p>On the bright side for Joomla though, community is stepping in where leadership is having issues. Like with <a href="http://www.alltogetherasawhole.org/">ATAAW</a>, <a href="http://jandbeyond.org">JAB10</a> (see also <a href="http://search.twitter.com/search?q=%23jab11">#jab11</a>!), <a href="http://joomlaforward.org">JFWD</a>, <a href="http://magazine.joomla.org/">JCM</a> and <a href="http://people.joomla.org/groups/viewgroup/119-Joomla+UX.html">J!UX</a>, consisting of volunteers aiming to contribute to Joomla in various ways.</p>
<h2>Your turn</h2>
<p>If you made it this far, you&#8217;re obviously interested in Joomla, and probably using it already. What are your hopes for the future? Do you thing there is still hope for even the most zealous Joomla fans out there? In which direction would you like the project to go?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.torkiljohnsen.com/2010/08/13/taking-joomla-forward/feed/</wfw:commentRss>
		<slash:comments>61</slash:comments>
		</item>
		<item>
		<title>Using MySQL Workbench to manage your Joomla component’s db schema</title>
		<link>http://www.torkiljohnsen.com/2010/07/23/using-mysql-workbench-to-manage-your-joomla-components-db-schema/</link>
		<comments>http://www.torkiljohnsen.com/2010/07/23/using-mysql-workbench-to-manage-your-joomla-components-db-schema/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 22:19:05 +0000</pubDate>
		<dc:creator>tj</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[component]]></category>
		<category><![CDATA[joomla]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[schema]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[workbench]]></category>

		<guid isPermaLink="false">http://www.torkiljohnsen.com/?p=298</guid>
		<description><![CDATA[MySQL Workbench is a great tool for developers to map out and visualise databases. What many people know is that it&#8217;s also a great way to make upgrading and writing upgrade scripts for your components really painless too. Let&#8217;s say you created a small component that became popular over night. Tens of thousands of downloads [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL Workbench is a great tool for developers to map out and visualise databases. What many people know is that it&#8217;s also a great way to make upgrading and writing upgrade scripts for your components really painless too.<br />
<span id="more-298"></span><br />
Let&#8217;s say you created a small component that became popular over night. Tens of thousands of downloads from on the Joomla Extensions Directory. So you get inspired and put some more work into improving and bugfixing this component even more, and while doing that you change and add on to the database schema. </p>
<p>Now you need to create and distribute an update script with the next version of your component, and MySQL Workbench makes creating this update script really easy. Here is what you need to do:</p>
<h2>Install MySQL Workbench</h2>
<p>I&#8217;ll not help you with this. Just go to the <a href="http://wb.mysql.com/">MySQL Workbench homepage</a> and follow the instructions from there. Multiple platforms supported! It&#8217;s the same tool I used to create the <a href="http://www.torkiljohnsen.com/2010/07/11/joomla-1-6-database-schema/">Joomla 1.6 database schema.</a></p>
<p>After installation, start MySQL Workbench and we&#8217;re off!</p>
<h2>Create a new model</h2>
<p>From the main menu, click File -> New Model, then double click Add Diagram. Save your diagram right away and give your file a name. It always sucks to lose your work.</p>
<h2>Basic settings</h2>
<p>First some settings that are handy:</p>
<p>To the right, under the tab &#8220;catalog&#8221;, you&#8217;ll find your schema with the default name &#8220;mydb&#8221;. The schema name is the database name by the way. Double click it and change it&#8217;s default collation to utf8 &#8211; utf8_general_ci. UTF8 is what Joomla uses by default.</p>
<p>Open MySQL Workbench Preferences and set the column default names and values for the Model configuration. That way you can make it easier for yourself to follow the standards and conventions you want to be following. For those of you who are using Nooku, make sure to look up the <a href="http://nooku.assembla.com/wiki/show/nooku-framework/KDatabase">Nooku naming conventions</a>.</p>
<p>For my example I&#8217;ll be setting up a small blog database.</p>
<h2>The articles table</h2>
<p><a href="http://www.torkiljohnsen.com/wp-content/uploads/2010/07/MySQL_Workbench_add_blog_table.png"><img src="http://www.torkiljohnsen.com/wp-content/uploads/2010/07/MySQL_Workbench_add_blog_table-e1279833324229-150x150.png" alt="" title="MySQL_Workbench_add_blog_table" width="150" height="150" class="size-thumbnail wp-image-309 alignright" /></a>Click the Place a New Table-button in the left toolbar and click anywhere on the canvas to place a new table. Double click the table to start editing. You&#8217;ll see a line of tabs appearing at the bottom of the screen, one of which being columns, which you can edit to add columns to your table. </p>
<p>I created an example table structure for a <strong>blog articles table</strong> that you can look at on the screenshot to the right. Very basic stuff, just an id, a title, some content and a publish date for every article.</p>
<h2>Comments for my blog articles</h2>
<p>I then added a comments table, so that people can add comments to my blog. Basic stuff here too: Comment id, author name, author email, author homepage and comment contents. Note: I added no relation between the two tables just yet.</p>
<p><a href="http://www.torkiljohnsen.com/wp-content/uploads/2010/07/MySQL_Workbench_add_comments_table.png"><img src="http://www.torkiljohnsen.com/wp-content/uploads/2010/07/MySQL_Workbench_add_comments_table-e1279833747991-150x150.png" alt="" title="MySQL_Workbench_add_comments_table" width="150" height="150" class="alignright size-thumbnail wp-image-311" /></a>Now, I need to set up a <strong>relation between the two tables</strong>, since each comment should belong to a blog article. I click the button for 1:n non-identifying relationship, because each blog post will have potentially many comments attached to it. Non-identifying just means that the relation does not identify the comments, in this case that&#8217;s the job of the comment id. </p>
<p>So after clicking 1:n non identifying, I then click the comments table and proceed to click the articles table to set up the relation. You&#8217;ll see the line representing the relationship popping up immediately. A new column, blog_article_id is also added to the comments table automatically. This is of course the foreign key.</p>
<p>I then click and drag the new column, blog_article_id, up in the comments table, so that it&#8217;s ordered as the second column. Not necessary, but I like to keep my keys close. Note that you can also double click the relation indicator itself to edit the relation and manually change it or indicate if it&#8217;s mandatory or not. A comment needs to belong to a blog post, so in my example the relation is mandatory.</p>
<p>There, all ready to go! </p>
<h2>Create the components install SQL script</h2>
<p>First, I forgot, my tables need to be able to have their names converted to use any db prefix according to the Joomla standards, so I need them to have the db prefix nameholder #__. So blog_articles becomes #__blog_articles and blog_comments becomes #__blog_comments.</p>
<p>Ok, now let&#8217;s create an install script. Go to the main menu and click File -> Export -> Forward engeneer SQL CREATE script. For Output SQL scriptfile, put in a the desired filename for your SQL file, install.sql would fit the bill. Select &#8220;Omit schema qualifier in object names&#8221;, or else the database name (mydb) will be included in all SQL statements in the script. You can also skip creation of foreign keys if you want to since they have no effect in MyISAM, but it will do no harm to leave them in there. In my opinion they just makes the SQL structure easier to read for people interested in checking out it&#8217;s details.</p>
<p>In the next step, choose to export table objects. You can also add default data to your tables if you want to, and would then wish to also export data for the tables. Click continue, then finish, and the SQL file will be created for you. </p>
<h2>Creating version 2 of my component, and the upgrade SQL script</h2>
<p>Then I wanted to add an author name to my blog articles, so I went ahead and did that. Now I have a new version of my database, and I need to update my component. So my components version two will have to include an update script. For this I&#8217;ll need some SQL to modify the table structure, and this is where MySQL Workbench comes in very handy.</p>
<p><a href="http://www.torkiljohnsen.com/wp-content/uploads/2010/07/MySQL_Workbench_create_alter_script.png"><img src="http://www.torkiljohnsen.com/wp-content/uploads/2010/07/MySQL_Workbench_create_alter_script-e1279834186659-150x150.png" alt="" title="MySQL_Workbench_create_alter_script" width="150" height="150" class="size-thumbnail wp-image-312 alignright" /></a>After having modified the schema, from the main menu click File -> Export -> <strong>Forward engineer SQL ALTER script</strong>. In the Input file-field, select the SQL CREATE script you created earlier, and in Output file you name the resulting file. This will take the SQL file you just created (version 1), compare it to the current updated schema (version 2) which includes the author_name, and then produce an SQL ALTER script that creates a bridge between versions 1 and 2. that you can run on existing installations to update their schemas. Pretty neat, huh? Takes five seconds, and it&#8217;s easy to include in your upcoming new product release!</p>
<p>This example might not be much, but imagine having done multiple small and big changes. Having easy version creation and automation of upgrade scripts at hand then really comes in handy.</p>
<h2>Streamlining the process</h2>
<p>All we need now is some creative soul to write some Lua scripts to automate the creation of update scripts for all old versions every time a new version is saved. When you create version 20 and run the plugin, then all update scripts for all previous 19 versions are automatically set up for you.</p>
<p>Automatic insertion of $Id$ tag for SVN keywords would also be nice of course. Validation of Joomla compatibility or Nooku conformity are other ideas. Anything to prevent potential errors and automate tedious tasks really.</p>
<p>There exists a <a href="http://code.google.com/p/mysql-workbench-doctrine-plugin/">plugin for doing Doctrine exports from MWB</a>, so someone might get some inspiration from that.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.torkiljohnsen.com/2010/07/23/using-mysql-workbench-to-manage-your-joomla-components-db-schema/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>What is MVC, and why should I care?</title>
		<link>http://www.torkiljohnsen.com/2010/07/17/mvc-explained-with-benefits-and-examples/</link>
		<comments>http://www.torkiljohnsen.com/2010/07/17/mvc-explained-with-benefits-and-examples/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 09:02:25 +0000</pubDate>
		<dc:creator>tj</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[joomla]]></category>
		<category><![CDATA[design patterns]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[Nooku]]></category>

		<guid isPermaLink="false">http://www.torkiljohnsen.com/?p=170</guid>
		<description><![CDATA[Those of you following blogs and tweets in the Joomlasphere and reading about Nooku, might have read and learned about MVC and HMVC already. If not, here is a short explanation on MVC, and why you should care about design patterns and MVC in particular, especially if you&#8217;re a Joomla user. Design patterns Design patterns [...]]]></description>
			<content:encoded><![CDATA[<p>Those of you following blogs and tweets in the Joomlasphere and reading about Nooku, might have read and learned about MVC and HMVC already. If not, here is a short explanation on MVC, and why you should care about design patterns and MVC in particular, especially if you&#8217;re a Joomla user.<span id="more-170"></span><br />
<a name="design_patterns"></a><br />
<h2>Design patterns</h2>
<h3>Design patterns are reusable solutions</h3>
<p>First of all, MVC is an <em>architectural design pattern</em>. Yeah, that&#8217;s a mouthful. What is a <em>design pattern</em>? Well think of it like this: Patterns are stuff that repeats itself, right? So a <em>design</em> pattern is a design that repeats itself, or you could say &#8220;is reused&#8221;. A design can in development terms be thought of as a solution, so when you hear the words &#8220;design pattern&#8221;, you can think <em>reusable solution</em>. </p>
<p>Reusable solutions are smart ways of solving similar problems without reinventing the wheel. An architectural design pattern like MVC is in other words a reusable solution to an architectural problem. Many computer softwares aren&#8217;t that different architecturally, so MVC is a solution that can be used in many circumstances.</p>
<p>By giving names to these design patterns, for instance MVC, developers can easily communicate between one another how they are approaching or solving issues in their applications. For instance, if a PHP class in my code is called ArticleController (where &#8220;Controller&#8221; is the C in MVC), another developer that reads this code will immediately understand what the responsibility of this class is and what it should be able to do, because he understands the responsibility of the Controller in the MVC pattern. </p>
<h3>&#8230;like the wheel</h3>
<p>Speaking of not reinventing the wheel; the wheel itself could be seen as a design pattern: </p>
<p>We use the wheel in for instance cars, bicycles, buses and trains. So the wheel has indeed become a reusable solution to one common challenge: Making a vehicle easy to move. The wheels themselves are different on each vehicle because they are adapted to suit special circumstances, but the wheel concept itself is the same: Once the solution has been identified, it&#8217;s just a matter of putting it to good use. </p>
<p>So if you and I are building a vehicle that&#8217;s going to solve the challenge of transporting us from A to B, and I suggest that &#8220;we should put wheels on this thing&#8221;, then you&#8217;ll basically know what I&#8217;m thinking and we&#8217;ll also have a common understanding of how we&#8217;re going to build it. If we were to travel on a snow covered surface though, you could have suggested that we used a pair of skis as our solution, instead of the wheels. I would of course have slapped my forehead and agreed with you, without needing to see complicated blueprints or having long committee meetings.</p>
<p>That&#8217;s the advantage of having design patterns!</p>
<p>Jeff Atwood also has another nice MVC analogy in a blog post of his, see the link in the <a href="#references_and_footnotes">references &#038; footnotes</a> at the bottom.</p>
<p><a name="mvc"></a><br />
<h2>The building blocks of MVC</h2>
<p>The MVC pattern splits your code into three parts, often referred to as a triad: The Model, View and Controller. Here is a brief outline of what job each part does, particularly in the Joomla and Nooku Frameworks. </p>
<p>Note: This will teach you how to talk the talk, but not walk the walk! Oleg Nesterov&#8217;s presentation &#8220;Joomla Extension Kung Fu&#8221; provides some nice PHP code examples you can look at though to see MVC in action. See the link in the <a href="#references_and_footnotes">references &#038; footnotes</a> at the bottom of this article. I&#8217;d also recommend looking into the <a href="http://nooku.assembla.com/code/nooku-framework/subversion/nodes">Nooku Framework sourcecode</a> to see how MVC is implemented in PHP there.</p>
<p>Here are the basics though:</p>
<h3>Controller</h3>
<p>The controller is in charge, as the name would suggest. When you do a request, like for instance in a Joomla site entering example.com/index.php?option=com_content&#038;view=article&#038;id=13 in your browser, the controller in the content component takes care of getting the request data. For this request, we have the variables option, view and id visible in the URL. From that, the controller will set the model state so that the model, which is fetching the data for us later on, will know that it needs to fetch article number 13. The controller will then tell the article view to render itself. </p>
<h3>View</h3>
<p>The view decides what ends up on the screen. It will use the model to fetch the data it needs, load the template and display the content inside that template. In this case, the view requested is &#8220;article&#8221;, singular. In Nooku Framework, the view will automatically deduct from this that it needs to fetch a single item instead of a collection of items, as &#8220;articles&#8221; (plural) would have suggested. This is a small part of the &#8220;magic&#8221; happening underneath the hood in Nooku, which makes it so easy to work with.</p>
<h3>Model</h3>
<p>The model handles the data. If you need something added, edited, deleted or fetched to or from the database, the model is the class that will do the heavy lifting. The controller will set it&#8217;s states (like filtering, ordering etc), and then the model will do whatever it is told to do.</p>
<h2>Benefits and advantages of MVC, for all of us</h2>
<p>Why should you care about MVC and demand that your developers do the same? </p>
<h3>A clear separation of the code</h3>
<p>First of all, MVC splits your code into three distinct parts, each of which have clear responsibilities and limitations. When you&#8217;ve used this pattern for a while, deciding where to put a piece of code or look for a piece of code becomes intuitive and straight forward. This makes many parts of development a lot easier, because the design pattern dictates where the code should be located and what the code should do.<br />
It also makes it easier for other developers who know MVC to read and understand the code you have written, and after that, also extend or contribute to it, or even replace parts of it. </p>
<h3>Visual flexibility</h3>
<p>At the heart of MVC there is the desire to separate the presentation of data from the manipulation of data, partially because we want to reuse as much code as possible, but also because we want to be able to present one set of data in multiple ways. In the Joomla CMS for instance (version 1.5 and up), you have templates, and you can change templates to easily get a list of articles to look completely different without modifying the Joomla core code. Each template has the power to implement it&#8217;s own overrides for any view in any component in Joomla. Consequently, anyone can use their own template to make a component look exactly like they want to, given that the component in question follows the MVC design pattern of course. </p>
<h3>Formatting flexibility</h3>
<p>A new presentation of content need not only mean a new HTML template though: A list of articles can very well be displayed in a completely different format, like CSV, RSS, PDF or JSON. This can allow us to easily be able to reuse it in other parts of your website or even on other websites. So while the presentation or format of the data is different, the functionality used to fetch the data from the database is exactly the same every time. </p>
<h3>Replaceable parts</h3>
<p>On the opposite side: If I suddenly decide I want to store my articles in flat files instead of in a database, I can just modify the part of MVC that stores and fetches data, and leave the presentation part alone. The presentation of the data is in other words decoupled from the part of the application that communicates with the storage of the data.  </p>
<h3>Workflow</h3>
<p>My personal experience is that when working in teams, the separation of responsibilities in MVC makes it easy to divide the workload between team members. If a task on my task list just says &#8220;Article model&#8221;, then these two words also describe pretty well what it is that I need to do.</p>
<h2>Where to go from here?</h2>
<p>So how do I find out if my favourite component X follows the MVC pattern or not? Easy in most systems! In Joomla you can open the component&#8217;s folders, either administrator/components/com_x/ or components/com_x/ in a file browser or FTP client, and look for folders named &#8220;models&#8221; and &#8220;views&#8221;. If you find none, then the component is likely not using MVC the Joomla way. </p>
<p>If so, make sure to send the component&#8217;s developer an e-mail with a link to this article ;)</p>
<h2>Conclusions</h2>
<p>Design patterns are like wheels: They make things roll smoothly!</p>
<p><strong>The benefits of the MVC design pattern:</strong> It provides a logical and predictable architecture to work with and collaborate on, it allows us to reuse larger parts of our code, and it allows us to modify parts of our code while other parts can remain untouched. Less code equals less maintenance, and more decoupling of code gives better flexibility and extensibility.</p>
<p>More importantly: MVC is the Joomla standard, so if you&#8217;re building extensions for Joomla you should use MVC like the rest of us.</p>
<p><a name="references_and_footnotes"></a><br />
<h2>References &#038; further reading</h2>
<ol>
<li><a href="http://www.martinfowler.com/eaaDev/uiArchs.html">GUI Architectures</a>, by Martin Fowler</li>
<li><a href="http://www.slideshare.net/onesterov/joomla-extensions-kung-fu">Joomla Extension Kung Fu</a>, presentation by Oleg Nesterov given at J and Beyond 2010</li>
<li><a href="http://www.slideshare.net/HermanPeeren/design-patterns-illustrated">Design patterns illustrated</a>, presentation by Herman Peeren given at J and Beyond 2010</li>
<li><a href="http://www.codinghorror.com/blog/2008/05/understanding-model-view-controller.html">Understanding Model-View-Controller,</a> by Jeff Atwood</li>
<li><a href="http://blog.astrumfutura.com/archives/373-The_M_in_MVC_Why_Models_are_Misunderstood_and_Unappreciated.html">The M in MVC: Why Models are Misunderstood and Unappreciated</a>, by Pádraic Brady</li>
<li><a href="http://publib.boulder.ibm.com/infocenter/adiehelp/v5r1m1/index.jsp?topic=/com.ibm.etools.struts.doc/topics/cstrdoc020.html">Benefits of the MVC design pattern</a>, by the IBM Corporation</li>
<li><a href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller">Wikipedia article on MVC</a>, which clearly states that MVC was coined by a Norwegian guy, so you&#8217;re obviously in good hands here! :)</li>
<li><a href="http://c2.com/cgi/wiki?PatternsForBeginners">Patterns for beginners</a>, by Falk Bruegmann</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.torkiljohnsen.com/2010/07/17/mvc-explained-with-benefits-and-examples/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>What is this Nooku Framework thing really? And why should I care?</title>
		<link>http://www.torkiljohnsen.com/2010/07/15/what-is-nooku-framework-and-why-should-i-care/</link>
		<comments>http://www.torkiljohnsen.com/2010/07/15/what-is-nooku-framework-and-why-should-i-care/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 00:43:21 +0000</pubDate>
		<dc:creator>tj</dc:creator>
				<category><![CDATA[joomla]]></category>
		<category><![CDATA[Nooku]]></category>

		<guid isPermaLink="false">http://www.torkiljohnsen.com/?p=146</guid>
		<description><![CDATA[Let me try to explain, in non-technical terms, what a framework is and why using the Nooku Framework is a good idea. Preface No, not &#8220;preface&#8221; as in &#8220;this is the start of a long and boring novel&#8221;. It&#8217;s just two quick preliminary pieces of information that you need to be aware of: Nooku Framework [...]]]></description>
			<content:encoded><![CDATA[<p>Let me try to explain, in non-technical terms, what a framework is and why using the Nooku Framework is a good idea.<br />
<span id="more-146"></span></p>
<h2>Preface</h2>
<p>No, not &#8220;preface&#8221; as in &#8220;this is the start of a long and boring novel&#8221;. It&#8217;s just two quick preliminary pieces of information that you need to be aware of:</p>
<ol>
<li>Nooku Framework is not to be confused with <a href="http://www.nooku.org/content.html">Nooku Content</a>. Nooku Content is more a competitor of <a href="http://joomfish.net">Joom!Fish</a>: It&#8217;s a Joomla component used for translating content. Nooku Content is also distributed only among paying partners in a partner programme. Nooku Framework however, is a programming framework, and it&#8217;s free and open source software (FOSS). Both products are backed by the same developers though, hence the similar names.</li>
<li>When I say framework, I really mean <em>software framework</em>, a term which Wikipedia <a href="http://en.wikipedia.org/wiki/Software_framework">defines and explains</a> really nicely. But don&#8217;t click that Wikipedia link for now. Instead, let <strong>me</strong> give you the short story, from a Joomla perspective:</li>
</ol>
<h2>What is a framework?</h2>
<p>A framework allows you to reuse common programming code, which is a good thing. Let me explain why by comparing a framework to something a lot easier: Your e-mail signature. In your e-mail software, like Outlook or Apple Mail, you write your e-mail signature once in your settings, then automatically use it whenever you send an e-mail. </p>
<p>This means:</p>
<ul>
<li>You spend less time writing your e-mail.</li>
<li>Time saved means you have more time to do what&#8217;s important: Focusing on the contents of your e-mail.</li>
<li>You get the signature right each time; In a stressful situation you might forget to include your phone number or even type your name incorrectly, but not when you&#8217;re using a predefined signature.</li>
</ul>
<p>The same thing goes for software frameworks from a programmer&#8217;s perspective:</p>
<ul>
<li>It saves you time by eliminating the need to do repetitive tasks, which means you can focus on what&#8217;s important: Finishing the application and making sure it meets the requirements.</li>
<li>You get less bugs in your system, because the parts handled by the framework have been used and tested earlier, and are usually  bug free. So the more framework code you use, the less bugs you should experience. More time saved.</li>
<li>An added bonus: A framework with multiple users allows people to find bugs together, in their shared, common code.</li>
</ul>
<h2>So what&#8217;s the difference between Nooku, Joomla and the Gantry Frameworks?</h2>
<p>I see many people asking this question, so I just had to answer it once and for all:</p>
<p>Nooku and Joomla try to accomplish the same thing: To make developing Joomla <em>components</em>, <em>plugins</em> and <em>modules</em> easier. This is primarily stuff happening under the hood you might say. <a href="http://www.gantry-framework.org/">Gantry</a> is a framework made by Rockettheme to make developing <em>templates</em> easier, which is more the facade of your website. </p>
<p>In other words, you can&#8217;t compare Gantry to the other two. Instead you should compare Gantry to the <a href="http://www.prothemer.com/morph/">Morph</a> Framework, which is rumoured to be Nooku based in the future, but that&#8217;s a whole different story.</p>
<h2>Why do I prefer Nooku Framework over Joomla&#8217;s own framework then?</h2>
<p>I have been a part of the Mambo/Joomla community since 2004, and I have written components both using the Joomla Framework and the Nooku Framework. So I have tried and tested both, and have decided to use Nooku for the following reasons:</p>
<ul>
<li><strong>It&#8217;s better.</strong> For me as a programmer. It reduces the amount of code I need to write by something close to 80%<sup><a href="#footnote1">1</a></sup>, which means more time for me to spend on creating new and cool stuff, and less bugs for you to get annoyed over. The only two programmers that I know of that have looked into Nooku and still decided they preferred the Joomla Framework, have been <abbr title="Open Source Matters">OSM</abbr> employees. I.e. the guys who are paid to develop the Joomla Framework.</li>
<li><strong>It makes me better.</strong> Nooku reuses solutions to common problems (called using design patterns) to a greater extent, and <a href="http://www.torkiljohnsen.com/2010/07/11/the-joomla-database-schema-smells/">unlike Joomla</a> it forces me to adhere to conventions and standards. No slacking around in other words. The predictability in the coding combined with strict data filtering gives my components easier extensibility and my clients better security. I&#8217;ve recently also started using HMVC, and I&#8217;m loving it.</li>
<li><strong>It&#8217;s Joomla compatible.</strong> Any Joomla website that needs custom functionality can start using Nooku to build that functionality, today. It installs like any other extension, and does not interfere with what&#8217;s already on your Joomla site and using the Joomla Framework.</li>
<li><strong>It&#8217;s cheaper.</strong> I know; too obvious. Less time spent programming + Less bugs = Lower development and maintenance costs.</li>
<li><strong>It&#8217;s the second generation.</strong> Yes, literally the second generation. You may now know, but both the Joomla and  Nooku Frameworks were built basically by the same guy: <a href="http://johan.janssens.me">Johan Janssens</a>. In fact, Johan is <a href="https://www.ohloh.net/p/joomla/contributors">still considered to be the largest contributor</a> to the Joomla codebase (by far!), even though he stopped working with Joomla in January 2008. He took with him the knowledge and lessons learned, and started from scratch to build something better: Nooku.</li>
<li><strong>It&#8217;s got a developer community.</strong> Unlike Joomla, development at the framework level is moving forward at a rapid pace, there is lots of activity, and developers are sharing and contributing code between themselves. In the web development industry, things are moving forward very quickly, and for the sake of myself and my clients, I need to keep up and stay sharp.</li>
</ul>
<p>So I choose Nooku.</p>
<p>If you&#8217;re a programmer yourself, go check it out at <a href="http://www.nooku.org/framework.html">http://www.nooku.org/framework.html</a>. If not, you should talk to whoever does the programming for you and make sure that they do.</p>
<h4>Footnotes</h4>
<ol>
<li><a name="footnote1"></a>The 80% figure is borrowed from <a href="http://nekkidninjas.com/index.php/2009/10/12/ninjaboard-countdown-to-launch-day-6">NinjaBoard&#8217;s comparison</a>. This, though, dates back to October 2009, after which the Nooku Framework has improved further, so the number should probably be higher than 80%.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.torkiljohnsen.com/2010/07/15/what-is-nooku-framework-and-why-should-i-care/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>The Joomla database schema smells</title>
		<link>http://www.torkiljohnsen.com/2010/07/12/the-joomla-database-schema-smells/</link>
		<comments>http://www.torkiljohnsen.com/2010/07/12/the-joomla-database-schema-smells/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 20:28:16 +0000</pubDate>
		<dc:creator>tj</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[joomla]]></category>

		<guid isPermaLink="false">http://www.torkiljohnsen.com/?p=117</guid>
		<description><![CDATA[Back in 2006 I was a member of the standards and guidelines workgroup in Joomla, and during my involvement there I produced the Joomla 1.5 database schema as a DB Designer EER diagram, so people could view the database in a visual way. I recently also set up the Joomla 1.6 database schema, this time [...]]]></description>
			<content:encoded><![CDATA[<p>Back in 2006 I was a member of the standards and guidelines workgroup in Joomla, and during my involvement there I produced the <a href="http://www.torkiljohnsen.com/2006/04/30/joomla-15-database-schema/">Joomla 1.5 database schema</a> as a DB Designer EER diagram, so people could view the database in a visual way. I recently also set up the <a href="http://www.torkiljohnsen.com/2010/07/11/joomla-1-6-database-schema/">Joomla 1.6 database schema</a>, this time using MySQL Workbench which is a better tool for the job, and also GPL and available on multiple platforms. During my work with setting up the 1.6 schema, I came across lots of oddities and lacks of normalization, and a severe lack of naming conventions and guidelines became obvious.<br />
<span id="more-117"></span></p>
<h2>Improvement suggestions</h2>
<p> I have listed a few of these below, and please add comments to this post if you find some of your own or you disagree with me, and I&#8217;ll adjust this list accordingly.</p>
<h3>Naming conventions</h3>
<p>I primarily want to address the lack of standards in this schema, <a href="http://forum.joomla.org/viewtopic.php?p=298129#p298129">which I even reported back as early as in 2006 when creating the 1.5 schema</a>. In coding, the concept of <a href="http://en.wikipedia.org/wiki/Convention_over_configuration">convention over configuration</a> gives predictability, simplicity and reduces the amount code you have to write later on. Same goes for database schemas and Joomla: The better the schemas follow the naming conventions, the less PHP code you&#8217;ll have to write later on. Convention also eliminates ambiguity, and developers won&#8217;t be <a href="http://www.python.org/dev/peps/pep-0020/">tempted into guessing</a>. Just <em>having</em> a convention for column names in the database would be a nice first step, both for Joomla and 3rd party developers alike. Right now, column names for instance are a sweet mix of abbreviations and non-abbreviations, both underscored and camelCased names. Plus, the column <em>id</em> is used to name most INT primary key names but not all.</p>
<p><strong>A prime example of Joomla&#8217;s lack of conventions</strong> can be seen in the <em>content</em> table, where we have these five foreign key columns: <em>catid</em>, <em>sectionid</em>, <em>language</em>, <em>checked_out</em> and <em>asset_id</em>. The first is abbreviated with no underscore, the second is also without underscore but not abbreviated, the third does not look like a foreign key because it has no &#8220;id&#8221; in it&#8217;s name like the others, but it holds the language code for the article, and thus references language.lang_code (Who would have known?). The fourth contains has no &#8220;id&#8221;-hint, and no hint to the fact that it refers to users.id. Finally, the fifth column is not abbreviated but with underscores (the way I like it personally). Five different naming conventions in one single table, if we should at all should acknowledge &#8220;checked_out&#8221; as some sort of readable standard foreign key for <em>user.id</em>. </p>
<p><strong>Also check out</strong> and compare <em>content.created_by</em> and <em>categories.created_user_id</em>. They both reference the same column. Weird huh? See the lack of convention? Which format do you prefer?</p>
<h3>Table names</h3>
<p>For consistency, I would propose changing using plural names on tables. Just a little something I got used to while using <a href="http://nooku.org">Nooku</a>. Most tables are already pluralised, and tables normally contain multiple rows, so it makes most sense to use pluralisation as the standard and thus renaming the following tables:</p>
<ol>
<li>content renamed to <em>contents</em></li>
<li>content_frontpage renamed to <em>contents_frontpage</em></li>
<li>content_rating renamed to <em>contents_ratings</em></li>
<li>menu renamed to <em>menus</em></li>
<li>modules_menu renamed to <em>modules_menus</em></li>
<li>session renamed to <em>sessions</em></li>
</ol>
<h3>Primary keys</h3>
<p>Primary keys are important, as they are used for row identification, and will therefore play a big part in the PHP code we write for our applications and extensions.</p>
<h4>Names</h4>
<p>Most tables have a primary key column named &#8220;id&#8221;, but not all tables follow this rule. The languages table has lang_id, update_sites has update_site_id, update_categories has categoryid, etc. In other words: Lots of inconsistensies and no clear naming convention. </p>
<p>Nooku is a good example of a framework that imposes a convention which allows the PHP-code to interpret the database structure automatically, and only requires you to write code for those few special cases that don&#8217;t fit the blueprint at all. Nooku uses the following convention for primary key names: <em>componentname_tablename_id</em>. For the articles table in <em>com_content</em>, the Nooku table name would have been <em>content_articles</em>, and the primary key would have been <em>content_article_id</em>. Notice the plural formed table name and the singular column name. Logical, since the table represents a collection of items, and the column identifies a single one.</p>
<p>Next, I would wish for the foreign keys to also use the full name of the column they are referencing. So instead of those abbreviated catid columns all over the place, you use for instance category_id.</p>
<h4>Field types</h4>
<p>A lot of the tables have an auto increment INT type of primary key, which is to be expected, but there is no clear standard as to what datatype this field should be. Some are unsigned, some are not, some are INT, some are INT(10) and some INT(11). There is no reason why these should not just follow a common standard.</p>
<h4>The INT key sickness</h4>
<p>Very often you will find yourself using a primary key column for your table named something_id, and it will have the field type in the shape of a large integer. This is typical for relational databases, so don&#8217;t be alarmed, but don&#8217;t stop thinking either. The primary key in a table is something that can uniquely identify each and every record in that table. If you already have such a column, then there is no need to add another integer. </p>
<p>Consider these examples from the Joomla database:</p>
<p>The <strong>language</strong> table has a lang_id INT(11) column. This really seems redundant, as the lang_code field, CHAR(7), uniquely identifies the language just fine. In the menu table, and all other tables using multilingual features, you have the column <em>language</em> which is also a CHAR(7), and references lang_code. It&#8217;s weird, and bad code, to use a foreign key to reference a column that&#8217;s not a primary key, and not even unique. It&#8217;s also hard to see the connection from <em>menu.language</em> to <em>languages.lang_code</em> too. As before: Consistent naming would really help; why not call it menu.lang_code instead?</p>
<p>Similarly, in the <strong>redirect links</strong> table, the old_url-field is what really should identify redirect links. You can&#8217;t have multiple redirects for one old url, hence every row in this table is uniquely identified by it&#8217;s old_url column, so that should be the table redirect_links&#8217; primary key. Consequently, the id INT field seems redundant here too.</p>
<h2>An oddity: ACL</h2>
<p>Viewlevels are in the database connected to usergroups via JSON-encoded data in the column <em>viewlevel.rules</em>. The column name is misleading, but it is even more strange to see foreign keys stacked up in a pure JSON-encoded field like this, instead of for instance creating a table for <em>usergroups_viewlevels</em>, to connect the <em>usergroups</em> and <em>viewlevels</em> tables, similar to for instance <em>modules_menu</em>, which connect modules to menu items.</p>
<p>There is probably an explenation here, and it probably got something to do with performance, pragmatism or laziness. I just think it&#8217;s bad database design, that&#8217;s all. Maybe someone out there, who has been deep into the ACL system, can explain this to me?</p>
<h2>Also strange: Extension update sites</h2>
<p>This part of the database seems incomplete and unfinished, even though this schema is supposed to be a beta. For instance the <em>update_sites_extensions</em> table allows null values in it&#8217;s two fields <em>extension_id</em> and <em>update_site_id</em>, and a unique key is nowhere to be found in the table. This might just not be a feature due for Joomla 1.6, but then I would not see the reason for introducing these tables in the first place.</p>
<h2>Other things</h2>
<p>There are so many other things, but I can&#8217;t be bothered to write them all down. I actually started writing a section in this article about recommendations for normalization, changes in column names, types and usages, but the list already had six elements before I was finished going through two of the ten or twelve large tables in this schema.</p>
<p>This database schema suffers because of legacy issues, and a parts of it probably dates back even as far as the Mambo days. You can really see the same things happening in the user interface. Or should I say not happening? Instead of being a constantly renewed, improved and refactored CMS and framework, Joomla bears both the visual and codewise smell of patchwork and old legacy code. </p>
<p>Because of the obvious lack of progress in the Joomla project, I fear that this will be the last database schema for Joomla I will make; The web world is moving forward, but Joomla seems to be stuck. We strive to provide our clients and ourselves with the best tools of the trade, and that&#8217;s what I&#8217;ll keep doing. I hope I am proven wrong.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.torkiljohnsen.com/2010/07/12/the-joomla-database-schema-smells/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Joomla 1.6 database schema</title>
		<link>http://www.torkiljohnsen.com/2010/07/11/joomla-1-6-database-schema/</link>
		<comments>http://www.torkiljohnsen.com/2010/07/11/joomla-1-6-database-schema/#comments</comments>
		<pubDate>Sun, 11 Jul 2010 17:40:43 +0000</pubDate>
		<dc:creator>tj</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[joomla]]></category>

		<guid isPermaLink="false">http://www.torkiljohnsen.com/?p=73</guid>
		<description><![CDATA[As some might remember I made a visual representation of the Joomla 1.5 database schema back in 2006. I have now set up an EER representation of the Joomla 1.6 database schema too, that you can download for free. This schema was made after the 1.6 beta 2 release, and it was built using MySQL [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.torkiljohnsen.com/wp-content/uploads/2010/07/joomla_1.6_database_schema.png"><img src="http://www.torkiljohnsen.com/wp-content/uploads/2010/07/joomla_1.6_database_schema-150x150.png" alt="joomla 1.6 database schema thumbnail" title="joomla 1.6 database schema thumbnail" width="150" height="150" style="float:right; margin-left: 20px;" class="size-thumbnail wp-image-120" /></a>As some might remember I made a visual representation of the <a href="http://www.torkiljohnsen.com/2006/04/30/joomla-15-database-schema/">Joomla 1.5 database schema</a> back in 2006. I have now set up an EER representation of the Joomla 1.6 database schema too, that you can download for free. This schema was made after the 1.6 beta 2 release, and it was built using <a href="http://wb.mysql.com/">MySQL Workbench</a>, which is both GPL and available as a free download for multiple platforms.<br />
<span id="more-73"></span><br />
First of all: If you find any errors in this schema, make sure you leave a comment for me at the bottom. Because of the lack of conventions for naming primary key columns, I am left to do a lot of guesswork here when drawing up table relations, so there may be errors. Pretty much the only table that&#8217;s easy to read is the menu table, which has descriptive column comments. Make sure you read the notes below the download links too.</p>
<p><strong>Update: </strong>With the release of 1.6 beta 5, I just did a diff between the schema for 1.6 beta 2 and 1.6 beta 5, and they are identical.</p>
<p><strong>DOWNLOAD available in different formats:</strong></p>
<ul>
<li><a href="http://www.torkiljohnsen.com/wp-content/uploads/2010/07/joomla_1.6_database_schema.mwb">MySQL Workbench format (.mwb), 90 kB</a> needs <a href="http://wb.mysql.com/">MySQL Workbench</a> to use.</li>
<li><a href="http://www.torkiljohnsen.com/wp-content/uploads/2010/07/joomla_1.6_database_schema.png">PNG format, 2652 * 2658 pixels, 800 kB</a></li>
<li><a href="http://www.torkiljohnsen.com/wp-content/uploads/2010/07/joomla_1.6_database_schema.pdf">PDF format, 1 MB</a></li>
<li><a href="http://www.torkiljohnsen.com/wp-content/uploads/2010/07/joomla_1.6_database_schema.svg">SVG format, 2 MB, to view directly in modern browsers</a></li>
</ul>
<h2>Schema modifications</h2>
<p>Here are some modifications that <u>I personally have done</u> in various places in the schema to be able to reproduce it visually in MySQL Workbench, and make it more readable. This does mean that that <u>this schema is not 100% identical</u> to an actual Joomla 1.6 installation, because of these changes. For instance it also has foreign key relations drawn in, whereas MySQL&#8217;s MyISAM tables don&#8217;t support those. This schema should therefore only be used as a visual supplement to Joomla development.</p>
<p>Here are the changes that makes this schema differ from an actual Joomla 1.6 installation:</p>
<h3>Invisible relations</h3>
<p>This is not something I have changed, but something I deliberately did not touch. For claritys sake, some foreign relations to the users table have been left out. For instance created_by, modified_by, locked_by, created_user_id, modified_user_id and checked_out all reference the field <em>users.id</em>. If I was to set up all these relations, the schema would become so crowded with relationship indicators that it would be virtually unreadable.</p>
<p>There is also a &#8220;relation&#8221; here between the tables viewlevels and usergroups, but that&#8217;s not solved in SQL: All usergroups that belong to a viewlevel are put into an array that is JSON encoded and stored in the <em>viewlevel.rules</em> field. This is not a foreign key in SQL, so the relation is not show in the schema.</p>
<h3>Changed column types</h3>
<p>If a column is referencing another column in the database (like a foreign key), these columns need to be the same datatype. A lot of the time, this is not the case in Joomla, for some strange reason. To represent real foreign key relations in MySQL Workbench, this needed to be changed, or else <abbr title="MySQL Workbench">MWB would not even allow the relations to be made at all. We have had issues like these all the way back since Joomla 1.0. Hopefully they are picked up and fixed soon, because fixing this should not be a problem for backwards compatibility. </p>
<p>Here are the columns I have had to change:</p>
<ol>
<li>modules_menu.moduleid has been changed from an INT to an INT(11), since it references modules.id</li>
<li>In two places, asset_id foreign key was of datatype INT, but referencing asset.id it should have been INT(10), so those foreign key relations have changed, and this affects the following tables; categories, content</li>
<li>Similar to asset_id, catid columns were also of datatype INT, whereas they should have been INT(11) since they are referring to categories.id, which is an INT(11). This occured in the following tables: banners, contact_details, content, newsfeeds, weblinks</li>
<li>user_usergroup_map.user_id, messages_cfg.user_id, messages.user_id_from, messages_user_id_to all reference user.id, hence they can&#8217;t be an unsigned INT, but has to be a signed INT.</li>
<li>Multiple occurences of user_id references user.id, so they must be INT, not INT(11). This affects the following tables: user_profiles, session (although the field is named <em>userid</em> in the session table, without the underscore).</li>
<li>schemas.extension_id has been changed from INT(11) to INT, since it references extensions.extension_id</li>
<li>update_sites_extensions.update_site_id changed from INT to INT(11), since it references update_sites.update_site_id, which is an INT(11). Both columns in update_sites_extensions got a NOT NULL attribute added, since they make no sense without it.</li>
</ol>
<h3>Changed column ordering</h3>
<p>Column ordering in some tables has been changed so that foreign keys are listed just below primary keys, as I feel that this is cleaner and makes the relations easier to read. The changes were so many that I gave up trying to write a complete list.</p>
<p>All in all, this schema badly needs an overhaul, to say it mildly. I have written a short blog post explaining <a href="http://www.torkiljohnsen.com/2010/07/11/the-joomla-database-schema-smells/">why I think the Joomla database schema smells</a>.</abbr></p>
]]></content:encoded>
			<wfw:commentRss>http://www.torkiljohnsen.com/2010/07/11/joomla-1-6-database-schema/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Installing Phing on MAMP (Mac OSX)</title>
		<link>http://www.torkiljohnsen.com/2009/04/06/installing-phing-on-mamp-mac-osx/</link>
		<comments>http://www.torkiljohnsen.com/2009/04/06/installing-phing-on-mamp-mac-osx/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 09:54:38 +0000</pubDate>
		<dc:creator>tj</dc:creator>
				<category><![CDATA[Php]]></category>
		<category><![CDATA[Web apps]]></category>
		<category><![CDATA[joomla]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[mamp]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[pear]]></category>
		<category><![CDATA[phing]]></category>

		<guid isPermaLink="false">http://www.torkiljohnsen.com/2009/04/06/installing-phing-on-mamp-mac-osx/</guid>
		<description><![CDATA[Just bumped into Phing, and thought I&#8217;d share my experiences. Installing Phing is easy enough. Phing is a build system in the shape of a PHP Pear package, that can do many things. To quote Hans Lillelid, this could include for instance configuring, packaging, uploading and testing. Ideal for building installable Joomla zip-files, which is [...]]]></description>
			<content:encoded><![CDATA[<p>Just bumped into Phing, and thought I&#8217;d share my experiences. Installing Phing is easy enough. Phing is a <em>build</em> system in the shape of a PHP Pear package, that can do many things. To quote <a href="http://www.slideshare.net/hozn/phing-building-with-php">Hans Lillelid</a>, this could include for instance configuring, packaging, uploading and testing. Ideal for building installable Joomla zip-files, which is what I am using it for right now.<br />
<span id="more-70"></span><br />
This is how I set up Phing to run on my local MAMP-based webserver. MAMP = Apache, MySQL and PHP, on a Mac, much like WAMP and LAMP for Windows and Linux respectively. </p>
<p>These are just very brief instructions, specifically on how I did this on my own system. A complete documentation on Phing can be found on at <a href="http://phing.info/docs/guide/current/">phing.info</a>. You don&#8217;t actually need MAMP either, it was just what I was working with to begin with. </p>
<p>Open the application Terminal. You can find pear by doing a locate call: locate pear.<br />
Currently MAMP requires you to install it into /Applications, so you should find pear (for php5) here: /Applications/MAMP/bin/php5/bin/.<br />
Make sure MAMP is using the correct php version, by starting MAMP and checking your preferences.</p>
<p>1: Go to the correct folder:<br />
cd /Applications/MAMP/bin/php5/bin/</p>
<p>2: Make sure pear can locate the package:<br />
./pear channel-discover pear.phing.info</p>
<p>3: Install phing:<br />
./pear install phing/phing</p>
<p>Phing should now be installed. Run the command &#8220;ls -al&#8221; and you should see phing in the same folder as pear.</p>
<p>You can now run this command:<br />
./phing -h<br />
This will give you an overview of the phing&#8217;s options. </p>
<p>From here you can for instance just run:<br />
./phing -f /path/to/your/build.xml</p>
]]></content:encoded>
			<wfw:commentRss>http://www.torkiljohnsen.com/2009/04/06/installing-phing-on-mamp-mac-osx/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Transferring Panic&#8217;s Coda to a new computer</title>
		<link>http://www.torkiljohnsen.com/2009/01/22/transferring-panics-coda-to-a-new-computer/</link>
		<comments>http://www.torkiljohnsen.com/2009/01/22/transferring-panics-coda-to-a-new-computer/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 09:06:21 +0000</pubDate>
		<dc:creator>tj</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.torkiljohnsen.com/2009/01/22/transferring-panics-coda-to-a-new-computer/</guid>
		<description><![CDATA[I am a huge fan of the lightweight code editor Coda, made by Panic. It is a combined code editor and FTP client that I frequently use during work hours. Probably the application I use the most, if you disregard Firefox. Today, Murphy&#8217;s law kicked in though; Just as we are approaching the deadline on [...]]]></description>
			<content:encoded><![CDATA[<p>I am a huge fan of the lightweight code editor Coda, made by Panic. It is a combined code editor and FTP client that I frequently use during work hours. Probably the application I use the most, if you disregard Firefox. Today, Murphy&#8217;s law kicked in though; Just as we are approaching the deadline on a large project, my laptop screen dies. For no good reason.</p>
<p><span id="more-69"></span> This is no crisis, we have spare computers, but having to set up all my needed Coda sites all over again would just be too much hassle. So I needed to transfer all Coda sites, stored passwords and I would prefer not having to purchase Coda all over again to use it on the old backup computer. </p>
<p>Coda also contains code snippets and plugins that really makes me work more effectively, and those would be alot of hassle for me to add manually. </p>
<p>So I googled a bit on how to do this, and this is what I did:</p>
<ol>
<li>I connected the old desktop computer to the laptop with a Firewire cable, and turned on the laptop. Immediately after pressing the power button, I press and hold &#8220;T&#8221; on the laptop. This will start the laptop in Target Disk Mode, making it function like a regular external harddrive.</li>
<li>I copied the Coda application from the Application folder on the laptop to the Application folder on the desktop computer. When trying to start Coda after this, it was like I had just downloaded the program: I had 15 days left on my trial period, and no sites in sight.</li>
<li>To transfer the Coda settings I copied ~/Library/Preferences/com.panic.Coda.plist from my laptop to the same folder on the desktop computer. ~/ stands for your home-folder, in /Users/yourname. This took care of all my Sites, but not their passwords.</li>
<li>Next I also copied ~/Library/Application Support/Coda from my laptop to the same folder on the desktop computer. This took care of all my plugins and stored code snippets</li>
<li>Last thing I needed was the passwords to all the sites stored in Coda. To do this I first opened the folder ~/Library/Keychains on my laptop. Here I duplicated the file &#8220;login.keychain&#8221; and renamed my copy &#8220;laptop.keychain&#8221;. I then copied this file over to the Desktop of the other computer. On the new computer I opened the application Keychain (from Applications/Utilities) and created a new keychain called laptop, which is stored in ~/Library/Keychains. I then replace this new keychain with the old one from the laptop, and tadaaaaa&#8230;</li>
</ol>
<p>All done! Both Coda, sites, passwords, plugins, code snippets and general happiness transferred from one computer to the other!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.torkiljohnsen.com/2009/01/22/transferring-panics-coda-to-a-new-computer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Turkey breast with herb cream and mashed potatoes</title>
		<link>http://www.torkiljohnsen.com/2008/11/18/turkey-breast-with-herb-cream-and-mashed-potatoes/</link>
		<comments>http://www.torkiljohnsen.com/2008/11/18/turkey-breast-with-herb-cream-and-mashed-potatoes/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 19:49:03 +0000</pubDate>
		<dc:creator>tj</dc:creator>
				<category><![CDATA[recipe]]></category>

		<guid isPermaLink="false">http://www.torkiljohnsen.com/2008/11/18/turkey-breast-with-herb-cream-and-mashed-potatoes/</guid>
		<description><![CDATA[I would normally not write about mashed potatoes, but I just had a really nice meal and I just have to write down this stuff before it is lost. It takes little time to prepare and tastes&#8230; well&#8230; extremely nice. Turkey breast: A 150 g turkey pr person is fine. Turkey breast has about zero [...]]]></description>
			<content:encoded><![CDATA[<p>I would normally not write about mashed potatoes, but I just had a really nice meal and I just have to write down this stuff before it is lost. It takes little time to prepare and tastes&#8230; well&#8230; extremely nice.<br />
<span id="more-68"></span><br />
<strong>Turkey breast:</strong><br />
A 150 g turkey pr person is fine. Turkey breast has about zero fat, so add more with a good concience! Chicken breast will do the trick too of course, but turkey is better in my opinion.<br />
To make up for the lack of fat in the turkey, use (a lot of) butter for the frying ;)<br />
Some salt and some lemon pepper seasoning.</p>
<p><strong>Mashed potatoes:</strong><br />
1 kg potatoes, should be enough for four people.<br />
2-3 dl milk. Use cream instead of half the milk for an even nicer mash. Yum!<br />
4-5 whole garlic cloves, or more if you want :)<br />
0,5 teaspoon ground nutmeg<br />
0,5 teaspoon dry mustard. I used dijon mustard though, and it worked like a charm.<br />
50-70 g butter<br />
Some salt, white pepper</p>
<p><strong>Herb cream</strong><br />
200 g feta cheese<br />
4 tablespoons crÃ¨me fraÃ®che or quark (in Norwegian that&#8217;s &#8220;kesam&#8221; I think)<br />
1 garlic clove, grated<br />
1 tablespoon of chopped, fresh herbs, like oregano or basil. Rosemary should also be nice, especially with turkey.</p>
<p>Herb cream:<br />
Mash the feta cheese and stir in the crÃ¨me fraÃ®che, garlic and herbs. It&#8217;s done! Just let it rest in your fridge while you make the rest. I love the herb cream cold with the other hot parts of this meal. </p>
<p>Mash:<br />
Chop the potatoes into small cubes, boil them until they are soft and ready to be mashed. Fry the garlic cloves in butter on low heat, to soften them up and make them a bit milder. Mash the potatoes and mash the garlic in with a garlic squeezer or by squeezing it through a sieve. To get a real feeling of home made mash I like to mash the potatoes by hand and not mash them too thoroughly either. Add the butter you used for the garlic and add some more butter if you like. (I won&#8217;t tell!). Add the milk little by little, so that you don&#8217;t make potato soup! Put in the nutmeg, mustard, salt and pepper as you see fit.</p>
<p>Turkey:<br />
Nice amount of butter in the pan is required. Low heat to begin with to avoid burning the turkey on the outside and leaving it raw in the center. Turn up the heat towards the end to make the surface more crispy. Season as you go along, and use a spoon to pour excess butter over the top of the turkey breasts.</p>
<p>Serving:<br />
Put the turkey on the platters, quickly add some water to the frying pan while it is still hot to get some extra gravy. Stir the water a bit and distribute the gravy over the turkey breasts. Put a nice pile of mash on the platter and decorate it with some fresh herbs. Add the herb cream on top of the turkey or on the side. Either way it should taste really nice.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.torkiljohnsen.com/2008/11/18/turkey-breast-with-herb-cream-and-mashed-potatoes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.626 seconds -->
