> Samples Tutorial
> Implementing Relationship Functions and Logical Modeling
Samples Tutorial
Implementing Relationship Functions and Logical Modeling
Relationship functions return data combined from two or more data services. For example, by creating a relationship between the Address and Customer data services, you can obtain the address for a given customer. Or by creating a relationship between the Customer and Order Management data services, you can receive data that identifies all orders returned by a particular customer.
Model diagrams are used to view a selected set of data services and the relationships between them. The model shows the basic structure of the data returned by the data service. The main purpose of the diagram is to help you envision meaningful subsets of your enterprise data relationships, but it can also be used to define new artifacts or edit existing artifacts.
Logical modeling is an extension of the physical modeling that you learned about in Tutorial 5: Modeling Data Services. There are three exercises in this lesson, which are to be completed in sequential order. The exercises in this tutorial are dependent on the work completed in the previous tutorials.
Objectives
After completing this lesson, you will be able to:
Create model diagrams for a logical data service.
Define relationships between data services.
View and implement multiple relationship functions.
Test multiple relationship functions.
Overview
To help you get from a complex, distributed physical data landscape to a more holistic view of enterprise information, ALDSP supports a visual, model-driven approach to developing data services. Modeling provides a graphical representation of the data resources in your environment, providing a bird's-eye view of a large system or giving you a way to create "zoomed" views of enterprise areas. In a model diagram data services appear as boxes, while relationships appear as annotated lines connection the data service representations. A relationship is only visible if both end points are also on the diagram.
The result is real-time access to externally persisted data through a logical data model.
20.1 Implementing and Testing a Relationship Function
The getCustomer_Order() function is intended to return customer order information for a specific customer. However, to accomplish that you need to add the ApparelDB data service's CUSTOMER_ORDER as a source schema, and then create a relationship with the target schema.
Objectives
In this exercise you will:
Implement a relationship function, using XQuery Editor View to define the return data service, by:
Identifying the data source.
Creating an overwrite map between source and target elements.
Creating a simple map between a parameter and a source element.
Test the relationship function created as a result of the mappings.
Instructions
Open CUSTOMER.ds in XQuery Editor View. The file is located in DataServices\CustomerDB.
Select getCustomer_Order(arg) from the Function drop-down list.
Figure 20-1 XQuery Editor View of getCustomer_Order Function
In Data Services Palette, expand the ApparelDB and CUSTOMER_ORDER.ds folders.
Drag and drop CUSTOMER_ORDER() into XQuery Editor View.
In XQuery Editor View, create an overwrite mapping between the CUSTOMER_ORDER source and Return elements by completing the following steps:
Press Ctrl.
Drag and drop the source node's CUSTOMER_ORDER* element onto the Return type's CUSTOMER_ORDER element.
Drag and drop the parameter's CUSTOMER_ID element onto the source node's C_ID element. Confirm that the getCustomer_Order() function is as displayed in Figure 20-2.
Figure 20-2 Joined and Mapped Function
Save your work and then build the DataServices project.
Open CUSTOMER.ds in Test View and run a test by completing the following steps:
Select getCUSTOMER_ORDER(arg) from the Function drop-down list.
Click Browse, navigate to, and open the <beahome>\weblogic81\samples\LiquidData\EvalGuide directory.
Select the customer.xml file.
Figure 20-3 Select XML File
Click Select. The contents of the file are inserted into the Parameters field.
Figure 20-4 Select XML File
Click Execute. The order information for CUSTOMER3 should appear.
Figure 20-5 Relationship Test Results
20.2 Creating a Model Diagram for Logical Data Services
Model diagrams display the basic structure of the data returned by a data service. A model diagram lets you view a selected set of data services and the relationships between them. The main purpose of the diagram is to help you envision meaningful subsets of the model, but it can also be used to define new artifacts or edit existing artifacts.
Objectives
In this exercise, you will:
Import a schema that provides a logical and unified representation of two separate physical data sources.
Create a basic model diagram by adding data services to the imported logical data service.
Create relationship functions between the modeled data services.
Instructions
Import the OrderManagement schema into the DataServices project folder by completing the following steps:
Right-click the DataServices project folder.
Choose Import.
Navigate to and open the <beahome>\weblogic81\samples\LiquidData\EvalGuide directory.
Select the OrderManagement folder.
Click Import. A new folder, OrderManagement, is created in the DataServices project. The imported schema contains logical representations of the two Order Management Systems (Apparel and Electronics), which make the two systems appear as if they are a single Order Management System.
Create a sub-folder within the Models folder by completing the following steps:
Right-click the MODELS folder, located in the DataServices folder.
Choose New Folder.
Enter Logical in the Name field.
Click OK.
Create a new logical model diagram by completing the following steps:
Right-click the Logical folder.
Choose New Model Diagram.
Enter OrderManagement_Logical_Model.md in the Name field.
Click Create.
Create a model for the OrderManagement data services by completing the following steps:
Expand the CustomerManagement, OrderManagement, and ServiceDB folders.
Drag and drop the following .ds files into the model:
Table 20-6 Model data services
Data Service File
Located in:
customerProfile.ds
CustomerManagement
address.ds
OrderManagement
Customer.ds
OrderManagement
customerOrder.ds
OrderManagement
customerOrderLineItem.ds
OrderManagement
orders.ds
OrderManagement
product.ds
OrderManagement
service_case.ds
ServiceDB
Your model diagram should be similar to that displayed in Figure 20-7. Notice that relationships between data services already exist. These relationships were generated during the Import Source Metadata process, and are based on the foreign key relationship defined in the underlying relational data.
Figure 20-7 Model Diagram for Logical Data Services
Create a relationship between the CustomerProfile and ADDRESS data services by completing the following steps:
Drag and drop the customer_id element (CustomerProfile) onto the CustomerID element (Address).
Click Finish in the Relationship Properties window.
Create a relationship between CustomerProfile and SERVICE_CASE data services by completing the following steps:
Drag and drop the customer_id (CustomerProfile) onto the CUSTOMER_ID element (SERVICE_CASE).
Click Finish in the Relationship Properties window.
Figure 20-8 New Relationships Defined
Open CustomerProfile.ds in Design View. You should see two new relationship functions, getAddress() (which navigates to the Address logical data service, located in OrderManagement) and getSERVICE_CASE() (which navigates to the SERVICE_CASE physical data service, located in ServiceDB).
Figure 20-9 New Functions
Save your work.
Lesson Summary
In this exercise, you learned to:
Import a schema that provides a logical and unified representation of two separate physical data sources.
Create a basic model diagram by adding data services to the imported logical data service.
Create relationship functions between the modeled data services.