28.01.2013 Views

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Simple Associations<br />

The definition of an association requires you to specify a name, which references two exposed entities and whose<br />

columns keep the relationship information. To distinguish the ends of the association, you must use the keywords<br />

principal and dependent. In addition, it is necessary to denote the multiplicity for each end of the<br />

association.<br />

Service definition: sample.odata:assocsimple.xsodata<br />

service {<br />

"sample.odata:customer.hdbtable" as "Customers";<br />

"sample.odata:order.hdbtable" as "Orders";<br />

association "Customer_Orders" principal "Customers"("ID") multiplicity<br />

"1" dependent "Orders"("CustomerID") multiplicity "*";<br />

}<br />

The association in the example above with the name Customer_Orders defines a relationship between the<br />

table customer, identified by its EntitySet name Customers, on the principal end, and the table<br />

order, identified by its entity set name Orders, on the dependent end. Involved columns of both tables are<br />

denoted in braces ({}) after the name of the corresponding entity set. The multiplicity keyword on each end<br />

of the association specifies their cardinality - in this example, one-to-many.<br />

The number of columns involved in the relationship must be equal for both ends of the association, and their order<br />

in the list is important. The order specifies which column in one table is compared to which column in the other<br />

table. In this simple example, the column customer.ID is compared to order.CustomerID in the generated<br />

table join.<br />

As a result of the generation of the service definition above, an AssociationSet named Customer_Orders<br />

and an Association with name Customer_OrdersType are generated:<br />

http://localhost:8002/sample/odata/assocsimple.xsodata/$metadata<br />

196<br />

P U B L I C<br />

© 2012 <strong>SAP</strong> AG. All rights reserved.<br />

<strong>SAP</strong> <strong>HANA</strong> <strong>Developer</strong> <strong>Guide</strong><br />

Defining Web-based Data Access

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!