2

I am in the process of designing RESTful web services and got stuck at one point. The design is very simple with 3 entities:

- Project
- Status
- Employee

The part I am having trouble with is capturing the relationships:

- A project has a current status (1 to 1 between Project and Status).
- A project has multiple 'possible subsequent status' (1 to many between Project and Status).

The Visual Studio designer does not allow these two different relationships to be defined between these two entities. I am aware that it is just a modelling tool but at the same time, I am willing to know if this is the right approach.

Also, with this design, I am not sure how to access the Status entities using these two relationships.

http://serviceRootURL/Project(2)?$expand=Status // For current status
http://serviceRootURL/Project(2)?$expand=SubsequentStatus // For subsequent status

Is it possible to use arbitrary relationship names with the expand keyword?

(The question probably touches OData a little bit as well since I am trying to make my library OData-compliant.)

3 Answers 3

1

In VS 2012 Express, I was able to model two relationships between the same entities separately in an EDMX model. By selecting the relationship in the canvas, you can use the property pane on the right to give them different names and cardinalities. Also pay attention to the parent property name (in the pane, it's the "End2 Navigation Property").

Having modeled the relationships and exposed the model through OData, you can use the OData $expand option with the name of the relationship (like what you showed) to embed the related entities in the response to parent entities.

1

Do the current 'possible subsequent status' only depend on the current project status?

If yes then you could also model the possible status values as an entity with 1 occurence per status value. This would cause a change in the relationship between project and status to n:1 (a status can have any number of projects).

Add another recursive relationship "possible subsequent status" from status to status with a cardinality of 1:n.

Nice side effect of this is that you can easily list the projects with a particular status by starting with the status and following the relationship to the projects :-)

Don't know how well this can be modeled in VS or expressed in REST, sorry. But that would seem like a good model to me.

0

As in Domain Driven Design, it is possible to qualify the relationship wrt time? Then for a particular time period, you will have one-to-one relationship between Project and Status. Hence, you can define only one relationship?

Sorry, no clue about REST at all

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.