The test class org.apache.tuscany.das.rdb.test.CompoundKeyTests does contain some initial tests that demonstrate and verify the use of compound keys. Examples from here could be added to the User's Guide. It would be best if all current Relationship tests were duplicated using compound keys.

Thanks,
--Kevin



Amita Vadhavkar wrote:

Hi All,

Title: There are no tests in the current suite that exercise relationships
formed by compound keys.
We need to add this for completeness

Ref: IN RDB DAS User Guide - WorkingWithCompoundKeys section - It is
explicitly stated that JIRA-841 is for
demonstrating relationship with compound FKs.

I am trying to describe different cases and out of that which case is
pertaining
to JIRA-841. Please check and give comments. According to below
categorization,
JIRA-841 will take care of case C# only.

Test cases will typically be similar to RelationShipTests.

####################################################################################################
A# Compound key - key consisting of more than 1 column,  can be PK or FK
#################################################################################################### B# Compound PK - compound key where combination of all columns values in the
row form
the key and that is unique across the table rows, but the individual columns
values
are not necessarily unique across the table rows. This constraint does not
span
across multiple tables, and thus no question of any relationships.

e.g.
Table: OrderDetails
Columns: {ORDERID, PRODUCTID}, DETAILS
Compound PK: {ORDERID, PRODUCTID}

Config-
<Config xmlns="http:///org.apache.tuscany.das.rdb/config.xsd";>
   <Table tableName="ORDERDETAILS">
       <Column columnName="ORDERID" primaryKey="true"/>
       <Column columnName="PRODUCTID" primaryKey="true"/>
   </Table>

</Config>
#################################################################################################### C# Compound FK - compound key where the columns in the key form FKs having
relationship with
other tables.

e.g.
Table: OrderDetails
Columns: {ORDERID, PRODUCTID}, DETAILS
Compound PK:{ORDERID, PRODUCTID}

Table: OrderDetailsDescription
Columns: ID, {ORDERID, PRODUCTID}, DETAILS
PK: ID
Compound FK: {ORDERID, PRODUCTID} where the compound key is PK in some other
table viz. OrderDetails

Config-
<Config xmlns="http:///org.apache.tuscany.das.rdb/config.xsd";>

 <Table tableName="ORDERDETAILS">
  <Column columnName="PRODUCTID" primaryKey="true"/>
 <Column columnName="ORDERID" primaryKey="true"/>
 </Table>

 <Table tableName="ORDERDETAILSDESC">
  <Column columnName="ID" primaryKey="true"/>
 </Table>

 <Relationship name="orderDetailsAnOrder" primaryKeyTable="ORDERDETAILS"
foreignKeyTable="ORDERDETAILSDESC" many="true">
    <KeyPair primaryKeyColumn="PRODUCTID" foreignKeyColumn="PRODUCTID"/>
    <KeyPair primaryKeyColumn="ORDERID" foreignKeyColumn="ORDERID"/>
 </Relationship>

</Config>
####################################################################################################
D# There can be case of multiple FKs but not necessarily Compound FK

e.g.
Table: Order
Columns: ID, DETAILS
PK:ID

Table: Product
Columns: ID, NAME
PK: ID

Table: OrderDetails
Columns: {ORDERID, PRODUCTID}, DETAILS
Compound PK:{ORDERID, PRODUCTID}
FK: ORDERID where Order.ID is PK
FK: PRODUCTID where Product.ID is PK
Config-
<Config xmlns="http:///org.apache.tuscany.das.rdb/config.xsd";>

 <Table tableName="ORDERDETAILS">
  <Column columnName="PRODUCTID" primaryKey="true"/>
 <Column columnName="ORDERID" primaryKey="true"/>
 </Table>

 <Table tableName="ANORDER">
  <Column columnName="ID" primaryKey="true"/>
 </Table>

 <Table tableName="PRODUCT">
  <Column columnName="ID" primaryKey="true"/>
 </Table>

 <Relationship name="orderDetailsAnOrder" primaryKeyTable="ANORDER"
foreignKeyTable="ORDERDETAILS" many="true">
    <KeyPair primaryKeyColumn="ID" foreignKeyColumn="ORDERID"/>
 </Relationship>

 <Relationship name="orderDetailsProduct" primaryKeyTable="PRODUCT"
foreignKeyTable="ORDERDETAILS" many="true">
    <KeyPair primaryKeyColumn="ID" foreignKeyColumn="PRODUCTID"/>
 </Relationship>
</Config>
##################################################################################

Regards,
Amita




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to