Primary key in Fact table

Hi ,
I have a question usually fact table consists of all primary keys from different dimensional tables but i have a requirement like this:
Fact table consists of non-dimensional columns and one primary key Amount_ID(PK) aand this amount_ID is a FK in another table which records day to day transactions. My question is can a fact table have a PK ?
Thanks,
ch

Yes Fact Table can have a Primary key
But in your case it looks like the Other Table which is storing Day to Day transaction should be made FACT , and the one you are calling FACT should be made Dimension..
Well depends again, how you are analysing data and against which attributes
Thanks
Ashish

Similar Messages

  • What is the best practice for creating primary key on fact table?

    what is the best practice for primary key on fact table?
    1. Using composite key
    2. Create a surrogate key
    3. No primary key
    In document, i can only find "From a modeling standpoint, the primary key of the fact table is usually a composite key that is made up of all of its foreign keys."
    http://download.oracle.com/docs/cd/E11882_01/server.112/e16579/logical.htm#i1006423
    I also found a relevant thread states that primary key on fact table is necessary.
    Primary Key on Fact Table.
    But, if no business requires the uniqueness of the records and there is no materilized view, do we still need primary key? is there any other bad affect if there is no primary key on fact table? and any benifits from not creating primary key?

    Well, natural combination of dimensions connected to the fact would be a natural primary key and it would be composite.
    Having an artificial PK might simplify things a bit.
    Having no PK leads to a major mess. Fact should represent a business transaction, or some general event. If you're loading data you want to be able to identify the records that are processed. Also without PK if you forget to make an unique key the access to this fact table will be slow. Plus, having no PK will mean that if you want to used different tools, like Data Modeller in Jbuilder or OWB insert / update functionality it won't function, since there's no PK. Defining a PK for every table is a good practice. Not defining PK is asking for a load of problems, from performance to functionality and data quality.
    Edited by: Cortanamo on 16.12.2010 07:12

  • Duplicate record with same primary key in Fact table

    Hi all,
       Can the fact table have duplicate record with same primary key . When i checked a cube i could see records with same primary key combination but the key figure values are different. My cube has 6 dimentions (Including Time,Unit and DP) and 2 key figures. So 6 fields combined to form the composite primary key of the fact table. When i checked the records in se16 i could see duplicate records with same primary key. Ther are no parallel loading happening for the cube.
    BW system version is 3.1
    Data base is : Oracle 10.2
    I am not sure how is this possible.
    Regards,
    PM

    Hi Krish,
       I checked the datapacket dimention also. Both the record have same dimention id (141). Except the Keyfigure value there is no other change in the Fact table record.  I know this is against the basic DBMS primary key rule. But i have records like this in the cube.
    Can this situation arise when same records is there in different data packet of same request.
    Thx,
    PM
    null

  • Primary key in fact/Dimention/SID table?

    Hello sap gurus,
    2 Questions....
    Which is primary key in
    -Fact table (probably answer is .... combination of DIM_ID keys)
    -Dimention table ( probably answer is .... DIM_ID key)
    -SID table ( probably answer is .... SID_ID key)
    Thnx in advance

    Gaurav,
    You already have the answers. A very simple way to figure out the keys is to use the transaction LISTSCHEMA, it will list the tables in an Infocube. Once you have the tables , you can use se11/se12 to check the keys.
    For ODS information in BI 7, check the link below.
    http://help.sap.com/saphelp_nw70/helpdata/en/80/1a60cae07211d2acb80000e829fbfe/frameset.htm
    For ODS information in BW 3.5 , check the link below
    http://help.sap.com/saphelp_nw04/helpdata/en/c0/99663b3e916a78e10000000a11402f/frameset.htm
    -Saket

  • Null key in fact tables

    Hi all,
    I have one role play dimension with some null key in fact table, I liked know if it's a good practice?
    thanks

    Depends on what you actually mean..
    When one dimension column contains NULL in your fact table, then it's normally a bad practice. Create a entry in your dimension table to represent this state.
    The problem is that NULL is a state, which means does missing or inapplicable information. This means that the row in the fact table is semantically meaningless. Cause your fact table is no longer additive over this dimension.

  • Is it possible to create many primary key for a table?

    hello sir/mam.
    i am selva, i am new to abap,
    is it possible to create many primary key for a table?
    please guide me.

    Hi Selva,
    Many Primary Keys = Composite Key.
    i.e some set of columns will enable you to identify a unique row from a set of rows in the table.
    This can be achieved by checking the primary key check box in se11.
    Hope it helps.
    Regards,
    Maheswaran.B
    Message was edited by: Maheswaran B

  • How to define Composite primary key for a Table

    Hi ,
    I am basically more into Java Programming , with little bit knowledge on Oracle as DataBase .so please excuse for my silly doubts .
    Can anybody please tell me how to define a Composite Primary Key on a Table .
    Thanks in advance .
    Edited by: user672373773 on Sep 25, 2009 8:54 AM

    Here is an example right out of the Oracle documentation and the syntax for adding PK since you mention adding a composite PK.
    Example creating composite index
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_indexing.htm#sthref594
    Syntax for adding a PK (composite or not)
    alter table oooooooo.tttttttt
    add constraint tttttttt_PK
    primary key (sample_column2,
    sample_column1)
    using index
    tablespace IDXSPC
    pctfree 05
    initrans 04
    maxtrans 08
    storage (initial 16k
    next 16k
    maxextents 32
    pctincrease 0);
    -- dictionary management with restricted storage, change as desired.
    HTH -- Mark D Powell --

  • How to get the PRIMARY KEY of a table at runtime ???

    Hi everybody,
    My requirement is to update a z-table at runtime according to the data given ata runtime. So the main difficulties for me is that whenever I tried to update the table based on the data given in UI many rows are getting updated as these fields are not unique. So I think if I can get the PRIMARY KEY along with these given fields then I can update only one row at a time.
    So Can anyone suggest me how to get PRIMARY KEY of a table based on the data in UI..??
    Any suggestions will be appreciated..
    Thanks,
    Sekhar

    U will get primary keys of transparent tables using FM "REUSE_FIELDCALATLOG_MERGE".
    pass tyour table name and u will get fieldcatalog filled. In tht their is a field called "KEY" if it has 'X' then tht field is a primary key of transparent tables & if it has "space" then it is not a primary key...
    Or else you can try with 'DDIF_TABT_GET'
    Or try this code
    PARAMETERS: p_table TYPE tabname OBLIGATORY.
    DATA: go_strucdescr   TYPE REF TO cl_abap_structdescr,
          gt_tab_fields   TYPE ddfields.
    FIELD-SYMBOLS: <gwa_tab_field> TYPE dfies.
    TRY .
    *   Get the details of the DDIC table
        go_strucdescr ?= cl_abap_elemdescr=>describe_by_name( p_table ).
      CATCH cx_sy_move_cast_error .
        MESSAGE 'Error while casting' TYPE 'S'. RETURN.
    ENDTRY.
    * Check if input is a DDIC table
    CHECK go_strucdescr->is_ddic_type( ) = 'X'.
    * Get the details of the table fields
    gt_tab_fields = go_strucdescr->get_ddic_field_list( ).
    * Display the Key fields of the table
    LOOP AT gt_tab_fields ASSIGNING <gwa_tab_field> WHERE keyflag = 'X'.
      WRITE: / <gwa_tab_field>-fieldname.
    ENDLOOP.

  • How can I obtain the primary key of a table for an entity relation?

    hello everybody
    I am doing a consultation to a table in my data base, good this table has alone two fields, the first one is the code or pk and the second one is the description, to be presisos they are names of city and code.
    From the beginning!!: This method this one in another class that is a Dialog that is going to call to the class SelecPlace ();
      SelecPlace sl = new SelecPlace();
    public void capturarLugar(){  //  Simple void method in the mentioned class
            String place = txtProcedencia.getText() ;  //  a JTextField
            sl.executeStatement(place) ;                  
        }ok, now we see part of the code of the class SelectPlace
    public class SelecPlace extends AbstractTableModel{
        Connection con = null;
        Statement sentencia = null ;
        ResultSet rs = null;
        ResultSetMetaData rsmd = null ;
        String[] nameColum = {} ;
        Vector datos = new Vector() ;
        public SelecPlace() { }
        public void executeStatement(String query){
          try{
             con = DBManager.getConnection() ;
             sentencia = con.createStatement(rs.TYPE_SCROLL_INSENSITIVE,
                                                                          rs.CONCUR_UPDATABLE) ;
             String sql = "select * from Place where descripcion like %"+query+"%'";
              rs = sentencia.executeQuery(sql) ;
              rsmd = rs.getMetaData();
              int nroColumnas = rsmd.getColumnCount() ;
              nameColum = new String[nroColumnas] ;
              //obtengo los nombres de columnas en cache
               for(int colum = 0; colum < nroColumnas; columna++){
                    nameColum[colum] = rsmd.getColumnLabel(columna + 1) ;
               datos = new Vector();
                while(rs.next()){
                    Vector newRow = new Vector();
                    for(int i = 0; i < getColumnCount(); i++){
                    newRow.addElement(rs.getObject("place_ID"));
                    newRow.addElement(rs.getObject("description"));
                    datos.addElement(nuevaFila);
                fireTableChanged(null);
            }catch(SQLException e){
                System.err.println(e);
                e.printStackTrace(System.err);
                System.out.println("error in statement");
            }catch(ClassNotFoundException cnfe){
                System.err.println(cnfe);
        }Ok, this code me works and I obtain in this case the field description of the table Place
    Now my question is, how can I obtain the primary field of my table?
    I need this value of this field that in the base of information in a bigint, and to take it to the first class before mentioned, for that I am working with a data base related

    Certain duffymo and everyone!!, good I give you my scheme:
    And generalizing my question, I want to obtain the value of the primary key of a table in the database, I obtain more values of the same row, but I need the primary key, and you see one with the primary key I want to turn a Long and it to insert with code java in foreign clave in another table of the database
    Good of this form I believe that it would not be breaking the integrity relacional of the tables

  • Is there any restriction on the length of all Primary keys in a table

    Hi all,
    Is there any restriction on the length of all Primary keys in a data base table?
    i have some 10 fields as primary key in a DB table and length exceeds 120 and getting a warning.
    Please let me know will there be any problems in future with respect to the same?
    With regards,
    Sumanth

    Well actually there are constraints like
    Total of internal lengths of all primary key columns        1024 Bytes
    Number of primary key columns per table                     512
    For other information about SAP database please refer to http://sapdb.org/sap_db_features.htm  
    Thanks & Regards,
    Vivek Gaur
    Alwayz in high spirits

  • If I have an EntityBean that mappes to two tables within one database, when I create that EJB, whoes reponsibilty to generate the primary key in database table? The RDBMS or EJB?

    If I have an EntityBean that mappes to two tables within one database, when I create
    that EJB, whoes reponsibilty to generate the primary key in database table? The
    RDBMS or EJB?
    Thanks,
    JW

    Refer to http://e-docs.bea.com/wls/docs81/faq/ejb.html/#257430
    "Jingwei Zhang" <[email protected]> wrote:
    >
    If I have an EntityBean that mappes to two tables within one database,
    when I create
    that EJB, whoes reponsibilty to generate the primary key in database
    table? The
    RDBMS or EJB?
    Thanks,
    JW

  • Multiple composite primary key in Master Table

    Dears ,
    I am try to find any solution about Multiple composite primary key by search in forum , but i didn't success ... i am try to built master detail , the master structure table built with multiple composite primary key , i know that apex 4.2 still support tow primary key , in detail table i solved the problem by depend on rowid , and now i can use multiple composite primary key in detail table , the problem with master table because it's support only tow primary key , there are any solution by manual process or any something else ?
    Thanks
    Abo Yahya

    Hi,
    I've never done this so all I can do is give some suggestions. It takes more effort because you are going beyond what APEX currently supports. That said, you might try searching the forum with this search string:
    key AND table AND instead
    Make sure the ANDs are capitailized in the search criteria. Also, look at this thread {thread:id=395870} and the forum thread asociated with this message {message:id=10542916}.
    Best wishes,
    Howard

  • Composite primary key in oe_order_headers_all table?

    Hi all
    What are columns involved in composite primary key in oe_order_headers_all table? how to identify that?
    (Order_number, order_type, org_id) are the combination of composite primary key or anything else ?

    select * From all_constraints where table_name = 'OE_ORDER_HEADERS_ALL'
    SELECT AIC.* FROM ALL_INDEXES AI, ALL_IND_COLUMNS AIC
    WHERE AI.TABLE_NAME='OE_ORDER_HEADERS_ALL'
    AND AI.UNIQUENESS='UNIQUE'
    AND AI.INDEX_NAME = AIC.INDEX_NAME
    order by AI.INDEX_NAME
    Hope this helps,
    Sandeep Gandhi

  • Two Primary keys on one table

    We are at the end of completing a project and we ran into a last minute bug. We are using two primary keys on a table to form a unique key. The problem we have is the program hangs up and gives us the following error,
    ORA-20001: Error in DML: p_rowid=CUA, p_alt_rowid=SIT_ID, p_rowid2=, p_alt_rowid2=. ORA-01422: exact fetch returns more than requested number of rows,
    probably meaning we only have one key setup in the DML
    processing when our table has two.
    we created a process with the Primary key set up in the DML but how does the secondary key column value work and is that what it's used for,because we tryed with no success. Is there a way around this problem without having to change our table by inserting only one primary key.
    Thanks in advance.
    Garry

    I am facing a similar problem , I used the two primary keys for navigating to the form page (forms with reports) so that the form page may display distinct records.
    Its not posing any error but its not showing the value of other columns associated with that record.
    Only the columns contained in the page item in the form page , that's are used as primary keys or that have been specified in the navigation part of the report page, are being shown ,
    Like for example I have got 5 columns
    a,b,c,d,e out of which a and b are my primary keys .
    I am using these to fetch values in the form page of forms with reports.
    We can specify three keys at the most , in my case I am having two , if in place of the third key I specify some column then in the form page it displays the correct record details of the three columns specified( 2 keys and one simple column), and it doesn't displays the value of other columns.
    Please help me out of this .

  • How many primary keys for one table?can we add more primary keys

    In general Table have one  primary key.is it possible to more than one primary key in a table?(ie is it possible to add more than one pirmary key in a table). Help me out.

    pls do check this link
    [http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ea0b446011d189700000e8322d00/frameset.htm|http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ea0b446011d189700000e8322d00/frameset.htm]
    All the key fields of a table must be stored together at the beginning of the table. A non-key field may not occur between two key fields.
    A maximum of 16 key fields per table is permitted. The maximum length of the table key is 255.
    If the key length is greater than 120, there are restrictions when transporting table entries. The key can only be specified up to a maximum of 120 places in a transport. If the key is larger than 120, table entries must be transported generically.

Maybe you are looking for