Category: data warehousing

  • Data Warehouse and allocated cost data

    In a previous post, I showed that costs data may be allocated to other departments or levels of granularity to enable cost analysis.

    The allocated cost data are artificial data: the data are only a part of costs for which the data are collected at other levels of the organisation, These data are then intermediate data that are halfway between original data that are collected in the business process and the final output data that are used in the final profit and loss analysis.

    In my opinion, such intermediate data should not be included in the data warehouse as they are artificially created data. If we would store such data in the data warehouse, such data could be misinterpreted as real input data. Someone from another department may use these data as being equivalent to real input data thus leading to unnecessary confusion. Anyone who does so, cannot be blamed. The data warehouse is a central data store that may be used by everyone for reporting purposes. Once included in the data warehouse, one may assume that the data represent a well analysed view upon real business events.

    Therefore, to maintain a good data quality, the data warehouse is not a good environment to store such intermediate allocated data.

    It is also true that the business rules to create the allocated costs can be quite complex. The owner of these business rules is the accounting department (and not the IT department). If the IT department is lured into trap to calculate such intermediate data, it is exposed at an immensely complicated situation as it must rely on specifications from the accounting department while at the same time it may be held responsible for the quality of such data. We then have a reason not to agree to calculate such allocations within the data warehouse: it is simply too complicated and the IT department does not have the knowledge to do so.

    An IT department is good at three things: retrieving data, storing data and propagating data. It is not good at programming complicated business rules that may be not fully known by the owners. Hence, the IT department should not attempt to do so.

     

  • Cost Allocation

    In most organisations, cost data are collected on a different level of granularity or attached to another dimension as we would like to see the cost data.

    Two examples.

    Cost data, such as advertisements or publicity may be collected at product group level whereas we would like to present the cost data on individual products. This can be understood as advertisements are made for, say, chocolate whereas we would like to see the cost data that are attached to an individual bar. This would allow to compare the sales price to the total cost price of a chocolate bar to see if it is sold at a profitable price or not.

    Cost data may also be acquired with cost centres (such as the HR department) whereas we would like to know how much costs is made with the sales data that are collected with the profit centres. In that case we would like to infer if the profit centre sells their products at a price that covers all direct and indirect costs.

    We are confronted with the question on how to spread costs to individual products. Or alike: how to divide the costs on, say, HR to sales departments.

    I have read on three different methods how to do this. The first method is almost trivial: do not do it. Do not spread the costs, do not allocate the costs. Just look at total turnover, direct costs and total indirect costs and see if profits are made.

    The second method is more adequate as then a factor is taken that is used to divide the costs. One may think of sales turnover. For each product and every profit department, one may calculate the percentage turnover in total turnover. The resulting set of factors can then be used in the division process. If a chocolate bar takes 2% of total chocolate sales, we may account 2% of advertisement costs on chocolate as being attributed to indirect advertisements costs for chocolate bars. Likewise: if department A sells 10% of total sales, we take 10% of HR costs as being attributable to department A.

    The third method assumes that we have different allocation factors for different cost groups. Hence advertisements may be allocated on base of turn over, HR on base of the number of employees, maintenance on capex outlays etc. The idea is that such allocation is closely related to the actual driver for which costs are incurred. This would then be more acceptable for the managers of a profitcentres who would like to see a close relation between his activities and the internal costs for which he is held attributable. It is not a pleasant idea to receive a large internal costs invoice for warehouse activities if the department does not have activities for which a warehouse is necessary.

    A good method for allocation can be immensely important for an organisation as allocation methods have behavioural effects within the organisation. A department may try to avoid attributed indirect costs to improve departmental profit figures. I once worked in an organisation where It costs were allocated according to the number of working network sockets. The idea is good as it may be assumed the IT costs have a relation to the number of network connections. However the negative consequence was that network access was denied to people who needed it for their work to avoid IT costs.

    Hence the important point is that cost allocation is important but one should create such a method to avoid unwanted behaviour. This is certainly not a trivial task as it may attribute how activities are assessed. The consequence is that the allocation mechanisme might become quite complex as multiple goals are aimed for: a fair representation of the cost structure without unwanted behavioural consequences.

     

     

  • A script to create a sample data warehouse – part 2 the fact

    I have created an example data warehouse with just one dimension table and one fact table. We have discussed how the dimension table must be loaded. Once the dimension table is loaded, we may start loading the fact table.

    Let us see how that is done.

    The fact table looks like:

    create table devADW_BAN_MI.factTARGET
    (PI DECIMAL(15,0) GENERATED  BY DEFAULT AS IDENTITY
               (START WITH 1
                INCREMENT BY 1
                MINVALUE 1
               NO CYCLE
                ),
     SK decimal(15,0),
     SBLrowid integer,
     getal integer,
     updat  timestamp(0) ,
     VERSION_SDATE timestamp(0)  ,
     version_edate  timestamp(0)   );

    Here, we have a SBLrowid that provides us with an indicator on the event. This indicator will be used as a business key of the event. This enable us to differentiate between a renewed recording of an event that we already know of and a comnpletely new event. Whenever a new recording of an event is received, we would like to label the former recording as being obsolete. Likewise, the newest recording should be marked as a new recording with times attached as from what point in time the recording is valid.
    The periods in which the data of a record reflect an actual situation is indicated by version_sdate and version_edate. The version_sdate stands for the start of the validity period whereas the version_edate stands for the end of the validity period.
    If a record is received, it is assumed that version_sdate can be filled out with a sysdate to indicate a start of the validity period. Likewise, if the record is superseded, the point in time at which the record is superseded is included as “version_edate”.
    I have included “getal” as an attribute that describes the features of an event. Also this event is assumed to be described by an attribute that stems from the dimension table.  Therefore a reference to that dimension table is included. This reference is done via the use of the surrogate key of the dimension table. This provides us with all details from the dimension table that are linked to an event.

    We also include an attribute “updat”. This indicates the time when a record is created. This attribute allows us to select a subset of the input records. Records that were processed earlier can then be skipped.

    Much like the loading of the dimension, a seperate table is created that contains source records. Let us assume that at a certain point of time, we have these records available in the source:

    	BK	SBLrowid	getal	updat
    1	PIP	3	25	10/3/2012 15:08:29
    2	BKO	2	1,200	10/3/2012 15:08:29
    3	BKO	1	1,000	10/3/2012 15:08:29
    4	XYZ	4	400	10/3/2012 15:08:30
    5	TBO	2	1,300	10/3/2012 15:11:13
    6	BKO	5	95	10/3/2012 15:11:14
    7	XYZ	4	400	10/3/2012 15:11:14

    Let us assume that the first 4 records are already loaded in the target fact table. That leaves 3 records to be loaded. These three records represent three different situations.

    1. The first situation are records that are updates on an event that is reported earlier. In this case, the event is indicated by SBLrowid. We notice that for SBLrowid=2, we received a record with [BKO, 1200] whereas an update is sent with [TBO, 1300]. To handle this, we first create an intermediate table that only contains updates on events that are not yet processed in the data warehouse.
      --temp tabel maken
      drop table devADW_BAN_MI.temp;
      create table devADW_BAN_MI.temp
      ( SK decimal(15,0),
       SBLrowid integer,
       getal integer,
       updat  timestamp(0) 
      );
      insert into  devADW_BAN_MI.temp 
        select A.SK,A.SBLrowid,A.getal,A.updat
        from (select SK, SBLrowid, getal, updat  
              from devADW_BAN_MI.factSOURCE
              left join devADW_BAN_MI.dimTARGET 
              on factSOURCE.BK = dimTARGET.BK
              where version_edate > CURRENT_DATE
              and (updat > (select max(updat) 
                   from devADW_BAN_MI.factTARGET)
                   )
              ) A, 
        (select SK, SBLrowid, getal, updat  
         from devADW_BAN_MI.factTARGET 
         where version_edate > CURRENT_DATE) B
      where A.SBLrowid=B.SBLrowid 
         and 
      (A.SK||A.getal != B.SK||B.getal);

      These records are subsequently used in two different actions. The first action is to update the records in the target table for which an update is received

      update devADW_BAN_MI.factTARGET
      set version_edate = CURRENT_TIME 
      where  (SBLrowid  in 
      (select SBLrowid from devADW_BAN_MI.temp))
       and version_edate > CURRENT_DATE;

      The second action is to insert the receords with the newest version of the events:

      insert into devADW_BAN_MI.factTARGET
      (SK,SBLrowid, getal,updat,version_sdate,version_edate) 
        select SK,
        SBLrowid, 
        getal,
        updat, 
        CURRENT_time,  
        cast ('99991231000000' as TIMESTAMP(0) FORMAT 'yyyymmddhhmiss') 
       from devADW_BAN_MI.temp
       ;
    • The second situation is a situation that records on events are received from the source that are not yet processed into the target table. This can be inserted by:
      --nieuwe records
      insert into devADW_BAN_MI.factTARGET
      (SK,SBLrowid, getal,updat,version_sdate,version_edate) 
       select 
        B.SK,
        A.SBLrowid, 
        A.getal,
        A.updat, 
        current_time, 
        cast ('99991231000000' as TIMESTAMP(0) FORMAT 'yyyymmddhhmiss')
       from 
        (select BK, SBLrowid, getal, updat  
         from devADW_BAN_MI.factSOURCE 
         where  SBLrowid not in 
         (select SBLrowid from devADW_BAN_MI.factTARGET)) A 
         left join 
         (select BK, SK from devADW_BAN_MI.dimTARGET 
         where version_edate > CURRENT_DATE) B
         on A.BK=B.BK
        ;

      This insert statement has two characteristics. The first characteristic is to select records on events from the source that are not yet included in the target table. The second characteristic is to look up teh surrogate key from the dimensional table with the business key that is delivered. From the source, we get a business key on items that we have stored in the dimension table. This is subsequently translated into a surrogate key with this dimension table. We need that surrogate key to identify exactly one record within the dimension table in which the correct versions of the dimension is stored.

    • The third situation is whereby records are sent from the source on events that are already stored in the target table. The content is also exactly equal between source and target. In that case, no action needs to be taken.
  • A script to create a sample data warehouse – part 1 the dimension

    In the last week, I have written a sample script to create a skeleton data warehouse. I will use this as a head start for future work where the skeleton will be used to implement an actual data warehouse.

    The skeleton is written for a Teradata DBMS. This is the platform that I currently use.

    The example data warehouse has two tables: a dimension table and a fact table. Hence we have a small example that can be expanded in the future.

    Let us start with the dimension table.
    See also the script with ExampleDW
    The dimension table is created with:

    drop table devADW_BAN_MI.dimTARGET;
    
    create table devADW_BAN_MI.dimTARGET
    (SK DECIMAL(15,0) GENERATED  BY DEFAULT AS IDENTITY
               (START WITH 1
                INCREMENT BY 1
                MINVALUE 1
               NO CYCLE
                ),
     BK varchar(3),
     extra varchar(256),
     VERSION_SDATE timestamp(0)  ,
     version_edate  timestamp(0)   );

    This dimension has a surrogate key (SK) that is loaded with the DBMS facility. This leads to the situation that every record is given an attribute that can be used as a primary key. This SK is the primary key. It uniquely identifies a record within a table.
    The table also has a business key (BK). This is something by which the business identifies an object (say a product, a contract or a customer). If we have a business key, we are able to know whether we have an earlier version of the object. If we get a new record on an object that we already have in the table, we may act accordingly.
    In our case, we assume that we want to act in the following way whenever a new record is found on an object that we already have in the data warehouse.

    • The record is added to the table.
    • The record that describes the old state of the object is labelled as ‘old version’ .

    In the table we have an attribute “extra”, that acts as an example of a descriptive attribute. It can be a colour of the object, the size, the owner etc.

    We also encounter an attribute “version_sdate”  which indicates the starting point of validity of the record. We assume that an object generates over time a series of records. Once the record is sent as the newest version of the object, it is stored in the data warehouse. We use the attribute version_sdate as the starting point in time after which the record is seen as the valid version of the object.

     Likewise, we have a “version_edate”  that indicates the finishing point in time. If a record is stored in the data warehouse and if a new version is included in the data warehouse, the old record is updated with version_edate equals finishing point in time.

    A source table is created with:

    create table devADW_BAN_MI.dimSOURCE
    (BK varchar(3),
     extra varchar(256));

    This represents the source of data. This source contains two attributes: a business key (BK) that identifies an object and an additional attribute (extra) that contains a description of the object.

    Let us then load the source:

    insert into devADW_BAN_MI.dimSOURCE(BK, extra) values ('BKO','BKO extra');
    insert into devADW_BAN_MI.dimSOURCE(BK, extra) values ('TBO','TBO extra');
    insert into devADW_BAN_MI.dimSOURCE(BK, extra) values ('SRM','SRM extra');
    insert into devADW_BAN_MI.dimSOURCE(BK, extra) values ('XYZ','XYZ extra');

    Ok. we now have a source that is loaded and a dimension table that is still empty. This can be initially loaded with:

    insert into devADW_BAN_MI.dimTARGET(BK,extra,version_sdate,version_edate)
    select BK,extra, current_time, cast ('99991231000000' as TIMESTAMP(0) FORMAT 'yyyymmddhhmiss')  
    from devADW_BAN_MI.dimSOURCE

    This gives:

    	
              SK  	BK	extra	 VERSION_SDATE	 version_edate
    1	100,001	XYZ	XYZ extra 10/2/2012 16:29:15 12/31/9999 00:00:00
    2	300,001	BKO	BKO extra 10/2/2012 16:29:15 12/31/9999 00:00:00
    3	1	SRM	SRM extra 10/2/2012 16:29:15 12/31/9999 00:00:00
    4	200,001	TBO	TBO extra 10/2/2012 16:29:15 12/31/9999 00:00:00

    Let us continue with a new dataload for the dimesnion table:

    delete  from devADW_BAN_MI.dimSOURCE;
    insert into devADW_BAN_MI.dimSOURCE(BK, extra) values ('SRM','SRM nog meer');
    insert into devADW_BAN_MI.dimSOURCE(BK, extra) values ('ABC','ABC extra');
    insert into devADW_BAN_MI.dimSOURCE(BK, extra) values ('TBO','TBO extra');

    We first deleted all records in the source. This is followed by loading three records.

    In an incremental load step, we may have three situations:

    • the record represents an object that is not yet included in the dimensional table. Whether or not this is the case can be assessed with the business key. If a new business key is encountered, we have this situation. The algorithm is quite simple: do we have a record is the source for which the business key is not yet included in the target dimension table. The sql reads as:
    --NEW records in source
    insert into devADW_BAN_MI.dimTARGET
     (BK,extra,version_sdate,version_edate)
     select 
      BK,
      extra, 
      CURRENT_time, 
      cast ('99991231000000' as TIMESTAMP(0) 
         FORMAT 'yyyymmddhhmiss') 
     from devADW_BAN_MI.dimSOURCE 
      where BK not in 
      (select BK 
       from devADW_BAN_MI.dimTARGET 
       where version_edate > CURRENT_DATE
      );
  •  the record in the source is included exactly in the target table. In our case, we have a combination (BK, extra) that may already be present in the target table. In that case we have no reason to apply any change in the target table: the data are already present in the target. We may go on looking for records in the source that may need action.
  • the record in the source table represents an update on an object that is already present in the data warehouse. In that case we have a business key (BK) that is already present in the dimensional table. We also have a situation whereby the content in additional attributes are different from what we have in the dimensional table. In this case “extra” in the source is not equal to “extra”  in the target table. We identify these records as:
    create table devADW_BAN_MI.temp
    (BK varchar(3),
     extra varchar(256));
    insert into  devADW_BAN_MI.temp 
    select B.BK, A.extra
    from 
    (select BK, extra from devADW_BAN_MI.dimSOURCE) A,
    (select BK, extra from devADW_BAN_MI.dimTARGET 
      where version_edate > CURRENT_DATE) B
    where A.BK=B.BK and A.extra != B.extra;

Once the records that contain an update are identified, we must take 2 actions:

  1. Update records in the data warehouse that represent an obsolete version of the object. This update consists of setting version_edate to a date that indicates the end of a validity period.
    update devADW_BAN_MI.dimTARGET
    set version_edate = CURRENT_TIME 
    where  
    (BK  in (select BK from devADW_BAN_MI.temp))  
    and 
    version_edate > CURRENT_DATE; 
  2. Insert records that represent the newest update on the objects.
    insert into devADW_BAN_MI.dimTARGET
    (BK,extra,version_sdate,version_edate)
    select BK,extra, CURRENT_time,  
    cast ('99991231000000' as TIMESTAMP(0) 
       FORMAT 'yyyymmddhhmiss')  
    from devADW_BAN_MI.temp
    where (BK  in (select BK from devADW_BAN_MI.Temp)) ;
    

 

  • Free ETL tool

    Yesterday evening, I received a copy of Expressor. This is a free ETL tool which made a very good impression to me.
    I downloaded the copy from http://www.expressor-software.com . The download and subsequent installation is very simple. The file to be downloaded is about a 100MB and the installation is straightforward: some legal screens and a few hits on the ” next button” .

    Once the tool was installed, I started my watch to see how much time was needed to create a dataflow. I wanted to extract the values from a table and write these to a file. It took me 18 minutes to create this flow and have it run.
    The setup of the tool is straight forward. The first things to do is to set up the data connections (to Oracle, ODBC, SQL Server etc).
    Once this is done, one could create the input- and output logic. Once could decribe what data are to be read and how the data are written to a target database. Finally one could describe the transformation in data betwee in- and output. Everything was positioned at logical / easily understandable locations within the programme.

    I really liked this programme. It came across as an ETL programme without the issues that make difficult in an ETL environment. Like user access: difficult to understand, more difficult to implement and impossible to debug. Within expressor no user access module (thank God).

  • Bugzilla

    In the test phase, we would like to create a nice list of encountered bugs.
    In most situations a project assistant is given the task to maintain this list. All encountered bugs are sent to him. He compiles a list. This list is then maintained to see which bugs are solved and which bugs are ready for a re-test.
    However, Bugzilla helps you to create and maintain such list. It is simple to install, it can be maintained by everyone who is connected to the project and it delivers a very nice overview. Moreover, it is easy to install and it is free.
    The idea is that Bugzilla is essentially a website that is installed from a so-called tarball that can be downloaded from www.bugzilla.org . It is a set of Perl scripts that act as a programm to store bug notifications in a MySQL database. We then need a webserver (to link user notifications to the database), a DBMS and a Perl interpretor. If you have a so-called LAMP installation at hand, you might have fulfilled the requirements: you then have a webserver (Apache), you have a DBMS (MySQL) and probably a Perl interpretor is available as well. In principle, the installation is straight-forward: download the tarball, unzip the file to get it installed on the website location, create a user and database in MySQL and pronto, you go.
    The technical details are nicely described in http://www.bugzilla.org/docs/tip/en/html/installation.html .

    For me, it took about 5 hours to get everything installed. I did not encounter a serious problem – it went along smoothly.
    The only issue was how to modify the configuration of Apache exactly to get it into the translation of the Perl files. But also here, may resources are available. And after 5 hours, I saw this screen:bugzilla

  • Deferring referential integrity constraints

    Last week, I gave a course on data warehousing. When I overviewed the theory, I noticed I had to spend some time on “disabling the the referential integrity constraints”.
    I realised that I had to provide a clear explanation on what is meant by this.
    The idea is rather straight forward. When we load sverela tables in a data warehouse, we might come in a situation where we load a certain table that is referenced to by another table. If we load that certain table before the referential table, we might come in a situation that we load certain fields that are not yet included in the referential table. If not dealt with properly, an error results.

    Example.

    Let us assume we have two tables. The DDL looks like:

    CREATE TABLE MOEDER
    (
      VREEMD  INTEGER
    );
    CREATE UNIQUE INDEX MOEDER_PK ON MOEDER
    (VREEMD);
    ALTER TABLE MOEDER ADD (
      CONSTRAINT MOEDER_PK
     PRIMARY KEY
     (VREEMD);
    
    CREATE TABLE DOCHTER
    (
      SLEUTEL  INTEGER,
      VREEMD   INTEGER
    );
    CREATE UNIQUE INDEX DOCHTER_PK ON DOCHTER
    (SLEUTEL);
    ALTER TABLE DOCHTER ADD (
      CONSTRAINT DOCHTER_PK
     PRIMARY KEY
     (SLEUTEL);
    
    ALTER TABLE DOCHTER ADD (
      CONSTRAINT DOCHTER_R01 
     FOREIGN KEY (VREEMD) 
     REFERENCES MOEDER (VREEMD)
        DEFERRABLE INITIALLY DEFERRED);
    

    We have two tables: a MOEDER table that contains referential data. We also have have DOCHTER that contains a foreign key (VREEMD). That foreign key can only contain values that are also included in table MOEDER.
    Assume, we load the record (SLEUTEL, VREEMD) in DOCHTER that contains a value pair (100,2) with 2 for VREEMD. In that case 2 must be included in the MOEDER.

    In a data warehouse, we might have a situation that we load DOCHTER first, followed by MOEDER.

    How to deal with the situation that we also want to load data in DOCHTER that are only later loaded in MOEDER?

    We solve that situation by adding the condition DEFERRABLE INITIALLY DEFERRED to the referential integrity constrant. In that case, the constraint is only checked when the commit is issued. At that moment, the MOEDER table must have values that are used in the DOCHTER table. That allows us to load the DOCHTER first, followed by a load of MOEDER and subsequently followed by a commit.

    That is different from the traditional situation when the check is done at the moment of loading. When we load a DOCHTER record without a proper refence in MOEDER, we get an error. When the DEFFERABLE INITIALLY DEFERRED is added, the check is postponed to the moment of commit. That solves our problem.

  • Temporary tables in Oracle

    Oracle has a feature it is possible to create tamporary tables. The idea is that a table can be created, can be populated with data, but these data can only be seen during the session. Other sessions do see the table but they see no rows. Even if someone uses the same userid as the user that created the temporary table, no rows are returned.
    First the syntax of this temporary table:

    
    create global temporary table onzin
    (i number(5,0),
    naam varchar2(30))
    on commit preserve rows;
    
    

    The working can be checked by adding a few rows. It can be verified that the rows exist: even after a commit, the rows are returned.
    However if another session is opened, the rows are NOT returned.
    What is the use of this feature?
    Burleson (http://www.dba-oracle.com/t_temporary_tables_sql.htm) claims that the performance can be improved by such temporary tables. I understand that some in-between results are kept in thic temporary table. They are later re-used by a second query.
    This is disputed by Tom Kyle. He writes: “I’m of the mindset that they are almost never needed”. He then proceeds by asking the readers to give him a situation where such temporary tables might be needed. He got some replies but they did not look very convincing.
    Whatever: Oracle does know the concept of a temporary table, but their usage seems somewhat limited.

  • How to run a SAS job in a batch mode

    I hope you recognise the situation. You have developed some SAS code (in Enterprise Guide, SAS Base Editor or DI Studio) and you would like to create a batch job from this. Huh? SAS seems to offer you only the possibility to run a job interactively.
    However, it is possible to run a job in a batch mode. The first step to do is to create a file that contains the SAS code. Let us assume that this file is called “D:\tmaanen\Documents\prive\datavault\Link_Invoice_Order.sas”. From the SAS helpfile we know that the command line to run this is: “”D:\Program Files\SAS\SASFoundation\9.2\sas.exe” -SYSIN D:\tmaanen\Documents\prive\datavault\Link_Invoice_Order.sas -NOSPLASH -ICON -PRINT D:\tmaanen\Documents\prive\datavault\Link_Invoice_Order.lst -log D:\tmaanen\Documents\prive\datavault\Link_Invoice_Order.log”. We could create a batch file that contains this line and submit this form the commandline.

  • Create a surrogate key in Oracle

    To create a surrogate key in Oracle is not really trivial. The issue, we address works as follows. Assume we have a table with 3 records an four attributes. The first attribute is a name, the second is a surrogate key. Other attributes refer to a user and a datetime stamp. This surrogate key should contain a unique number that allows us to locate the record uniquely. Let us assume the table looks like:

    name, SURKEY, CreatedDate, CreatedUser
    tom    1
    ine     2
    paula 
    

    In this case, we would like to have a unique value next to “paula”.
    This can be accomplished by a so-called trigger that creates such a unique value every time a record is inserted. To ensure that a unique value is retrieved, we use a sequence. The trigger has next code:

    create or replace
    TRIGGER SCOTT.DWH_SAI_ID
    BEFORE INSERT
    ON SCOTT.TABLE_SURKEY 
    REFERENCING NEW AS New OLD AS Old
    FOR EACH ROW
    DECLARE
    tmpVar NUMBER;
    BEGIN
       tmpVar := 0;
       SELECT DWH_TECH_ID.NEXTVAL INTO tmpVar FROM dual;
       :NEW.SURKEY := tmpVar;
       :NEW.CreatedDate := SYSDATE;
       :NEW.CreatedUser := USER;
    END DWH_SAI_ID; 
    

    This trigger takes a new (unique) value from a sequence DWH_TECH_ID and stores this value in attribute SURKEY. Along with the surrogate key, the user that inserted the record and the datetime is stored in the record.

    The result is:

    name, SURKEY, CreatedDate, CreatedUser
    tom    1
    ine     2
    paula  3           2010/2/2      tom