OData used Entity Data Model to describe the data exposed
by an OData service.
Entity data model describes the structure of data,
regardless of how it stored physically (For example, data can be stored in
RDBMS, xls file, repositories, Hadoop system, file systems etc.,). Since data
stored in different databases can follow different schema, EDM comes up with a
generic approach by describing the data in the form of EDM.
Basic things to understand in EDM.
a.
Entities
b.
Entity Types
c.
Complex Types
d.
Entity Sets
e.
Dynamic Property
Entities
Entities are the instance of entity types. An entity type
can be any class like Employee, Customer, Product etc.,
Entity Type
Entity type describes the structure of data with the
Entity Data Model. Entity type define the properties and relationships of an
entity. All the Entity types must have a key.
For example, EntityType for the vehicle Car is defined
like below.
<EntityType Name="Car"> <Key> <PropertyRef Name="Id" /> </Key> <Property Name="Id" Type="Edm.Int16" /> <Property Name="Model" Type="Edm.String" /> <Property Name="ModelYear" Type="Edm.String" MaxLength="4" /> <Property Name="Price" Type="Edm.Decimal" Scale="2" /> <Property Name="Currency" Type="Edm.String" MaxLength="3" /> </EntityType>
One EntityType can refer other complex types (Which are
not basic types like Edm.Int16, Edm.String etc.,). In the below example, Entity
type ‘Manufacturer’ is referring Address entity type.
<EntityType Name="Manufacturer"> <Key> <PropertyRef Name="Id" /> </Key> <Property Name="Id" Type="Edm.Int16" /> <Property Name="Name" Type="Edm.String" /> <Property Name="Address" Type="olingo.odata.sample.Address" /> </EntityType> <ComplexType Name="Address"> <Property Name="Street" Type="Edm.String" /> <Property Name="City" Type="Edm.String" /> <Property Name="ZipCode" Type="Edm.String" /> <Property Name="Country" Type="Edm.String" /> </ComplexType>
As you see, complex type does not have key.
In simple terms,
Entity type: A
structured type with a key.
Complex type: A
structured type without a key.
Entity Sets
Entity sets are the named collection of entities.
EntityKey
It is formed from a subset of properties of the
EntityType. It is used to uniquely identify the entity type instances
For example, CustomerId is used to uniquely identify a
customer entity.
No comments:
Post a Comment