1

データセットまたはデータテーブルをxmlファイルに保存しようとしているのではなく、関連データを保存するためのxml構造を作成していますか?たとえば、以下のデータがxmlファイルにどのように含まれるか知りたいです

ユーザー

UserId
Username
Password

役割

RoleId
UserId [FK]
CreatedOn

このようになりますか

<User userid="" username="" password="">
<Roles id="">
 <Name></Name>
 <Description></Description>
</Roles>
</User>

xmlファイルをDBとして使用するのに最適な構造

4

1 に答える 1

2

リレーショナルデータベースの場合と同様に、より正規化された方法でXMLを実装することを検討したいと思います。たとえば、現在のソリューションでは、次のようなすべてのユーザー内の役割構造全体を入力する必要があります。

<User userid="1" username="user01" password="password">
   <Roles id="1">
      <Name>Role 1</Name>
      <Description>This is Role 1</Description>
   </Roles>
</User>
<User userid="2" username="user02" password="password">
   <Roles id="1">
      <Name>Role 1</Name>
      <Description>This is Role 1</Description>
   </Roles>
</User>

正規化された構造は次のようになります

<Roles>
   <Role id="1">
      <Name>Role 1</Name>
      <Description>This is Role 1</Description>
   </Role>
</Roles>

<User id="1" username="user01" password="password">
   <Roles>
      <Role>1</Role>
   </Roles>
</User>
<User id="2" username="user02" password="password">
   <Roles>
      <Role>1</Role>
   </Roles>
</User>

お役に立てれば

于 2011-10-29T01:15:26.377 に答える