<?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>Vladimir Cvetic &#187; MySQL</title>
	<atom:link href="http://www.hazaah.com/cat/databases/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hazaah.com</link>
	<description>buffle the world</description>
	<lastBuildDate>Thu, 12 Nov 2009 14:30:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Always fresh: Sql list of countires</title>
		<link>http://www.hazaah.com/programming/always-fresh-sql-list-of-countires/</link>
		<comments>http://www.hazaah.com/programming/always-fresh-sql-list-of-countires/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 11:01:49 +0000</pubDate>
		<dc:creator>Vladimir Cvetic</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Something Else]]></category>
		<category><![CDATA[countries list]]></category>
		<category><![CDATA[fresh countries list]]></category>
		<category><![CDATA[iso countries]]></category>
		<category><![CDATA[mysql countires list]]></category>
		<category><![CDATA[sql countires list]]></category>
		<category><![CDATA[up to date countries list]]></category>

		<guid isPermaLink="false">http://www.hazaah.com/?p=70</guid>
		<description><![CDATA[Since my last post with updated list of countries in MySQL format was so well received I decided to go even further and write a parser script so you can always get fresh countries list.
Every time you download sql countries list it will be up to date for that very minute. This is because it [...]]]></description>
			<content:encoded><![CDATA[<p>Since my last post with updated list of countries in MySQL format was so well received I decided to go even further and write a parser script so you can always get fresh countries list.</p>
<p>Every time you <a href="/download/countries.sql.php">download</a> sql countries list it will be up to date for that very minute. This is because it is fetched and parsed from ISO.org just for your pleasure, every time you download (well if you don&#8217;t mind a bit of caching :P)</p>
<div style="border:1px solid #ccc;padding:6px;">
Enough talk&#8230; <a href="/download/countries.sql.php"><strong>Download</strong></a> MySQL countries list.
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.hazaah.com/programming/always-fresh-sql-list-of-countires/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Up to date sql list of countries &#8211; 31-07-2008</title>
		<link>http://www.hazaah.com/programming/up-to-date-sql-list-of-countries-31-07-2008/</link>
		<comments>http://www.hazaah.com/programming/up-to-date-sql-list-of-countries-31-07-2008/#comments</comments>
		<pubDate>Thu, 31 Jul 2008 08:52:58 +0000</pubDate>
		<dc:creator>Vladimir Cvetic</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[countries list]]></category>
		<category><![CDATA[mysql countries list]]></category>
		<category><![CDATA[sql countries]]></category>
		<category><![CDATA[up to date countries list]]></category>

		<guid isPermaLink="false">http://www.hazaah.com/?p=68</guid>
		<description><![CDATA[Just collected list of countries and formatted it into MySQL form&#8230; well nothing much but I bet it will be useful to someone out there. Well enjoy: Countries List SQL download

Even fresher SQL Countries list&#8230; here.

]]></description>
			<content:encoded><![CDATA[<p>Just collected list of countries and formatted it into MySQL form&#8230; well nothing much but I bet it will be useful to someone out there. Well enjoy: <a href="http://hazaah.com/download/countries.sql.gz">Countries List SQL download</a></p>
<div style="border:1px solid #ccc;padding:6px;">
<a href="http://www.hazaah.com/programming/always-fresh-sql-list-of-countires/">Even fresher SQL Countries list&#8230; here.</a>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.hazaah.com/programming/up-to-date-sql-list-of-countries-31-07-2008/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Fulltext boolean search on InnoDB</title>
		<link>http://www.hazaah.com/databases/fulltext-boolean-search-on-innodb/</link>
		<comments>http://www.hazaah.com/databases/fulltext-boolean-search-on-innodb/#comments</comments>
		<pubDate>Wed, 06 Dec 2006 14:41:39 +0000</pubDate>
		<dc:creator>Vladimir Cvetic</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.knowbies.com/vladimir-cvetic/something-else/fulltext-boolean-search-on-innodb/</guid>
		<description><![CDATA[On different MySQL table engines different rules apply. For example on MyIsam you can have Full Text indexes (thus enabling full text search) but you are giving up foreign keys.
I searched the way to get both on out-of-the-box mysql but failed (this can be enabled with use of sphinx mysql plugin). The best thing I [...]]]></description>
			<content:encoded><![CDATA[<p>On different MySQL table engines different rules apply. For example on MyIsam you can have Full Text indexes (thus enabling <a href="http://www.knowbies.com/vladimir-cvetic/databases/mysql/fulltext-search-mysql/">full text search</a>) but you are giving up <a href="http://www.knowbies.com/vladimir-cvetic/databases/2-deo-referencijalni-interitet-u-mysql-bazama-podataka/">foreign keys</a>.</p>
<p>I searched the way to get both on out-of-the-box mysql but failed (this can be enabled with use of <a href="http://www.sphinxsearch.com/">sphinx mysql plugin</a>). The best thing I could think of were triggers.</p>
<p><strong>What are triggers?</strong></p>
<p>Trigger is simple peace of sql code that is executed when predefined event happens. Most commonly they are used after insert or before insert.</p>
<p><strong>General Idea </strong></p>
<p>I we can&#8217;t have one table with full text and referential integrity then we need two tables one InnoDB and one MyIsam. It would be really stupid to create two identical tables, so I created new MyIsam table with only those columns I wanted to search and key which connects these two tables.<br />
After this I needed a After Insert Trigger to execute so both tables would have identical content. Problem with this is that MySQL introduced triggers in version 5, which is still considered to be an very exotic peace of software.</p>
<p>Here is a sample Before Insert trigger:</p>
<pre lang="sql" name="code">mysql&gt; CREATE TRIGGER test
-&gt; AFTER INSERT ON t
-&gt; FOR EACH ROW
-&gt; BEGIN
-&gt;   INSERT INTO test2 SET column1 = NEW.column1;
-&gt;   INSERT INTO test3 SET column1 = NEW.column1 + 4;
-&gt;   END;//
Query OK, 0 rows affected (0.00 sec)</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.hazaah.com/databases/fulltext-boolean-search-on-innodb/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How-to: Full text search in MySQL</title>
		<link>http://www.hazaah.com/databases/mysql/fulltext-search-mysql/</link>
		<comments>http://www.hazaah.com/databases/mysql/fulltext-search-mysql/#comments</comments>
		<pubDate>Wed, 29 Nov 2006 14:11:38 +0000</pubDate>
		<dc:creator>Vladimir Cvetic</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.knowbies.com/vladimir-cvetic/databases/mysql/fulltext-search-mysql/</guid>
		<description><![CDATA[MySQL has had FULLTEXT searching in one form or another since version 3.23.23. FULLTEXT indices in MySQL allow database administrators and programmers to designate any character-based field (CHAR, VARCHAR, or TEXT) as a FULLTEXT index, which allows for complex text searching against data stored in those fields.
This feature is not to be confused with the [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL has had FULLTEXT searching in one form or another since version 3.23.23. FULLTEXT indices in MySQL allow database administrators and programmers to designate any character-based field (CHAR, VARCHAR, or TEXT) as a FULLTEXT index, which allows for complex text searching against data stored in those fields.</p>
<p>This feature is not to be confused with the LIKE function in MySQL. LIKE works more along the lines of a regular expression. On the other hand, FULLTEXT indices are fully indexed fields which support stopwords, boolean searches, and relevancy ratings.</p>
<p><strong>How does it work ?</strong></p>
<p>Adding Full Text to your table is very easy it will remind you of adding regular keys or indexes. We will begin with creating a simple news table and fill it with some content:</p>
<pre lang="sql">CREATE TABLE news
(
ID INT(9) UNSIGNED NOT NULL DEFAULT '0' AUTO_INCREMENT,
title CHAR(255) NOT NULL DEFAULT '',
body TEXT NOT NULL DEFAULT '',
PRIMARY KEY (ID),
FULLTEXT(title,body)
);

INSERT INTO news
VALUES (1,
'Pellentesque mauris',
'Pellentesque mauris turpis, porta vel, euismod sed,
pulvinar vitae, tortor. Duis accumsan. Suspendisse facilisis blandit mauris.');

INSERT INTO news
VALUES (2,
'Mauris eu massa',
'Praesent varius orci sit amet erat. Suspendisse sed quam non sapien
consectetuer scelerisque. Aliquam mauris pede, vestibulum vitae,
dapibus vel, cursus at, sapien. Nullam vel purus sit amet quam placerat
suscipit.');

INSERT INTO news
VALUES (3,
'Cum sociis',
'Ut auctor eleifend magna. Morbi porttitor, felis nec accumsan
elementum, lectus justo interdum sapien, non volutpat felis est quis
felis. Vestibulum nulla.');

INSERT INTO news
VALUES (4,
'Quisque dolor!',
'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed sapien
nunc, feugiat et, ultrices eget, aliquam non, nulla. Cras mollis. Duis
eget eros. In mauris. Mauris purus massa, mollis at, malesuada in,
vulputate vitae, odio. Duis ut dolor. Phasellus id nunc non est dictum
porttitor.');</pre>
<p><strong>Getting results</strong></p>
<p>Now that we have filled our table with some news we can start doing some queries.</p>
<pre lang="sql">SELECT ID,title
FROM news
WHERE MATCH (title,body) AGAINST('sociis');</pre>
<p>Ok this is simplest full text search query. There are few things you must know tho.<br />
Columns in match() must always be the same ones that we defined as fulltext.</p>
<p>With fulltext you will get results sorted by their relevance aka score, lets display that score.</p>
<pre lang="sql">SELECT ID,title
FROM news
WHERE MATCH (title,body) AGAINST('sociis') as score;</pre>
<p>Using full text search doesn&#8217;t not forbid you to use other sql statements, for example limit etc.</p>
<p><strong>Boolean mode</strong></p>
<pre lang="sql">SELECT ID,title
FROM news
WHERE MATCH (title,body) AGAINST('+sed -mauris') as score;</pre>
<p>You can filter results given by searching with boolean query. Look at against(), you will notice + and &#8211; signs in front of keywords, + sign means that word will be included in search and minus sign means that all results containing this keyword will be excluded from search.</p>
<p>And at the end I must warn you that Full Text search is not supported on InnoDB table engine. (so referential integiry and full text don&#8217;t stack)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hazaah.com/databases/mysql/fulltext-search-mysql/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>2nd part Referential integrity with MySQL</title>
		<link>http://www.hazaah.com/databases/2-deo-referencijalni-interitet-u-mysql-bazama-podataka/</link>
		<comments>http://www.hazaah.com/databases/2-deo-referencijalni-interitet-u-mysql-bazama-podataka/#comments</comments>
		<pubDate>Tue, 14 Nov 2006 11:10:56 +0000</pubDate>
		<dc:creator>Vladimir Cvetic</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.knowbies.com/vladimir-cvetic/databases/2-deo-referencijalni-interitet-u-mysql-bazama-podataka/</guid>
		<description><![CDATA[In first part I talked about the basis of referential integrity, in this part I will go through few practical examples.
For start we will create on table that we will call â€˜newsâ€™ and then insert few rows
CREATE TABLE news (id TINYINT NOT NULL AUTO_INCREMENT,
title VARCHAR(50), body VARCHAR(255) NOT NULL, PRIMARY KEY(id)) ENGINE=INNODB;
Query OK, 0 rows [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://www.knowbies.com/vladimir-cvetic/databases/1-deo-referencijalni-integritet-u-mysql-bazama-podataka/">first part</a> I talked about the basis of referential integrity, in this part I will go through few practical examples.<br />
For start we will create on table that we will call â€˜newsâ€™ and then insert few rows</p>
<pre lang="sql">CREATE TABLE news (id TINYINT NOT NULL AUTO_INCREMENT,
title VARCHAR(50), body VARCHAR(255) NOT NULL, PRIMARY KEY(id)) ENGINE=INNODB;
Query OK, 0 rows affected (0.11 sec)

INSERT INTO novosti VALUES (1, 'Some title, 'Testing body'), (2, 'Another title', 'Again some body for news');
Query OK, 4 rows affected (0.06 sec)
Records: 4  Duplicates: 0  Warnings: 0</pre>
<p>To show example of referential integrity we will create another table called â€˜commentsâ€™</p>
<pre lang="sql">CREATE TABLE comments (
id INT(4) NOT NULL,
title VARCHAR(50) NOT NULL,
comment VARCHAR(255) NOT NULL,
id_news TINYINT(4) NOT NULL,
INDEX (id_news),
FOREIGN KEY (id_news) REFERENCES novosti (id),
PRIMARY KEY(id)
) ENGINE=INNODB;</pre>
<p>In table comments we defined foreign key id_news and referred it to id field in table news. I we tried to insert random rows in comments table it would look something like this:</p>
<pre lang="sql">INSERT INTO comments VALUES (1, 'Comment title', 'Some comment text', 91);
ERROR 1216 (23000): Cannot add or update a child row: a foreign key
constraint fails</pre>
<p><strong>Note: </strong>look at first and last value of this insert, note that it does not match any news so this comment would be just junk data.<br />
So we are protected on database level from junk data. Even tho this is highly recommended donâ€™t try to dump your application level validation, since you need error handling (so you users donâ€™t get ugly errors) and also mysql is not able to validate data for example E-mail addresses.</p>
<p>Hope it helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hazaah.com/databases/2-deo-referencijalni-interitet-u-mysql-bazama-podataka/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>1st part Referential integrity with MySQL</title>
		<link>http://www.hazaah.com/databases/1-deo-referencijalni-integritet-u-mysql-bazama-podataka/</link>
		<comments>http://www.hazaah.com/databases/1-deo-referencijalni-integritet-u-mysql-bazama-podataka/#comments</comments>
		<pubDate>Thu, 26 Oct 2006 09:12:57 +0000</pubDate>
		<dc:creator>Vladimir Cvetic</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.knowbies.com/vladimir-cvetic/opusteno/1-deo-referencijalni-integritet-u-mysql-bazama-podataka/</guid>
		<description><![CDATA[Click here for Part 2
MySQL is definitely the best choice for most web applications, for it&#8217;s speed and for it&#8217;s price (or lack of the same). This is the main reason that I am writing about what was the biggest flaw of mysql (in my book) for many years, Foreign keys.
Referential integrity is very important [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.knowbies.com/vladimir-cvetic/databases/2-deo-referencijalni-interitet-u-mysql-bazama-podataka/">Click here for Part 2</a></p>
<p>MySQL is definitely the best choice for most web applications, for it&#8217;s speed and for it&#8217;s price (or lack of the same). This is the main reason that I am writing about what was the biggest flaw of mysql (in my book) for many years, Foreign keys.</p>
<p>Referential integrity is very important part of database development. The term &#8220;Referential integrity&#8221; means that all referrals in database valid and that there are no invalid links between tables.</p>
<p>The state of referential integrity is most commonly achieved by using foreign keys. Like I mentioned mysql hasn&#8217;t supported foreign keys for very long time, mainly for the fear that it will negatively influence the speed. Recent versions support use of referential integrity through InnoDB table engine.</p>
<p>Few basic conditions need to be met so we can use referential integrity:</p>
<ol>
<li>Both tables must be InnoDB type</li>
<li>Both fields used must be indexed</li>
<li>Type of data must be similar of same</li>
</ol>
<p>In next part I will go through short example of creating two tables linked in referential integrity in mind.</p>
<p><a href="http://www.knowbies.com/vladimir-cvetic/databases/2-deo-referencijalni-interitet-u-mysql-bazama-podataka/">Click here for Part 2 </a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hazaah.com/databases/1-deo-referencijalni-integritet-u-mysql-bazama-podataka/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
