6 Replies Latest reply on Mar 25, 2015 1:14 AM by sanjeev.gour

    What is the best way to assign primary keys to views for OData

    sanjeev.gour

      Hi-

      I am trying the expose the VDB as REST using OData. It works but I need advise for cases where I don't have primary keys. There are two cases-

      1. There is a table in the database with a primary key column, this table is directly available in the VDB and it can accessed through OData. - No issues.
      2. There is a table in the database with a primary key and there is a view in the VDB around this table with no primary key defined. There are issues around this-
        1. If there is no primary key on the view,it is not accessible through OData.
        2. If the same primary column in the database table is marked as primary key in the VDB, I get an error as "Primary already defined for the view". It happens for DB2 but worked fine for H2.
        3. If I add a new column to the view as select UUID() as ID, columns from the table....the view becomes accessible through OData.

       

      I am looking for some advise about the best practice for defining the primary keys for almost every table that I need to access.

      Is defining a view on every table with the additional UUID column a good option, possibly alter view in a central location? Or there are better ways to handle this case.

       

      I am using Teiid 8.7.

       

      Thanks.

      Sanjeev.