Condividi tramite


Schema di archiviazione del modello Sales di AdventureWorks (EDM)

In Entity Data Model (EDM) i metadati di archiviazione sono definiti nel linguaggio SSDL (Store Schema Definition Language). In questo esempio lo schema SSDL rappresenta le tabelle e le chiavi dei dati nel database di esempio AdventureWorks.

Schema SSDL

Nell'esempio seguente sono contenuti i metadati per cinque tabelle del database AdventureWorks. La sintassi XML viene utilizzata per definire le strutture del modello di archiviazione. I set di entità rappresentano le tabelle. I tipi di entità rappresentano le righe. Le proprietà rappresentano le colonne nelle righe. Le associazioni rappresentano relazioni di chiavi esterne. I set di associazioni definiscono in modo logico l'ambito delle associazioni.

Questo schema è utilizzato per il mapping del modello incluso nell'argomento precedente Schema concettuale del modello Sales di AdventureWorks (EDM) all'archivio.

Lo schema SSDL completo è illustrato nell'esempio seguente.

<?xml version="1.0" encoding="utf-8"?>
<Schema Namespace="AdvWrksSalesModel.Store" Alias="Self"
    Provider="System.Data.SqlClient"
    ProviderManifestToken="2005"
    xmlns="https://schemas.microsoft.com/ado/2006/04/edm/ssdl">
  <EntityContainer Name="Person">
    <EntitySet Name="Address" EntityType="AdvWrksSalesModel.Store.Address" />
    <EntitySet Name="Contact" EntityType="AdvWrksSalesModel.Store.Contact" />
    <EntitySet Name="Product" EntityType="AdvWrksSalesModel.Store.Product" Schema="Production" />
    <EntitySet Name="SalesOrderDetail" EntityType="AdvWrksSalesModel.Store.SalesOrderDetail" Schema="Sales" />
    <EntitySet Name="SalesOrderHeader" EntityType="AdvWrksSalesModel.Store.SalesOrderHeader" Schema="Sales" />
    <AssociationSet Name="FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID" Association="AdvWrksSalesModel.Store.FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID">
      <End Role="SalesOrderHeader" EntitySet="SalesOrderHeader" />
      <End Role="SalesOrderDetail" EntitySet="SalesOrderDetail" />
    </AssociationSet>
    <AssociationSet Name="FK_SalesOrderHeader_Address_BillToAddressID" Association="AdvWrksSalesModel.Store.FK_SalesOrderHeader_Address_BillToAddressID">
      <End Role="Address" EntitySet="Address" />
      <End Role="SalesOrderHeader" EntitySet="SalesOrderHeader" />
    </AssociationSet>
    <AssociationSet Name="FK_SalesOrderHeader_Address_ShipToAddressID" Association="AdvWrksSalesModel.Store.FK_SalesOrderHeader_Address_ShipToAddressID">
      <End Role="Address" EntitySet="Address" />
      <End Role="SalesOrderHeader" EntitySet="SalesOrderHeader" />
    </AssociationSet>
    <AssociationSet Name="FK_SalesOrderHeader_Contact_ContactID" Association="AdvWrksSalesModel.Store.FK_SalesOrderHeader_Contact_ContactID">
      <End Role="Contact" EntitySet="Contact" />
      <End Role="SalesOrderHeader" EntitySet="SalesOrderHeader" />
    </AssociationSet>
  </EntityContainer>
  <EntityType Name="Address">
    <Key>
      <PropertyRef Name="AddressID" />
    </Key>
    <Property Name="AddressID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
    <Property Name="AddressLine1" Type="nvarchar" Nullable="false" MaxLength="60" />
    <Property Name="AddressLine2" Type="nvarchar" MaxLength="60" />
    <Property Name="City" Type="nvarchar" Nullable="false" MaxLength="30" />
    <Property Name="StateProvinceID" Type="int" Nullable="false" />
    <Property Name="PostalCode" Type="nvarchar" Nullable="false" MaxLength="15" />
    <Property Name="rowguid" Type="uniqueidentifier" Nullable="false" />
    <Property Name="ModifiedDate" Type="datetime" Nullable="false" />
  </EntityType>
  <EntityType Name="Contact">
    <Key>
      <PropertyRef Name="ContactID" />
    </Key>
    <Property Name="ContactID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
    <Property Name="NameStyle" Type="bit" Nullable="false" />
    <Property Name="Title" Type="nvarchar" MaxLength="8" />
    <Property Name="FirstName" Type="nvarchar" Nullable="false" MaxLength="50" />
    <Property Name="MiddleName" Type="nvarchar" MaxLength="50" />
    <Property Name="LastName" Type="nvarchar" Nullable="false" MaxLength="50" />
    <Property Name="Suffix" Type="nvarchar" MaxLength="10" />
    <Property Name="EmailAddress" Type="nvarchar" MaxLength="50" />
    <Property Name="EmailPromotion" Type="int" Nullable="false" />
    <Property Name="Phone" Type="nvarchar" MaxLength="25" />
    <Property Name="PasswordHash" Type="varchar" Nullable="false" MaxLength="128" />
    <Property Name="PasswordSalt" Type="varchar" Nullable="false" MaxLength="10" />
    <Property Name="AdditionalContactInfo" Type="xml" />
    <Property Name="rowguid" Type="uniqueidentifier" Nullable="false" />
    <Property Name="ModifiedDate" Type="datetime" Nullable="false" />
  </EntityType>
  <EntityType Name="Product">
    <Key>
      <PropertyRef Name="ProductID" />
    </Key>
    <Property Name="ProductID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
    <Property Name="Name" Type="nvarchar" Nullable="false" MaxLength="50" />
    <Property Name="ProductNumber" Type="nvarchar" Nullable="false" MaxLength="25" />
    <Property Name="MakeFlag" Type="bit" Nullable="false" />
    <Property Name="FinishedGoodsFlag" Type="bit" Nullable="false" />
    <Property Name="Color" Type="nvarchar" MaxLength="15" />
    <Property Name="SafetyStockLevel" Type="smallint" Nullable="false" />
    <Property Name="ReorderPoint" Type="smallint" Nullable="false" />
    <Property Name="StandardCost" Type="money" Nullable="false" />
    <Property Name="ListPrice" Type="money" Nullable="false" />
    <Property Name="Size" Type="nvarchar" MaxLength="5" />
    <Property Name="SizeUnitMeasureCode" Type="nchar" MaxLength="3" />
    <Property Name="WeightUnitMeasureCode" Type="nchar" MaxLength="3" />
    <Property Name="Weight" Type="decimal" Precision="8" Scale="2" />
    <Property Name="DaysToManufacture" Type="int" Nullable="false" />
    <Property Name="ProductLine" Type="nchar" MaxLength="2" />
    <Property Name="Class" Type="nchar" MaxLength="2" />
    <Property Name="Style" Type="nchar" MaxLength="2" />
    <Property Name="ProductSubcategoryID" Type="int" />
    <Property Name="ProductModelID" Type="int" />
    <Property Name="SellStartDate" Type="datetime" Nullable="false" />
    <Property Name="SellEndDate" Type="datetime" />
    <Property Name="DiscontinuedDate" Type="datetime" />
    <Property Name="rowguid" Type="uniqueidentifier" Nullable="false" />
    <Property Name="ModifiedDate" Type="datetime" Nullable="false" />
  </EntityType>
  <EntityType Name="SalesOrderDetail">
    <Key>
      <PropertyRef Name="SalesOrderID" />
      <PropertyRef Name="SalesOrderDetailID" />
    </Key>
    <Property Name="SalesOrderID" Type="int" Nullable="false" />
    <Property Name="SalesOrderDetailID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
    <Property Name="CarrierTrackingNumber" Type="nvarchar" MaxLength="25" />
    <Property Name="OrderQty" Type="smallint" Nullable="false" />
    <Property Name="ProductID" Type="int" Nullable="false" />
    <Property Name="SpecialOfferID" Type="int" Nullable="false" />
    <Property Name="UnitPrice" Type="money" Nullable="false" />
    <Property Name="UnitPriceDiscount" Type="money" Nullable="false" />
    <Property Name="LineTotal" Type="numeric" Nullable="false" Precision="38" Scale="6" StoreGeneratedPattern="Computed" />
    <Property Name="rowguid" Type="uniqueidentifier" Nullable="false" />
    <Property Name="ModifiedDate" Type="datetime" Nullable="false" />
  </EntityType>
  <EntityType Name="SalesOrderHeader">
    <Key>
      <PropertyRef Name="SalesOrderID" />
    </Key>
    <Property Name="SalesOrderID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
    <Property Name="RevisionNumber" Type="tinyint" Nullable="false" />
    <Property Name="OrderDate" Type="datetime" Nullable="false" />
    <Property Name="DueDate" Type="datetime" Nullable="false" />
    <Property Name="ShipDate" Type="datetime" />
    <Property Name="Status" Type="tinyint" Nullable="false" />
    <Property Name="OnlineOrderFlag" Type="bit" Nullable="false" />
    <Property Name="SalesOrderNumber" Type="nvarchar" Nullable="false" MaxLength="25" StoreGeneratedPattern="Computed" />
    <Property Name="PurchaseOrderNumber" Type="nvarchar" MaxLength="25" />
    <Property Name="AccountNumber" Type="nvarchar" MaxLength="15" />
    <Property Name="CustomerID" Type="int" Nullable="false" />
    <Property Name="ContactID" Type="int" Nullable="false" />
    <Property Name="SalesPersonID" Type="int" />
    <Property Name="TerritoryID" Type="int" />
    <Property Name="BillToAddressID" Type="int" Nullable="false" />
    <Property Name="ShipToAddressID" Type="int" Nullable="false" />
    <Property Name="ShipMethodID" Type="int" Nullable="false" />
    <Property Name="CreditCardID" Type="int" />
    <Property Name="CreditCardApprovalCode" Type="varchar" MaxLength="15" />
    <Property Name="CurrencyRateID" Type="int" />
    <Property Name="SubTotal" Type="money" Nullable="false" />
    <Property Name="TaxAmt" Type="money" Nullable="false" />
    <Property Name="Freight" Type="money" Nullable="false" />
    <Property Name="TotalDue" Type="money" Nullable="false" StoreGeneratedPattern="Computed" />
    <Property Name="Comment" Type="nvarchar" MaxLength="128" />
    <Property Name="rowguid" Type="uniqueidentifier" Nullable="false" />
    <Property Name="ModifiedDate" Type="datetime" Nullable="false" />
  </EntityType>
  <Association Name="FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID">
    <End Role="SalesOrderHeader" Type="AdvWrksSalesModel.Store.SalesOrderHeader" Multiplicity="1">
      <OnDelete Action="Cascade" />
    </End>
    <End Role="SalesOrderDetail" Type="AdvWrksSalesModel.Store.SalesOrderDetail" Multiplicity="*" />
    <ReferentialConstraint>
      <Principal Role="SalesOrderHeader">
        <PropertyRef Name="SalesOrderID" />
      </Principal>
      <Dependent Role="SalesOrderDetail">
        <PropertyRef Name="SalesOrderID" />
      </Dependent>
    </ReferentialConstraint>
  </Association>
  <Association Name="FK_SalesOrderHeader_Address_BillToAddressID">
    <End Role="Address" Type="AdvWrksSalesModel.Store.Address" Multiplicity="1" />
    <End Role="SalesOrderHeader" Type="AdvWrksSalesModel.Store.SalesOrderHeader" Multiplicity="*" />
    <ReferentialConstraint>
      <Principal Role="Address">
        <PropertyRef Name="AddressID" />
      </Principal>
      <Dependent Role="SalesOrderHeader">
        <PropertyRef Name="BillToAddressID" />
      </Dependent>
    </ReferentialConstraint>
  </Association>
  <Association Name="FK_SalesOrderHeader_Address_ShipToAddressID">
    <End Role="Address" Type="AdvWrksSalesModel.Store.Address" Multiplicity="1" />
    <End Role="SalesOrderHeader" Type="AdvWrksSalesModel.Store.SalesOrderHeader" Multiplicity="*" />
    <ReferentialConstraint>
      <Principal Role="Address">
        <PropertyRef Name="AddressID" />
      </Principal>
      <Dependent Role="SalesOrderHeader">
        <PropertyRef Name="ShipToAddressID" />
      </Dependent>
    </ReferentialConstraint>
  </Association>
  <Association Name="FK_SalesOrderHeader_Contact_ContactID">
    <End Role="Contact" Type="AdvWrksSalesModel.Store.Contact" Multiplicity="1" />
    <End Role="SalesOrderHeader" Type="AdvWrksSalesModel.Store.SalesOrderHeader" Multiplicity="*" />
    <ReferentialConstraint>
      <Principal Role="Contact">
        <PropertyRef Name="ContactID" />
      </Principal>
      <Dependent Role="SalesOrderHeader">
        <PropertyRef Name="ContactID" />
      </Dependent>
    </ReferentialConstraint>
  </Association>
</Schema>

Vedere anche

Concetti

Schema concettuale del modello Sales di AdventureWorks (EDM)
Schema di mapping del modello Sales di AdventureWorks (EDM)
Connessione al modello Sales di AdventureWorks (EDM)