Mapping in OWB with primary key and foreign key relationship

Hi all,
I am new to this datawarehousing field. I have just started my career. I have to now create a mapping in owb where a table has a field which is a primary key of another table in the same staging area. If you guys could help me out with the a method it can be created that would be very helpful to me.
I thought of 2 ideas,
1. If I can use a look up, but then I am not sure if i can use a lookup for primary key, foreign key relationship. If I can use also, I do not know how to use that.
2. What if I can directly take that the first table and link the primary key of that table to the second table which uses that primary key of the first table as one of its fields.
I do not know how feasible these methods are. Please guys help me out.
Thanks in advance.

I have a similar case where table a and table b having relation but table a got inserted with data and table b is empty so there no values for foriegn key column in table b to realte with table a.
Now i want to load table b foriegn key with primary key column values of table a.
how can we do this in owb
thanks
kumar

Similar Messages

  • How to transfer database table contain null values, primary key, and foreign key to the another database in same server. using INSERT method.

    how to transfer database table contain null values, primary key, and foreign key to the another database in same server. using INSERT method.  thanks

    INSERT targetdb.dbo.tbl (col1, col2, col3, ...)
       SELECT col1, col2, col3, ...
       FROM   sourcedb.dbo.tbl
    Or what is your question really about? Since you talke about foreign keys etc, I suspect that you want to transfer the entire table definition, but you cannot do that with an INSERT statement.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Primary Key and Foreign Key Constraints

    Hi All,
    I would like to know PRIMARY KEY and FOREIGN KEY constraints on existing oracle tables. Could any one suggest me how to find out.
    Thanks,
    RED

    You can query DBA_CONSTRAINTS to get a list of all the constraints on table A and/or table B. The documentation I linked to gives a full list of the data you can see in DBA_CONSTRAINTS, but it includes things like the referenced table name and referenced constraint name for a foreign key constraint. If A is a parent of B or B is a parent of A, you could match up the parent's primary key constraint to the child's foreign key constraint.
    More generally, though, if you don't know that one of the tables is a parent of the other, figuring out how to join the two tables is probably not something that can be done using just the Oracle data dictionary. You would probably need an understanding of the data model being used to figure out what intermediate table(s) needed to be joined in order to relate rows in A to rows in B.
    Justin

  • Primary key and Foreign key on same column

    Hi, I am able to create below tables , primary and foreign keys as below.
    But Is this valid design? Can I define a column (ckey2 in table "child") as
    primary key and as well as foreign key?
    CREATE TABLE parent (
    col1 NUMBER,
    col2 NUMBER
    CREATE TABLE child (
    ckey1 NUMBER,
    ckey2 NUMBER,
    ckey3 NUMBER
    alter table parent add constraint parent_pk primary key( col1 );
    alter table child add constraint child_pk primary key( ckey2 );
    alter table child add constraint child_fk foreign key( ckey2 ) references parent( col1);
    Thanks.

    Can I define a column (ckey2 in table "child") as primary key and as well as foreign key?You mean you want to define a one-to-one relationship between parent and child tables.. why would you want to do that ? You might as well merge the 2 tables into one.

  • Primary keys and foreign keys

    Hi,
    is there a script available for changing the value of a primary key which automaticly
    detect all foreigs keys refering to this primary key and change them as well?
    William Oorschot

    I don't have the script now. but you can make a procedure of ur own.
    using a join on user_constraints, and user_cons_columns you can find out all the columns in all the tables which are referencing the particular primary key. once you have the table and the referencing columns, you can change the value of those columns with the new value.
    you'll have to call this procedure from a before row level trigger.
    HTH
    Naveen

  • Primary key and Foreign Key

    Hello,
             I have a question which was asked in an interview
    Can a Primary key in a table also act as a foreign key in the same table ?
    If yes than please provide a simple example
    Thanks
    www.techgulf.blogspot.com

    See this illustration
    create table t
    id int identity(1,1) not null primary key,
    val varchar(100)
    create table t2
    id int not null primary key,
    val varchar(100)
    -- make pk itself as fk to table t
    alter table t2 add constraint fk_t2 foreign key (id) references t(id)
    --some test values to t
    insert t (val)
    values ('test'),('test1'),('test2')
    -- populate t2 first two suceeds
    insert t2(id,val)
    values (1,'iuyi')
    insert t2(id,val)
    values (2,'ef24r')
    -- this will fail as we dont have record with id 4 in t
    insert t2(id,val)
    values (4,'weqw')
    --check the output
    select * from t
    select * from t2
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Lost about 60-75% of my primary and foreign keys when Migrating from SQL Server 7

    Hi All,
    I did an almost successful migration between SQL Server 7.0 and Oracle9i.
    What happened:
    I seem to have lost my primary and foreign keys in the migration. The funny thing is when I viewed the constraints and indexes in Toad, they were there. However when I tried to enabled those constraints nothing happened.
    I really don't know how I can fixed this, but I don't understand why I didn't get a warning or an error message in the Migration Workbench (latest version).
    I did ignore the following errors, could that have anything to do with the keys being lost.
    Failed to create User:omwb_emulation; ORA-1920: user name "OMWB_EMULATION" conflicts with another user or role name
    Failed to create User:guest;ORA-01920: user name "GUEST" conflicts with another user or role name
    These users do not own any objects therefore I ignored them.
    Please advise
    Thanks

    Hi Joe,
    Not sure why you are able to see these objects and yet not able to enable them. Did you encounter any errors during the create Oracle Model phase?? Did you encounter any errors during the final Migrate phase?
    Also, it is really important to have a tablespace created before an attempt is made to create tables and indexes in the destination Oracle database.
    Regards
    John

  • Primary and Foreign Keys

    I've attempted to identify a primary and foreign key in these two tables, but I am getting a bunch of errors re duplicate keys and column names needing to be unique. Can someone explain to me what I am doing wrong? I have watched numerous tutorials. Perhaps
    the primary and foreign key I have identified don't meet the criteria?
    CREATE TABLE StockNames
    -- Added Primary key to [stock_symbol]
    [stock_symbol] VARCHAR(5) NOT NULL CONSTRAINT PK_stock_symbol PRIMARY KEY,
    [stock_name] VARCHAR(150) NOT NULL,
    [stock_exchange] VARCHAR(50) NOT NULL,
    GO
    stock_symbol stock_name stock_exchange
    AEA American External Accessories NYSE
    ASP All Sports Portal NYSE
    AIT Anthony Interest Technology NYSE
    ATV American Technology Vehicles NYSE
    ACM Anderson Charles and Mitchell NYSE
    ACH American Career Helpers NYSE
    AVA Alleviate America NYSE
    and the second table
    CREATE TABLE DailyPricesA (
    [stock_symbol] VARCHAR (5) NOT NULL CONSTRAINT FK_stocksymbol REFERENCES [StockNames]([stock_symbol]),
    [date] VARCHAR (15) NOT NULL,
    [stock_price_open] FLOAT (53) NOT NULL,
    [stock_price_high] FLOAT (53) NOT NULL,
    [stock_price_low] FLOAT (53) NOT NULL,
    [stock_price_close] FLOAT (53) NOT NULL,
    [stock_volume] INT NOT NULL,
    [stock_price_adj_close] FLOAT (53) NOT NULL,
    stock_exchange stock_symbol date stock_price_open stock_price_high stock_price_low stock_price_close stock_volume stock_price_adj_close
    NYSE AEA 8/02/2010 4.42 4.42 4.21 4.24 205500 4.24
    NYSE AEA 5/02/2010 4.42 4.54 4.22 4.41 194300 4.41
    NYSE AEA 4/02/2010 4.55 4.69 4.39 4.42 233800 4.42

    Hi Stan,
    I have removed "stock_exchange" - that removed that error. These are the other errors I am experiencing:Msg
    2714, Level 16, State 6, Line 8
    There is already an object named 'DailyPricesA' in the database.
    Msg 2714, Level 16, State 6, Line 36
    There is already an object named 'StockNames' in the database.
    Msg 2627, Level 14, State 1, Line 47
    Violation of PRIMARY KEY constraint 'PK__StockNam__117C59C768B2BB7F'. Cannot insert duplicate key in object 'dbo.StockNames'. The duplicate key value is (AA).
    The statement has been terminated.
    Msg 1913, Level 16, State 1, Line 54
    The operation failed because an index or statistics with name 'SNIndex' already exists on table 'DailyPricesA'.
    And the code:
    USE NYSEDatabaseProject
    -- Drop the table to clean up database.
    --DROP TABLE DailyPricesA
    --GO
    -- Create the table.
    CREATE TABLE DailyPricesA (
    [stock_symbol] VARCHAR (5) NOT NULL CONSTRAINT FK_stocksymbol REFERENCES [StockNames]([stock_symbol]),
    [date] VARCHAR (15) NOT NULL,
    [stock_price_open] FLOAT (53) NOT NULL,
    [stock_price_high] FLOAT (53) NOT NULL,
    [stock_price_low] FLOAT (53) NOT NULL,
    [stock_price_close] FLOAT (53) NOT NULL,
    [stock_volume] INT NOT NULL,
    [stock_price_adj_close] FLOAT (53) NOT NULL,
    -- Add a foreign key.
    -- [stock_symbol] VARCHAR (5) NOT NULL CONSTRAINT FK_stocksymbol REFERENCES [StockNames]([stock_symbol]),
    BULK INSERT DailyPricesA
    from 'C:\Users\fenwky\NYSE_daily_prices_A.csv'
    -- firstrow = 2 skips the header row, field terminator =',' deterines the separator, and rowterminator defines where the row ends
    with (firstrow = 2, fieldterminator = ',', rowterminator = '\n')
    GO
    -- Create an index named DPAIndex, for the columns stock_symbol//'DPAIndex' already exists on table 'DailyPricesA'
    --CREATE INDEX DPAIndex
    --ON DailyPricesA (stock_symbol);
    -- Drop the table to clean up database.
    -- DROP TABLE StockNames
    -- GO
    CREATE TABLE StockNames
    -- Added Primary key to [stock_symbol]
    [stock_symbol] VARCHAR(5) NOT NULL CONSTRAINT PK_stock_symbol PRIMARY KEY,
    [stock_name] VARCHAR(150) NOT NULL,
    [stock_exchange] VARCHAR(50) NOT NULL,
    GO
    -- Insert the CSV into the table named Stocknames
    BULK INSERT StockNames
    from 'C:\Users\fenwky\NYSE_stock_names.csv'
    -- firstrow = 2 skips the header row, field terminator =',' deterines the separator, and rowterminator defines where the row ends
    with (firstrow = 2, fieldterminator = ',', rowterminator = '\n')
    GO
    -- Create an index named SNIndex, for the columns stock_symbol and stock_exchange.
    CREATE INDEX SNIndex
    ON DailyPricesA (stock_symbol);
    -- Select all from DailyPricesA
    select * from StockNames

  • Difference between PRIMARY KEY and UNIQUE KEY with NOT NULL

    What is the difference between PRIMARY KEY and UNIQUE KEY with NOT NULL constraint?
    Message was edited by:
    Nilesh Hole

    Answer for the master!!!
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:8743855576462
    Thanks,
    Karthick

  • Lack of Primary and Foreign Keys and Efficiency

    I am reverse engineering a Maximo database. I am shock that it does not have Primary or foreign keys define for 590 out of 620 tables.
    My question is does the lack of Primary and Foreign key relationships adversely impact the efficiency of an Oracle database? I think it does IBM techs do not think it does.
    Anyone has the answer?

    does the lack of Primary and Foreign key relationships adversely impact the efficiency of an Oracle database? Not necessarily. There are many large OLTP databases that do not define PKs and FKs.
    It is true that the presence of constraint defintions is used by the optimizer. However,
    what matters is how the application is written and how the optimizer handles it.
    Remember that Oracle Databases have been in production since before constraint definitions were introduced.
    Hemant K Chitale
    Edited by: Hemant K Chitale on Jun 9, 2010 10:05 AM

  • About Surrogate Key and Dimension Key on OWB 10.2

    Hi, everyone.
    I am using OWB 10.2 and I have a question about Surrogate key and Dimension Key.
    I indicated the foreign key as VARCHAR2 type in Fact Table and Dimension Key as VARCHAR2 type is operated as Primary key in Dimension Table. I made Single Level in Dimension Table.
    I know that Dimension Key stores the surrogate ID for dimension and is the primary key of the table. Also, Surrogate ID should be only NUMBER type.
    So, in this case, Surrogate ID is NUMBER type
    Dimension key should be NUMBER type to store the surrogate ID.
    But, Dimension key also should operate the primary to relate Foreign key as VARCHAR2 type.
    How I can solve this confusing condition?
    Please let me know that.
    JWS

    Hi JWS,
    From a SQL point of view it should not be a problem to join a NUMBER field to a VARCHAR2 field because during execution there will be an implicite cast for the NUMBER value to a VARCHAR2 value. See the example below.
       SELECT * FROM DUAL
       WHERE   1 = '1'From an OWB point of view it is not possible to have a Dimension with an NUMBER value Key that has a relation to a VARCHAR2 value Foreign key in a Fact table. This is caused due to the creation of a Fact table in OWB in which the Foreign keys in it are build from de Dimension tables that refer to them.
    You will loose the reference to the Dimension when changing the type of the Foreign Key.
    To resolve this issue I would advise you to use a Sequence that generates your Surrogate Key (NUMBER type) for the Dimension table and store it in the Primary Key Column (VARCHAR2 type).
    When validating the mapping you will get a warning, but when executing this should give no problems.
    Regards,
    Ilona

  • Diff b/w primary key and unique key?

    what is the diff b/w primary key and unique key?

    Hi,
    With respect to functionality both are same.
    But in ABAP we only have Primary key for the Database tables declared in the Data Dictionary.
    Unique is generally is the term used with declaring key's for internal tables.
    Both primary and Unique keys can identify one record of a table.
    Regards,
    Sesh

  • Did elationship fields in entity bean with CMP same as foreign key in table

    did elationship fields in entity bean with CMP same as foreign key in table database.so we don't have to make some foreign key column in table database.
    did Container handle that both.
    I need some answer
    thank's

    Suppose you have Group and user entity. Relation is 1-m. One group many users. When you create user, you dont need to send group id, All you need is create user and add it in collection (cmr-field) in group(user belongs to). Container will add its group id in user entity as well as in db.

  • Workflow with item type and item key  is in progress. Abort existing workfl

    Dear all,
    I'm using the below code from the submit button event to launch the workflow. The workflow works fine when I submit for the first time, when i try to submit for the second time from the same session it throws me the error as Workflow with item type and item key is in progress. Abort existing workflow.
    Where I am struck,Kindly send me any solution.
    I am using below code in oaf
    public void workflow(OAPageContext pageContext,
    String headerId,
    String empName,
    String userName
    String wfItemType = "XXSample";
    String wfProcess = "XXSample";
    String wfItemKey = headerId;
    OANavigation wfClass = new OANavigation();
    // Create Workflow Process
    wfClass.createProcess(pageContext, wfItemType, wfProcess, wfItemKey);
    System.out.println("Workflow created");
    wfClass.setItemAttrText(pageContext,
    wfItemType,
    wfItemKey,
    "XXHDRID",
    headerId);
    wfClass.setItemAttrText(pageContext,
    wfItemType,
    wfItemKey,
    "XXEMPNAME",
    employeeName);
    wfClass.setItemOwner(pageContext, wfItemType, wfItemKey,username);
    wfClass.startProcess(pageContext, wfItemType, wfProcess, wfItemKey);
    System.out.println("Workflow started");
    Thanks,
    Kumar.

    Item type and item key forms unique record for the workflow session, you cannot have 2 instances of the workflow running for the same header id, in your case. Check if the process exists for the header id. If so, display a warning message without launching another workflow session, else start the workflow process.
    Thanks
    Shree

  • Repairing Library Permissions: But the instructions didn't work  clicking the iPhoto icon with the Option and Command keys opened iPhoto but not the First Aid as promised

    Went to Help.  But the instructions didn't work
    clicking the iPhoto icon with the Option and Command keys opened iPhoto but not the First Aid as promised

    Give this a try:
    1 -be sure to have a current backup of the iPhoto library.
    2 - download and launch http://www.macchampion.com/arbysoft/BatChmod.
    3 - click on the File button, locate and select your iPhoto Library.
    4 - check the Unlock and Apply to enclosed checkboxes.
    5 - make no changes to the other checkboxes
    6 - click on the Apply button.
    OT

Maybe you are looking for

  • How do I get my videos to all work correctly in Photoshop Album Starter Edition Ver. 3.0?

    I have been using version 3.0 for the last 3 years and had no problems with any of my videos playing once they were downloaded from my mobile phone or camera to version 3.0 until August 2007 but now a lot of them say 'The selected file cannot be play

  • XBLNR  field in DME file (classic payment medium program)

    Hi ,          My client wants XBLNR field in the DME file which is created from automatic programme F110,can u please advise whether it is possible if yes can u please tell the procedure to do the same i.e whether we should use any function module ,

  • ITunes Match songs on library with external drive

    Hi, I have all my music on an external drive (and my library files on the internal drive). I activated iTunes Match so I can listen to my music when the drive is not present. iTunes Match activated succefully and I see all my music on my iPhone. But

  • Acrobat X Crash when double clicking PDFs

    I have reinstalled it from our CS5 disks but nothing has changed. It just crashes and tells me to restore the window. That's all well and good but this is happening almost all the time. I quit viewing the PDFs I make from InDesign because of this pro

  • Where are the API Docs of the appserv-rt.jar classes and others?

    Where do I find the API Documentation/Specification for the classes of : com.iplanet ... com.sun.appserv ... com.sun.enterprise.security ... The very of appserv-rt.jar and appserv-rt-ee.jar I need it for AS7 (J2EE 1.3) and AS8 (J2EE 1.4). Something l