Databases Reference
In-Depth Information
Usually the entities in the conceptual model are closely related to the tables and views in
the storage model. However, entity types are higher-level constructs and do not necessar-
ily match the database tables they represent. In particular, the Product entity has a singu-
lar name, but the Products table name is plural. It also has navigation properties that
allow you to traverse entity relationships without having to immediately resort to joins in
LINQ queries.
Following is the raw XML definition of the Product entity. Notice that the XML element
names, EntityType , Key , and Property , are similar to those used in the storage model defi-
nition. The NavigationProperty element, on the other hand, is used only in the concep-
tual model:
<EntityType Name=”Product”>
<Key>
<PropertyRef Name=”ProductID” />
</Key>
<Property Name=”ProductID” Type=”Int32” Nullable=”false”
annotation:StoreGeneratedPattern=”Identity” />
<Property Name=”ProductName” Type=”String” Nullable=”false”
MaxLength=”40” Unicode=”true” FixedLength=”false” />
<Property Name=”SupplierID” Type=”Int32” />
<Property Name=”CategoryID” Type=”Int32” />
<Property Name=”QuantityPerUnit” Type=”String” MaxLength=”20”
Unicode=”true” FixedLength=”false” />
<Property Name=”UnitPrice” Type=”Decimal” Precision=”19” Scale=”4” />
<Property Name=”UnitsInStock” Type=”Int16” />
<Property Name=”UnitsOnOrder” Type=”Int16” />
<Property Name=”ReorderLevel” Type=”Int16” />
<Property Name=”Discontinued” Type=”Boolean” Nullable=”false” />
<NavigationProperty Name=”Supplier” FromRole=”Product” ToRole=”Supplier”
Relationship=”NorthwindModel.FK_Products_Suppliers” />
<NavigationProperty Name=”Category” FromRole=”Product” ToRole=”Category”
Relationship=”NorthwindModel.FK_Products_Categories” />
<NavigationProperty Name=”Order_Details”
FromRole=”Product” ToRole=”Order_Detail”
Relationship=”NorthwindModel.FK_Order_Details_Products” />
</EntityType>
Some database tables, such as the EmployeeTerritories in the Northwind sample database,
might not have corresponding entity types at all. The many-to-many association between
the Employees and the Territories tables requires a third table, sometimes called a “junc-
tion table,” to implement in a relational database system. However, in the conceptual
entity model, the many-to-many association between the Employee and Territory entities
can be supported directly by their Territories and Employees navigation properties.
 
Search WWH ::




Custom Search