<?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 &#187; Databases</title>
	<atom:link href="http://www.torkiljohnsen.com/category/databases/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.torkiljohnsen.com</link>
	<description>My personal piece of cyberspace</description>
	<lastBuildDate>Mon, 28 Nov 2011 11:18:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<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>6</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>23</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>11</slash:comments>
		</item>
		<item>
		<title>MySQL connection (resource) management</title>
		<link>http://www.torkiljohnsen.com/2006/08/18/mysql-connection-resource-management/</link>
		<comments>http://www.torkiljohnsen.com/2006/08/18/mysql-connection-resource-management/#comments</comments>
		<pubDate>Fri, 18 Aug 2006 11:06:18 +0000</pubDate>
		<dc:creator>tj</dc:creator>
				<category><![CDATA[Content management]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.torkiljohnsen.com/2006/08/18/mysql-connection-resource-management/</guid>
		<description><![CDATA[Just came across a good article by Jay Pipes talking about lazy loading and caching of content. A nice read with some good code examples that I thought I should share with my fellow readers. Read Jays blog entry]]></description>
			<content:encoded><![CDATA[<p>Just came across a good article by Jay Pipes talking about lazy loading and caching of content. A nice read with some good code examples that I thought I should share with my fellow readers. <span id="more-41"></span></p>
<p><a href="http://jpipes.com/index.php?/archives/99-MySQL-Connection-Management-in-PHP-How-Not-To-Do-Things.html">Read Jays blog entry</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.torkiljohnsen.com/2006/08/18/mysql-connection-resource-management/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Search and replace in MySQL</title>
		<link>http://www.torkiljohnsen.com/2006/07/24/search-and-replace-in-mysql/</link>
		<comments>http://www.torkiljohnsen.com/2006/07/24/search-and-replace-in-mysql/#comments</comments>
		<pubDate>Mon, 24 Jul 2006 12:57:49 +0000</pubDate>
		<dc:creator>tj</dc:creator>
				<category><![CDATA[Databases]]></category>

		<guid isPermaLink="false">http://www.torkiljohnsen.com/2006/07/24/search-and-replace-in-mysql/</guid>
		<description><![CDATA[I recently had to help a friend go through a site and correct alot of wrong URLs. Here is an easy way to do search and replace in MySQL, for those of you who didn&#8217;t know. If you have phpMyAdmin you can use the SQL-tab to run this query. If not, you can run it [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had to help a friend go through a site and correct alot of wrong URLs. Here is an easy way to do search and replace in MySQL, for those of you who didn&#8217;t know.<span id="more-38"></span></p>
<p>If you have phpMyAdmin you can use the SQL-tab to run this query. If not, you can run it from the commandline as well. Here is the query I ran: (remember of course to replace table_name, column_name, find_this and replace_with_this with real data)</p>
<p><!--adsense#468artikkelbanner--></p>
<p><code>UPDATE table_name SET column_name = replace(column_name,"find_this","replace_with_this");</code></p>
<p>[tags]MySQL,databases,sql,query[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.torkiljohnsen.com/2006/07/24/search-and-replace-in-mysql/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

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

