如何使用最小的数据库往返进行gedcom导入。什么是这种发展的最佳实践

时间:2010-04-28 05:19:11

标签: gedcom

在我目前的申请中, 我需要从gedcom文件导入用户。 这些用户可能存在于我的注册用户中,或者我需要为其创建一个注册用户。 现在gedcom文件包含很多信息 例如个人详细信息,地址,教育详细信息,ProfessionalDetails 这是我们存储的一个xml文件样本,用于存储用户的个人资料。

<UserProfile xmlns="">
  <BasicInfo>
    <Title value="Basic Details" />
    <Fields>
      <UserId title="UserId" right="Public" value="151" />
      <EmailAddress title="Email Address" right="CUG" value="XYZ@gmail.com" />
      <FirstName title="First Name" right="Public" value="Anju" />
      <LastName title="Last Name" right="Public" value="Trivedi" />
      <DisplayName title="Display Name" right="Private" value="Anju" />
      <RegistrationStatusId title="RegistrationStatusId" right="Public" value="19" />
      <RegistrationStatus title="Registration Status" right="Private" value="Registered" />
      <CityId title="CityId" right="Private" value="19" />
      <CityName title="City" right="Public" value="Delhi" />
      <StateId title="StateId" right="Private" value="69" />
      <StateName title="State" right="Public" value="Delhi" />
      <CountryId title="CountryId" right="Private" value="109" />
      <CountryName title="Country" right="Public" value="India" />
      <Gender title="Gender" right="Private" value="Male" />
      <CreatedBy title="CreatedBy" right="Public" value="0" />
      <CreatedOn title="CreatedOn" right="Public" value="Nov 27 2009  3:08PM " />
      <ModifiedBy title="ModifiedBy" right="Public" value="13" />
      <ModifiedOn title="ModifiedOn" right="Public" value="Mar  3 2010  6:56PM " />
      <LogInStatusId title="LogInStatusId" right="Public" value="1" />
      <LogInStatus title="LogIn Status" right="Private" value="Free" />
      <ProfileImagePath title="Profile Pic" right="Public" value="~/Images/13_HolidayBarbie07CL2010427143129.jpg" />
      <ProfileThumbnailPath title="Profile Thumbnail" right="Public" value="~/Images/Thumb13_HolidayBarbie07CL2010427143129.jpg" />
    </Fields>
  </BasicInfo>
  <PersonalInfo>
    <Title value="Personal Details" />
    <Fields>
      <Nickname title="Nick Name" right="Public" value="Anju" />
      <NativeLocation title="Native" right="Public" value="Mehsana" />
      <DateofAnniversary title="Anniversary Dt." right="Private" value="4/1/2010" />
      <BloodGroupId title="BloodGroupId" right="Public" value="24" />
      <BloodGroupName title="Blood Group" right="Public" value="A+" />
      <MaritalStatusId title="MaritalStatusId" right="Private" value="35" />
      <MaritalStatusName title="Marital status" right="Private" value="UnMarried" />
      <DateofDeath title="Death dt" right="Private" value="" />
      <CreatedBy title="CreatedBy" right="Public" value="" />
      <CreatedOn title="CreatedOn" right="Public" value="" />
      <ModifiedBy title="ModifiedBy" right="Public" value="13" />
      <ModifiedOn title="ModifiedOn" right="Public" value="4/27/2010 2:32:07 PM" />
      <DateOfBirth title="Birth Date" value="" right="Public" />
      <BirthPlace title="Birth Place" value="Jaipur" right="Private" />
    </Fields>
  </PersonalInfo>
  <FamilyInfo>
    <Title value="Family Details" />
    <Fields>
      <GallantryHistory title="Gallantry History" right="Public" value="Anjli History" />
      <Ethinicity title="Ethinicity" right="Public" value="Indian" />
      <KulDev title="KulDev" right="Public" value="Krishna" />
      <KulDevi title="KulDevi" right="Public" value="Lakhsmi" />
      <Caste title="Caste" right="Private" value="Vaishnav" />
      <SunSignId title="SunSignId" right="Public" value="15" />
      <SunSignName title="SunSignName" right="Public" value="Gemini" />
    </Fields>
  </FamilyInfo>
  <HobbyInfo>
    <Title value="Hobbies/Interests" />
    <Fields>
      <AbountMe title="Abount Me" right="Public" value="" />
      <Hobbies title="Hobbies" right="Public" value="" />
      <Food title="Food" right="Public" value="" />
      <Movies title="Movies" right="Public" value="" />
      <Music title="Music" right="Public" value="" />
      <TVShows title="TV Shows" right="Public" value="" />
      <Books title="Books" right="Public" value="" />
      <Sports title="Sports" right="Public" value="" />
      <Will title="Will" right="Public" value="" />
      <FavouriteQuotes title="Favourite Quotes" right="Public" value="" />
      <CremationPrefernces title="Cremation Prefernces" right="Public" value="" />
    </Fields>
  </HobbyInfo>
  <PermenantAddr>
    <Title value="Permenant Address" />
    <Fields>
      <Address title="Address" right="Public" value="Select" />
      <CityId title="CityId" right="Public" value="116" />
      <CityName title="City" right="Public" value="Iran" />
      <StateId title="StateId" right="Public" value="95" />
      <StateName title="State" right="Public" value="Iran" />
      <CountryId title="CountryId" right="Public" value="7" />
      <CountryName title="Country" right="Public" value="Afghanistan" />
      <ZipCode title="ZipCode" right="Private" value="" />
    </Fields>
  </PermenantAddr>
  <PresentAddr>
    <Title value="Present Address" />
    <Fields>
      <Address title="Address" right="Public" value="Select" />
      <CityId title="CityId" right="Public" value="1" />
      <CityName title="City" right="Public" value="Select" />
      <StateId title="StateId" right="Public" value="1" />
      <StateName title="State" right="Public" value="Select" />
      <CountryId title="CountryId" right="Public" value="1" />
      <CountryName title="Country" right="Public" value="Select" />
      <ZipCode title="ZipCode" right="Private" value="" />
    </Fields>
  </PresentAddr>
  <ContactInfo>
    <Title value="Contact Details" />
    <Fields>
      <DayPhoneNo title="Day Phone" right="Public" value="" />
      <NightPhoneNo title="Night Phone" right="Public" value="" />
      <MobileNo title="Mobile No" right="Private" value="" />
      <FaxNo title="Fax No" right="CUG" value="" />
    </Fields>
  </ContactInfo>
  <EmailInfo>
    <Title value="Alternate Email Addresses" />
    <Fields>
      <Record right="Public">
        <Id title="Id" right="Public" value="3" />
        <Provider title="Provider" right="Public" value="google" />
        <EmailAddress title="Email Address" right="Public" value="am@gmail.com" />
        <IsActive title="IsActive" right="Public" value="false" />
        <CreatedBy title="CreatedBy" right="Public" value="13" />
        <CreatedOn title="CreatedOn" right="Public" value="Mar  3 2010 10:17AM " />
        <ModifiedBy title="ModifiedBy" right="Public" value="0" />
        <ModifiedOn title="ModifiedOn" right="Public" value="                    " />
      </Record>
      <Record right="Public">
        <Id title="Id" right="Public" value="4" />
        <Provider title="Provider" right="Public" value="Yahoo" />
        <EmailAddress title="Email Address" right="Public" value="am@yahoo.co.in" />
        <IsActive title="IsActive" right="Public" value="false" />
     </Record>
      <Record right="Private">
        <Provider value="111" right="Private" />
        <EmailAddress value="111@11.com" right="Private" />
        <Id value="5" />
     </Record>
    </Fields>
  </EmailInfo>
  <AcademicInfo>
    <Title value="Education Details" />
    <Fields>
      <Record right="Public">
        <Id title="Id" right="Public" value="0" />
        <Education title="Education" right="Public" value="" />
        <Institute title="Institute" right="Public" value="" />
        <PassingYear title="Passing Year" right="Public" value="" />
       </Record>
    </Fields>
  </AcademicInfo>
  <AchievementInfo>
    <Title value="Achievement Details" />
    <Fields>
      <Record right="Public">
        <Id title="Id" right="Public" value="0" />
        <Awards title="Award" right="Public" value="" />
        <FieldOfAward title="Field Of Award" right="Public" value="" />
        <Tournament title="Tournament" right="Public" value="" />
        <AwardDescription title="Description" right="Public" value="" />
        <AwardYear title="Award Year" right="Public" value="" />
      </Record>
    </Fields>
  </AchievementInfo>
  <ProfessionalInfo>
    <Title value="Professional Details" />
    <Fields>
      <Record right="Public">
        <Id title="Id" right="Public" value="4" />
        <Occupation title="Occupation" right="Public" value="a" />
        <Organization title="Organization" right="Public" value="a" />
        <ProjectsDescription title="Description" right="Public" value="a" />
        <Duration title="Duration" right="Public" value="2" /
      </Record>
      <Record right="Public">
        <Id title="Id" right="Public" value="5" />
        <Occupation title="Occupation" right="Public" value="ab" />
        <Organization title="Organization" right="Public" value="zsd" />
        <ProjectsDescription title="Description" right="Public" value="sd" />
        <Duration title="Duration" right="Public" value="5" />
      </Record>
      <Record right="Public">
        <Id title="Id" right="Public" value="8" />
        <Occupation title="Occupation" right="Public" value="fgdf" />
        <Organization title="Organization" right="Public" value="gdfg" />
        <ProjectsDescription title="Description" right="Public" value="dfgdf" />
        <Duration title="Duration" right="Public" value="12" />
      </Record>
      <Record right="Public">
        <Id title="Id" right="Public" value="9" />
        <Occupation title="Occupation" right="Public" value="fgdf" />
        <Organization title="Organization" right="Public" value="gdfg" />
        <ProjectsDescription title="Description" right="Public" value="dfgdf" />
        <Duration title="Duration" right="Public" value="12" />
      </Record>
      <Record right="Public">
        <Id title="Id" right="Public" value="10" />
        <Occupation title="Occupation" right="Public" value="fgdf" />
        <Organization title="Organization" right="Public" value="gdfg" />
        <ProjectsDescription title="Description" right="Public" value="dfgdf" />
        <Duration title="Duration" right="Public" value="12" />
      </Record>
    </Fields>
  </ProfessionalInfo>
</UserProfile>

现在当我从gedcom导入数据时,我正在创建一个包含所有这些信息的人物对象。 但在我插入之前,itodatabase必须检查是否存在用于电子邮件地址的用户ID不更新数据 否则创建一个用户并从gedcom的数据中更新其profilexml。

对于这个我认为我需要一些解决方案,通过它我只能进行一次往返数据库并可以更新所有用户的xml。

或者我可以执行一个sp从所有用户获取userid,我将检查用户是否存在然后返回userid else插入基本数据并返回插入的userid

然后为每个用户从数据中创建xml并更新它。

请提供建议进行此类开发的最佳做法。

如果需要更多细节,请写信给我

1 个答案:

答案 0 :(得分:0)

您可以向数据库发送一个查询以获取新文件的用户:

select * from person_table where userId=foo@foo.com  or  userID = bar@bar.com or ...

然后,从结果中你可以检查结果集中是否有每个用户的记录并相应地进行处理。