<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Oracle Spaghetti</title>
	<atom:link href="http://oraghetti.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://oraghetti.wordpress.com</link>
	<description>Parla come mangi</description>
	<lastBuildDate>Fri, 09 Dec 2011 12:32:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='oraghetti.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Oracle Spaghetti</title>
		<link>http://oraghetti.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://oraghetti.wordpress.com/osd.xml" title="Oracle Spaghetti" />
	<atom:link rel='hub' href='http://oraghetti.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Have you read the news today?</title>
		<link>http://oraghetti.wordpress.com/2011/12/09/have-you-read-the-news-today/</link>
		<comments>http://oraghetti.wordpress.com/2011/12/09/have-you-read-the-news-today/#comments</comments>
		<pubDate>Fri, 09 Dec 2011 12:05:16 +0000</pubDate>
		<dc:creator>dmoraschi</dc:creator>
				<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://oraghetti.wordpress.com/?p=87</guid>
		<description><![CDATA[You may already know that Oracle has the capability to get data directly from the Web. Like in: SELECT HTTPURITYPE.createuri (&#8216;http://www.economist.com/rss/leaders_rss.xml&#8217;).getclob () RSS FROM DUAL; This offers a lot of possibilities when you need to query external data and, combined with some XML magic, can make a cute RSS view out of a well-formed xml <a href="http://oraghetti.wordpress.com/2011/12/09/have-you-read-the-news-today/" class="excerpt-more-link">[&#8230;]</a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oraghetti.wordpress.com&amp;blog=5415577&amp;post=87&amp;subd=oraghetti&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>You may already know that Oracle has the capability to get data directly from the Web. Like in:</p>
<p><strong>SELECT HTTPURITYPE.createuri (&#8216;http://www.economist.com/rss/leaders_rss.xml&#8217;).getclob () RSS FROM DUAL;</strong></p>
<p>This offers a lot of possibilities when you need to query external data and, combined with some XML magic, can make a cute RSS view out of a well-formed xml feed:</p>
<p><strong> CREATE VIEW RSS_READER</strong><br />
<strong>AS</strong><br />
<strong>   SELECT EXTRACTVALUE (VALUE (p), &#8216;/item/title&#8217;) title,</strong><br />
<strong>          EXTRACTVALUE (VALUE (p), &#8216;/item/link&#8217;) link_url,</strong><br />
<strong>          EXTRACTVALUE (VALUE (p), &#8216;/item/description&#8217;) description</strong><br />
<strong>     FROM TABLE (</strong><br />
<strong>             XMLSEQUENCE (EXTRACT (xmltype (HTTPURITYPE.createuri (&#8216;http://www.economist.com/rss/leaders_rss.xml&#8217;).getclob (),</strong><br />
<strong>                                            NULL,</strong><br />
<strong>                                            1,</strong><br />
<strong>                                            1),</strong><br />
<strong>                                   &#8216;/rss/channel/item&#8217;,</strong><br />
<strong>                                   &#8216;xmlns:media=&#8221;http://search.yahoo.com/mrss/&#8221;&#8216;))) p;</strong></p>
<p>Nice and cheap, no need to store data in the RDBMS. Every time you access the view the data is read from the Web. Just change the rss url according to your feed (you will probably need to rework the EXTRACT functions also).</p>
<p><em><strong>Note</strong></em>: if you&#8217;re on Oracle 11g you may have to grant connecttion to the rss feed domain thru&#8217; an ACL (ask your DBA for details&#8230;)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/oraghetti.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/oraghetti.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/oraghetti.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/oraghetti.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/oraghetti.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/oraghetti.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/oraghetti.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/oraghetti.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/oraghetti.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/oraghetti.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/oraghetti.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/oraghetti.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/oraghetti.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/oraghetti.wordpress.com/87/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oraghetti.wordpress.com&amp;blog=5415577&amp;post=87&amp;subd=oraghetti&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://oraghetti.wordpress.com/2011/12/09/have-you-read-the-news-today/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4f26dbe1a7a7963647e032058d979569?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=G" medium="image">
			<media:title type="html">Davide Moraschi</media:title>
		</media:content>
	</item>
		<item>
		<title>Playing with DATE ranges</title>
		<link>http://oraghetti.wordpress.com/2011/12/07/playing-with-date-ranges/</link>
		<comments>http://oraghetti.wordpress.com/2011/12/07/playing-with-date-ranges/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 14:49:30 +0000</pubDate>
		<dc:creator>dmoraschi</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[calendar]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[ETL]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://oraghetti.wordpress.com/?p=81</guid>
		<description><![CDATA[If you search on the net for a trick to generate date rangees in Oracle, you most probably will end up here: http://stackoverflow.com/questions/418318/generate-a-range-of-dates-using-sql variuos interesting and mind-challenging ways to achieve the same result. I found this way the most cost effective and readable, yet flexible enough for my datawarehouse ETL processes. WITH LIMITS AS (SELECT <a href="http://oraghetti.wordpress.com/2011/12/07/playing-with-date-ranges/" class="excerpt-more-link">[&#8230;]</a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oraghetti.wordpress.com&amp;blog=5415577&amp;post=81&amp;subd=oraghetti&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you search on the net for a trick to generate date rangees in Oracle, you most probably will end up here:</p>
<p><a href="http://stackoverflow.com/questions/418318/generate-a-range-of-dates-using-sql">http://stackoverflow.com/questions/418318/generate-a-range-of-dates-using-sql</a></p>
<p>variuos interesting and mind-challenging ways to achieve the same result.</p>
<p>I found this way the most cost effective and readable, yet flexible enough for my datawarehouse ETL processes.</p>
<p><strong>WITH LIMITS AS (SELECT TO_DATE (&#8217;01-JAN-2010&#8242;) BEGINDATE, SYSDATE + 10 ENDDATE FROM DUAL)</strong></p>
<p><strong>SELECT (BEGINDATE + LEVEL &#8211; 1) AS DATES</strong></p>
<p><strong>FROM LIMITS</strong></p>
<p><strong>CONNECT BY LEVEL &lt;= (ENDDATE &#8211; BEGINDATE)</strong></p>
<p>/</p>
<p>You can modify start and end date and have a calendar in one SQL pass. Let&#8217;s go a little further: I always have reports wich need to show the current week (WTD) for example:</p>
<p><strong>WITH LIMITS AS (SELECT TRUNC ( SYSDATE, &#8216;DY&#8217;) BEGINDATE, TRUNC (SYSDATE) ENDDATE FROM DUAL),</strong></p>
<p><strong>     CALENDAR</strong></p>
<p><strong>     AS (    SELECT (BEGINDATE + LEVEL &#8211; 1) AS DATES</strong></p>
<p><strong>               FROM LIMITS</strong></p>
<p><strong>         CONNECT BY LEVEL &lt;= (ENDDATE &#8211; BEGINDATE))</strong></p>
<p><strong>SELECT DATES, TO_CHAR ( DATES, &#8216;Dy&#8217;) DAYS_OF_WEEK</strong></p>
<p><strong>  FROM CALENDAR</strong></p>
<p>/</p>
<p>Easy way to retrieve a list of days in the current week until today. Fast, cost effective and easy to modify. And so on:</p>
<p>&#8211;Last full Week</p>
<p><strong>WITH LIMITS AS (SELECT TRUNC ( SYSDATE &#8211; 7, &#8216;DY&#8217;) BEGINDATE, TRUNC ( SYSDATE, &#8216;DY&#8217;) ENDDATE FROM DUAL),</strong></p>
<p><strong>     CALENDAR</strong></p>
<p><strong>     AS (    SELECT (BEGINDATE + LEVEL &#8211; 1) AS DATES</strong></p>
<p><strong>               FROM LIMITS</strong></p>
<p><strong>         CONNECT BY LEVEL &lt;= (ENDDATE &#8211; BEGINDATE))</strong></p>
<p><strong>SELECT DATES, TO_CHAR ( DATES, &#8216;Dy&#8217;) DAYS_OF_WEEK</strong></p>
<p><strong>  FROM CALENDAR</strong></p>
<p>/</p>
<p>&#8211;Same day last Week to Date</p>
<p><strong>WITH LIMITS AS (SELECT TRUNC (SYSDATE &#8211; 6) BEGINDATE, TRUNC (SYSDATE) ENDDATE FROM DUAL),</strong></p>
<p><strong>     CALENDAR</strong></p>
<p><strong>     AS (    SELECT (BEGINDATE + LEVEL &#8211; 1) AS DATES</strong></p>
<p><strong>               FROM LIMITS</strong></p>
<p><strong>         CONNECT BY LEVEL &lt;= (ENDDATE &#8211; BEGINDATE + 1))</strong></p>
<p><strong>SELECT DATES, TO_CHAR ( DATES, &#8216;Dy&#8217;) DAYS_OF_WEEK</strong></p>
<p><strong>  FROM CALENDAR</strong></p>
<p>/</p>
<p>&#8211;Last Month</p>
<p><strong>WITH LIMITS AS (SELECT TRUNC ( ADD_MONTHS ( SYSDATE, -1), &#8216;MONTH&#8217;) BEGINDATE, TRUNC (SYSDATE,&#8217;MONTH&#8217;) ENDDATE FROM DUAL),</strong></p>
<p><strong>     CALENDAR</strong></p>
<p><strong>     AS (    SELECT (BEGINDATE + LEVEL &#8211; 1) AS DATES</strong></p>
<p><strong>               FROM LIMITS</strong></p>
<p><strong>         CONNECT BY LEVEL &lt;= (ENDDATE &#8211; BEGINDATE))</strong></p>
<p><strong>SELECT DATES, TO_CHAR ( DATES, &#8216;Dy&#8217;) DAYS_OF_WEEK</strong></p>
<p><strong>  FROM CALENDAR</strong></p>
<p>/</p>
<p>&#8211;Year to Date</p>
<p><strong>WITH LIMITS AS (SELECT TRUNC ( SYSDATE, &#8216;YEAR&#8217;) BEGINDATE, TRUNC (SYSDATE) ENDDATE FROM DUAL),</strong></p>
<p><strong>     CALENDAR</strong></p>
<p><strong>     AS (    SELECT (BEGINDATE + LEVEL &#8211; 1) AS DATES</strong></p>
<p><strong>               FROM LIMITS</strong></p>
<p><strong>         CONNECT BY LEVEL &lt;= (ENDDATE &#8211; BEGINDATE + 1))</strong></p>
<p><strong>SELECT DATES, TO_CHAR ( DATES, &#8216;Dy&#8217;) DAYS_OF_WEEK</strong></p>
<p><strong>  FROM CALENDAR</strong></p>
<p>/</p>
<p>If you need to build a time dimension for your datawarehouse, you may probably need more that that.</p>
<p><strong>WITH LIMITS AS (SELECT TRUNC ( SYSDATE, &#8216;YEAR&#8217;) BEGINDATE, TRUNC (SYSDATE) ENDDATE FROM DUAL),</strong></p>
<p><strong>     CALENDAR</strong></p>
<p><strong>     AS (    SELECT (BEGINDATE + LEVEL &#8211; 1) AS DATES</strong></p>
<p><strong>               FROM LIMITS</strong></p>
<p><strong>         CONNECT BY LEVEL &lt;= (ENDDATE &#8211; BEGINDATE + 1))</strong></p>
<p><strong>SELECT DATES</strong></p>
<p><strong>      ,TO_CHAR ( DATES, &#8216;Dy&#8217;) DAYS_OF_WEEK</strong></p>
<p><strong>      ,DATES &#8211; 7 ONE_WEEK_AGO</strong></p>
<p><strong>      ,ADD_MONTHS ( DATES, -1) ONE_MONTH_AGO</strong></p>
<p><strong>      ,ADD_MONTHS ( DATES, -12) ONE_YEAR_AGO</strong></p>
<p><strong>      ,TRUNC ( DATES, &#8216;Q&#8217;) BEGIN_OF_QUARTER</strong></p>
<p><strong>      ,TRUNC ( ADD_MONTHS ( DATES, 3), &#8216;Q&#8217;) &#8211; 1 END_OF_QUARTER</strong></p>
<p><strong>  FROM CALENDAR</strong></p>
<p>/</p>
<p>Check out <a href="http://programmerslounge.blogspot.com/2011/07/how-to-get-first-day-and-last-day-of.html">http://programmerslounge.blogspot.com/2011/07/how-to-get-first-day-and-last-day-of.html</a> for a list of more first/last attributes.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/oraghetti.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/oraghetti.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/oraghetti.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/oraghetti.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/oraghetti.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/oraghetti.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/oraghetti.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/oraghetti.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/oraghetti.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/oraghetti.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/oraghetti.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/oraghetti.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/oraghetti.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/oraghetti.wordpress.com/81/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oraghetti.wordpress.com&amp;blog=5415577&amp;post=81&amp;subd=oraghetti&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://oraghetti.wordpress.com/2011/12/07/playing-with-date-ranges/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4f26dbe1a7a7963647e032058d979569?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=G" medium="image">
			<media:title type="html">Davide Moraschi</media:title>
		</media:content>
	</item>
		<item>
		<title>Chapter 2 &#8211; The Oracle VALUES table</title>
		<link>http://oraghetti.wordpress.com/2008/11/24/chapter-2-the-oracle-values-table/</link>
		<comments>http://oraghetti.wordpress.com/2008/11/24/chapter-2-the-oracle-values-table/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 14:55:23 +0000</pubDate>
		<dc:creator>dmoraschi</dc:creator>
				<category><![CDATA[Gams]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Vensim]]></category>
		<category><![CDATA[data warehouse]]></category>
		<category><![CDATA[LinkedIn]]></category>
		<category><![CDATA[panel data]]></category>
		<category><![CDATA[Stata]]></category>
		<category><![CDATA[time series]]></category>

		<guid isPermaLink="false">http://oraghetti.wordpress.com/?p=34</guid>
		<description><![CDATA[An article I've read time ago gave me the idea to attach an extra table to manage the variable number of columns in different data sets*. This article about dimensional modeling was introducing the concept of "helper table". In few words, I can create a single column and store a reference (a code, an ID) to another table which holds the real dimensions, no matter how many columns they are. I simply need to create a fake code for the dimension group and link the two tables on that code.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oraghetti.wordpress.com&amp;blog=5415577&amp;post=34&amp;subd=oraghetti&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div class="hang">An article I&#8217;ve read time ago gave me the idea to attach an extra table to manage the variable number of columns in different data sets*. This article about dimensional modeling was introducing the concept of &#8220;helper table&#8221;. In few words, I can create a single column and store a reference (a code, an ID) to another table which holds the real dimensions, no matter how many columns they are. I simply need to create a fake code for the dimension group and link the two tables on that code.</div>
<div class="hang">In the &#8220;helper table&#8221; I may have a row for every dimension, which would be the correct think to do if we want to comply strictly with the normalization rules.</div>
<div class="hang">So for the example TSTRAD in Chapt. 1and the helper table would be stored this way:</div>
<div class="hang">
<div id="attachment_42" class="wp-caption alignnone" style="width: 213px"><a rel="attachment wp-att-42" href="http://oraghetti.wordpress.com/2008/11/24/chapter-2-the-oracle-values-table/t1/"><img class="size-full wp-image-42" title="TSTRAD" src="http://oraghetti.files.wordpress.com/2008/11/t1.jpg?w=500" alt="TSTRAD"   /></a><p class="wp-caption-text">TSTRAD</p></div>
</div>
<div class="hang">
<div id="attachment_43" class="wp-caption alignnone" style="width: 317px"><a rel="attachment wp-att-43" href="http://oraghetti.wordpress.com/2008/11/24/chapter-2-the-oracle-values-table/t2/"><img class="size-full wp-image-43" title="HELPER TABLE" src="http://oraghetti.files.wordpress.com/2008/11/t2.jpg?w=500" alt="HELPER TABLE"   /></a><p class="wp-caption-text">HELPER TABLE</p></div>
</div>
<div class="hang">But I am using Oracle 10g and in this version there is no easy way later to transform several rows into several columns; say for example that I want to select all dimensions in group 1 and display them as columns with the respective value. This would be a very complicated query involving DECODE and MAX and who knows what else. So I am taking advantage of an Oracle feature: the ability to store custom type objects inside table columns, so I create a data type to hold an array of 10 dimensions:</div>
<h4><span style="color:#008000;"><strong>CREATE OR REPLACE TYPE T_VARCHAR2_25 AS VARRAY (10) OF VARCHAR2 (25);</strong></span></h4>
<div class="hang">This type will hold up to ten varchar2 strings and since varrays in Oracle are numbered sequentially I will always be sure that they are in correct order. So the &#8220;helper table&#8221; becomes:</div>
<h4><span style="color:#008000;">CREATE TABLE UNI_DIM_DIMENSIONS(<br />
DIMENSION_ID NUMBER,<br />
VA_ELEMENT_NAMES T_VARCHAR2_25 NOT NULL, CONSTRAINT PK_UNI_DIM_DIMENSIONS PRIMARY KEY (DIMENSION_ID));</span></h4>
<div class="hang">
<div id="attachment_53" class="wp-caption alignnone" style="width: 254px"><a rel="attachment wp-att-53" href="http://oraghetti.wordpress.com/2008/11/24/chapter-2-the-oracle-values-table/t31/"><img class="size-full wp-image-53" title="UNI_DIM_DIMENSIONS" src="http://oraghetti.files.wordpress.com/2008/11/t31.jpg?w=500" alt="UNI_DIM_DIMENSIONS"   /></a><p class="wp-caption-text">UNI_DIM_DIMENSIONS</p></div>
<p>Why do I do this? Can&#8217;t I simply store the varray in the original VALUES table and get rid of the helper table? Yes, I can, I do this just in case that two or more values happen to share the same exact dimension columns: in that case I will not need duplicate the information, I will simply reuse the code of the proper dimension group and feel an experienced database developer <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/oraghetti.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/oraghetti.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/oraghetti.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/oraghetti.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/oraghetti.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/oraghetti.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/oraghetti.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/oraghetti.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/oraghetti.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/oraghetti.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/oraghetti.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/oraghetti.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/oraghetti.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/oraghetti.wordpress.com/34/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oraghetti.wordpress.com&amp;blog=5415577&amp;post=34&amp;subd=oraghetti&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://oraghetti.wordpress.com/2008/11/24/chapter-2-the-oracle-values-table/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4f26dbe1a7a7963647e032058d979569?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=G" medium="image">
			<media:title type="html">Davide Moraschi</media:title>
		</media:content>

		<media:content url="http://oraghetti.files.wordpress.com/2008/11/t1.jpg" medium="image">
			<media:title type="html">TSTRAD</media:title>
		</media:content>

		<media:content url="http://oraghetti.files.wordpress.com/2008/11/t2.jpg" medium="image">
			<media:title type="html">HELPER TABLE</media:title>
		</media:content>

		<media:content url="http://oraghetti.files.wordpress.com/2008/11/t31.jpg" medium="image">
			<media:title type="html">UNI_DIM_DIMENSIONS</media:title>
		</media:content>
	</item>
		<item>
		<title>Chapter 1 &#8211; The beginning</title>
		<link>http://oraghetti.wordpress.com/2008/11/21/chapter-1-the-beginning/</link>
		<comments>http://oraghetti.wordpress.com/2008/11/21/chapter-1-the-beginning/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 14:32:56 +0000</pubDate>
		<dc:creator>dmoraschi</dc:creator>
				<category><![CDATA[Gams]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Vensim]]></category>
		<category><![CDATA[data warehouse]]></category>
		<category><![CDATA[LinkedIn]]></category>
		<category><![CDATA[panel data]]></category>
		<category><![CDATA[Stata]]></category>
		<category><![CDATA[time series]]></category>

		<guid isPermaLink="false">http://oraghetti.wordpress.com/?p=14</guid>
		<description><![CDATA[The aim of these posts is trying to find an elegant database solution to this: a way to build a common repository for different data sets from different softwares so that data can be easily exchanged and the history of the changes can be visible to everyone involved in data analysis. And -much better- a new interface will help maintain, correct, cleanse the various data sets.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oraghetti.wordpress.com&amp;blog=5415577&amp;post=14&amp;subd=oraghetti&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The institution where I work needs to analyze data from different sources with different statistical and modeling packages.</p>
<p>The way that the data is stored at the moment is baroque: tab or comma delimited ASCII data files, Excel sheets, and word of mouth. Multiple copies of the same data set may be stored on the network and -even worse- different and updated version can coexist. Result data sets are stored on local hard drives and are not visible to everyone. This can lead to embarrassing situations were at the same meeting two or more pie-chart of the same data set do not agree with each other.</p>
<p>So the aim of these posts is trying to find an elegant database solution to this: a way to build a common repository for different data sets from different softwares so that data can be easily exchanged and the history of the changes can be visible to everyone involved in data analysis. And -much better- a new interface will help maintain, correct, cleanse the various data sets.</p>
<p>The data sets can be about anything, from pollution data, to GDP, to fuel consumption or demographics. All data sets have both cross-sectional and time series dimensions (see Christopher Dougherty &#8220;Introduction to Econometrics 3e&#8221; book, for a good introduction to PANEL or LONGITUDINAL data sets)*.</p>
<p>There are different modeling packages on the market; in my job we use both GAMS<span style="font-size:10pt;font-family:Verdana;"><sup>®</sup></span> and VENSIM<span style="font-size:10pt;font-family:Verdana;"><sup>®</sup></span>. Also STATA<span style="font-size:10pt;font-family:Verdana;"><sup>®</sup></span> is used sometimes for specific functions. Every package has its own terminology and give different names to the same entity: for example VENSIM<span style="font-size:10pt;font-family:Verdana;"><sup>®</sup></span> uses &#8220;Subscripts&#8221; while GAMS<span style="font-size:10pt;font-family:Verdana;"><sup>®</sup></span> has &#8220;Sets&#8221; but they both refer to the same thing; this lead to confusion among people using different tools who need to share their data sets.</p>
<table style="height:298px;" border="0" cellspacing="0" cellpadding="0" width="194">
<tbody>
<tr>
<td colspan="5" align="center">TSTRAD</td>
</tr>
<tr>
<td width="46" valign="top">mmpdr</td>
<td width="34" valign="top">aus</td>
<td width="34" valign="top">xoc</td>
<td width="46" valign="top">Y1996</td>
<td width="34" valign="top">12</td>
</tr>
<tr>
<td width="46" valign="top">mmpdr</td>
<td width="34" valign="top">aus</td>
<td width="34" valign="top">xoc</td>
<td width="46" valign="top">Y1999</td>
<td width="34" valign="top">2</td>
</tr>
<tr>
<td width="46" valign="top">mmpdr</td>
<td width="34" valign="top">aus</td>
<td width="34" valign="top">xoc</td>
<td width="46" valign="top">Y2000</td>
<td width="34" valign="top">15</td>
</tr>
<tr>
<td width="46" valign="top">mmpdr</td>
<td width="34" valign="top">aus</td>
<td width="34" valign="top">xoc</td>
<td width="46" valign="top">Y2001</td>
<td width="34" valign="top">2</td>
</tr>
<tr>
<td width="46" valign="top">mmpdr</td>
<td width="34" valign="top">aus</td>
<td width="34" valign="top">xoc</td>
<td width="46" valign="top">Y2002</td>
<td width="34" valign="top">3</td>
</tr>
<tr>
<td width="46" valign="top">mmpdr</td>
<td width="34" valign="top">aus</td>
<td width="34" valign="top">hkg</td>
<td width="46" valign="top">Y1979</td>
<td width="34" valign="top">1</td>
</tr>
<tr>
<td width="46" valign="top">mmpdr</td>
<td width="34" valign="top">aus</td>
<td width="34" valign="top">hkg</td>
<td width="46" valign="top">Y1980</td>
<td width="34" valign="top">1</td>
</tr>
<tr>
<td width="46" valign="top">mmpdr</td>
<td width="34" valign="top">aus</td>
<td width="34" valign="top">hkg</td>
<td width="46" valign="top">Y1981</td>
<td width="34" valign="top">3</td>
</tr>
<tr>
<td width="46" valign="top">mmpdr</td>
<td width="34" valign="top">aus</td>
<td width="34" valign="top">hkg</td>
<td width="46" valign="top">Y1982</td>
<td width="34" valign="top">1</td>
</tr>
<tr>
<td width="46" valign="top">mmpdr</td>
<td width="34" valign="top">aus</td>
<td width="34" valign="top">jpn</td>
<td width="46" valign="top">Y1994</td>
<td width="34" valign="top">133</td>
</tr>
<tr>
<td width="46" valign="top">mmpdr</td>
<td width="34" valign="top">aus</td>
<td width="34" valign="top">jpn</td>
<td width="46" valign="top">Y1995</td>
<td width="34" valign="top">17</td>
</tr>
<tr>
<td width="46" valign="top">mmpdr</td>
<td width="34" valign="top">aus</td>
<td width="34" valign="top">jpn</td>
<td width="46" valign="top">Y1996</td>
<td width="34" valign="top">47</td>
</tr>
<tr>
<td width="46" valign="top">mmpdr</td>
<td width="34" valign="top">aus</td>
<td width="34" valign="top">jpn</td>
<td width="46" valign="top">Y1997</td>
<td width="34" valign="top">23</td>
</tr>
<tr>
<td width="46" valign="top">mmpdr</td>
<td width="34" valign="top">aus</td>
<td width="34" valign="top">jpn</td>
<td width="46" valign="top">Y1998</td>
<td width="34" valign="top">13</td>
</tr>
<tr>
<td width="46" valign="top">mmpdr</td>
<td width="34" valign="top">aus</td>
<td width="34" valign="top">jpn</td>
<td width="46" valign="top">Y1999</td>
<td width="34" valign="top">22</td>
</tr>
</tbody>
</table>
<p>Take this for example: the last column is a value, column number 4 looks like a time indicator. Now look at column 3; it can contain one of the following: (xoc, hkg or jpn). The list of all possible codes for column 3 is called &#8220;Subscript Range&#8221; in VENSIM<span style="font-size:10pt;font-family:Verdana;"><sup>®</sup></span> and &#8220;Set&#8221; in GAMS<span style="font-size:10pt;font-family:Verdana;"><sup>®</sup></span>.</p>
<p>Look at the first data row, it could be written this way:</p>
<p><strong>TSTRAD[mmpdr, aus, xoc, Y1996]=12</strong></p>
<p>So how do we call TSTRAD? We may call it a variable, and what&#8217;s the name of the codes inside parentheses? Subscripts, dimensions, indexes? There is a need for a common terminology across different software tools. So from now on we will call them <span style="text-decoration:underline;">variable</span> and <span style="text-decoration:underline;">dimension</span> respectively, and <span style="text-decoration:underline;">domain</span> the list of all possible codes inside a column.</p>
<p>Another issue we are facing is that different data sets have different number of columns, and the number is not known &#8220;a priori&#8221;. If I want to store the example table above in a database I could easily create a table with 5 columns and set the primary key to the combination of the first four columns. But if I need to store another data set with 3 or 7 columns then I have to modify my table or create another table, leading to poor design and confusion in the names of the columns. Also, do I need to normalize this data set? For storage and speed sake I&#8217;d better replace all descriptive columns with numerical codes. Giving for example xoc a code of 1, hkg = 2, and jpn = 3, I can spare several bytes every row and make faster searches. Then I would need an extra reference table to explain what numerical codes mean.</p>
<p>In order to facilitate the table design and maintenance I will need a flexible table to store a variable number of descriptive columns and their respective value. VENSIM<span style="font-size:10pt;font-family:Verdana;"><sup>®</sup></span> and GAMS<span style="font-size:10pt;font-family:Verdana;"><sup>®</sup></span> have a limit on the number of columns for a given data set, this limit is 10 for both.  We can then create a table with 11 fields and have a coffee break -end of the story- but we wouldn&#8217;t be satisfied, would we?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/oraghetti.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/oraghetti.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/oraghetti.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/oraghetti.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/oraghetti.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/oraghetti.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/oraghetti.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/oraghetti.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/oraghetti.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/oraghetti.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/oraghetti.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/oraghetti.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/oraghetti.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/oraghetti.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oraghetti.wordpress.com&amp;blog=5415577&amp;post=14&amp;subd=oraghetti&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://oraghetti.wordpress.com/2008/11/21/chapter-1-the-beginning/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4f26dbe1a7a7963647e032058d979569?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=G" medium="image">
			<media:title type="html">Davide Moraschi</media:title>
		</media:content>
	</item>
		<item>
		<title>So you want Gams, Vensim, Stata panel data?</title>
		<link>http://oraghetti.wordpress.com/2008/11/13/so-you-want-gams-vensim-stata-panel-data/</link>
		<comments>http://oraghetti.wordpress.com/2008/11/13/so-you-want-gams-vensim-stata-panel-data/#comments</comments>
		<pubDate>Thu, 13 Nov 2008 16:06:41 +0000</pubDate>
		<dc:creator>dmoraschi</dc:creator>
				<category><![CDATA[Gams]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Stata]]></category>
		<category><![CDATA[Vensim]]></category>
		<category><![CDATA[LinkedIn]]></category>
		<category><![CDATA[panel data]]></category>
		<category><![CDATA[time series]]></category>

		<guid isPermaLink="false">http://oraghetti.wordpress.com/?p=5</guid>
		<description><![CDATA[Stay tuned for upcoming articles on how to read/write panel data to an Oracle database and read them from several mathematical or statistical packages.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oraghetti.wordpress.com&amp;blog=5415577&amp;post=5&amp;subd=oraghetti&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Stay tuned for upcoming articles on how to read/write panel data to an Oracle database and read them from several mathematical or statistical packages.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/oraghetti.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/oraghetti.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/oraghetti.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/oraghetti.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/oraghetti.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/oraghetti.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/oraghetti.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/oraghetti.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/oraghetti.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/oraghetti.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/oraghetti.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/oraghetti.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/oraghetti.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/oraghetti.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oraghetti.wordpress.com&amp;blog=5415577&amp;post=5&amp;subd=oraghetti&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://oraghetti.wordpress.com/2008/11/13/so-you-want-gams-vensim-stata-panel-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4f26dbe1a7a7963647e032058d979569?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=G" medium="image">
			<media:title type="html">Davide Moraschi</media:title>
		</media:content>
	</item>
	</channel>
</rss>
