how to do gedcom import with minimal database roundtrip. what is best practice for this kind of dev

Posted by Radhi on Stack Overflow See other posts from Stack Overflow or by Radhi
Published on 2010-04-28T05:19:10Z Indexed on 2010/04/28 5:23 UTC
Read the original article Hit count: 554

In My current application, I need to import users from gedcom file. these users may exist in my registered users or i need to create one registered user for the same. now gedcom file contain s many information e.g. PersonalDetails,Addresses, Education Details, ProfessionalDetails this is one sample of xml file we are storing to store user's profile.

<UserProfile xmlns="">
  <BasicInfo>
    <Title value="Basic Details" />
    <Fields>
      <UserId title="UserId" right="Public" value="151" />
      <EmailAddress title="Email Address" right="CUG" value="[email protected]" />
      <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="10" />
      <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="CUG" />
      <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" />
      <CreatedBy title="CreatedBy" right="Public" value="13" />
      <CreatedOn title="CreatedOn" right="Public" value="Dec 11 2009 12:00AM " />
      <ModifiedBy title="ModifiedBy" right="Public" value="13" />
      <ModifiedOn title="ModifiedOn" right="Public" value="Dec 11 2009 12:00AM " />
    </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="" />
      <CreatedBy title="CreatedBy" right="Public" value="" />
      <CreatedOn title="CreatedOn" right="Public" value="" />
      <ModifiedBy title="ModifiedBy" right="Public" value="" />
      <ModifiedOn title="ModifiedOn" 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="" />
      <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/6/2010 10:48:39 AM" />
    </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="" />
      <CreatedBy title="CreatedBy" right="Public" value="" />
      <CreatedOn title="CreatedOn" right="Public" value="" />
      <ModifiedBy title="ModifiedBy" right="Public" value="" />
      <ModifiedOn title="ModifiedOn" right="Public" 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="" />
      <CreatedBy title="CreatedBy" right="Public" value="" />
      <CreatedOn title="CreatedOn" right="Public" value="" />
      <ModifiedBy title="ModifiedBy" right="Public" value="" />
      <ModifiedOn title="ModifiedOn" right="Public" 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="[email protected]" />
        <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="[email protected]" />
        <IsActive title="IsActive" right="Public" value="false" />
        <CreatedBy title="CreatedBy" right="Public" value="13" />
        <CreatedOn title="CreatedOn" right="Public" value="Mar  3 2010  6:53PM " />
        <ModifiedBy title="ModifiedBy" right="Public" value="0" />
        <ModifiedOn title="ModifiedOn" right="Public" value="                    " />
      </Record>
      <Record right="Private">
        <Provider value="111" right="Private" />
        <EmailAddress value="[email protected]" right="Private" />
        <Id value="5" />
        <IsActive value="true" right="Private" />
        <ModifiedBy value="13" right="Private" />
        <ModifiedOn value="Tuesday, March 16, 2010" right="Private" />
      </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="" />
        <IsActive title="IsActive" right="Public" value="" />
        <CreatedBy title="CreatedBy" right="Public" value="" />
        <CreatedOn title="CreatedOn" right="Public" value="" />
        <ModifiedBy title="ModifiedBy" right="Public" value="" />
        <ModifiedOn title="ModifiedOn" 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="" />
        <IsActive title="IsActive" right="Public" value="" />
        <CreatedBy title="CreatedBy" right="Public" value="" />
        <CreatedOn title="CreatedOn" right="Public" value="" />
        <ModifiedBy title="ModifiedBy" right="Public" value="" />
        <ModifiedOn title="ModifiedOn" 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" />
        <IsActive title="IsActive" right="Public" value="false" />
        <CreatedBy title="CreatedBy" right="Public" value="13" />
        <CreatedOn title="CreatedOn" right="Public" value="Jan  7 2010  1:14PM " />
        <ModifiedBy title="ModifiedBy" right="Public" value="13" />
        <ModifiedOn title="ModifiedOn" right="Public" value="Jan  7 2010  1:14PM " />
      </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" />
        <IsActive title="IsActive" right="Public" value="false" />
        <CreatedBy title="CreatedBy" right="Public" value="13" />
        <CreatedOn title="CreatedOn" right="Public" value="Jan  7 2010  1:15PM " />
        <ModifiedBy title="ModifiedBy" right="Public" value="13" />
        <ModifiedOn title="ModifiedOn" right="Public" value="Jan  7 2010  1:15PM " />
      </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" />
        <IsActive title="IsActive" right="Public" value="false" />
        <CreatedBy title="CreatedBy" right="Public" value="13" />
        <CreatedOn title="CreatedOn" right="Public" value="Feb 22 2010  5:07PM " />
        <ModifiedBy title="ModifiedBy" right="Public" value="0" />
        <ModifiedOn title="ModifiedOn" right="Public" value="Jan  1 1900 12:00AM " />
      </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" />
        <IsActive title="IsActive" right="Public" value="false" />
        <CreatedBy title="CreatedBy" right="Public" value="13" />
        <CreatedOn title="CreatedOn" right="Public" value="Feb 22 2010  5:11PM " />
        <ModifiedBy title="ModifiedBy" right="Public" value="0" />
        <ModifiedOn title="ModifiedOn" right="Public" value="Jan  1 1900 12:00AM " />
      </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" />
        <IsActive title="IsActive" right="Public" value="false" />
        <CreatedBy title="CreatedBy" right="Public" value="13" />
        <CreatedOn title="CreatedOn" right="Public" value="Feb 22 2010  5:13PM " />
        <ModifiedBy title="ModifiedBy" right="Public" value="0" />
        <ModifiedOn title="ModifiedOn" right="Public" value="Jan  1 1900 12:00AM " />
      </Record>
    </Fields>
  </ProfessionalInfo>
  <SecuritySettings>
    <AlbumRights>
      <Create value="Private" />
      <View value="CUG" />
      <Edit value="CUG" />
      <Delete value="CUG" />
      <PostComments value="CUG" />
      <AddToAlbum value="CUG" />
    </AlbumRights>
    <ImageRights>
      <Create value="Private" />
      <View value="CUG" />
      <Edit value="CUG" />
      <Delete value="CUG" />
      <PostComments value="Private" />
    </ImageRights>
  </SecuritySettings>
</UserProfile>

now when i am importing data from gedcom, i am creating one person object which contains all this info. but before i insert it itodatabase have to check if userid exist for the emailaddress dont update data else create a user and update its profilexml from data fecthed from gedcom.

for this i think i need some soln by which i can do only one roundtrip to database and can update all user's xml.

or i can execute one sp to get userid from all users where i'll check if user exist then return userid else insert basic data and return inserted userid

then for every user make xml from data and update it.

please provide be suggestion what is best practice to do this kind of development.

if need any more details please write me

© Stack Overflow or respective owner

Related posts about gedcom

Related posts about database-queries