What do each of the files do inside of an iPhoto Library?
Basically, all the files like xml, db and such help different softwares like iPhoto, iMovies etc gain information about your photos.

Excerpted from Fat Cat Software: iPhoto Library Internals help page:


  AlbumData.xml
  
  This file is written out by iPhoto as a way for other applications
  (such as iMovie and iDVD) to be able to easily access the contents of
  your iPhoto library. You can read in more detail about this file here.
  
  AlbumData2.xml
  
  This file is only created by iPhoto 8. It is a smaller version of the
  AlbumData.xml file that only contains information for the library's
  albums and events, and none of the actual photos. This file is faster
  to read for programs that only need to get the list of albums and
  events in the library.
  
  Attachments
  
  This folder is used by iPhoto 9 as a temporary holding place for
  photos that are being sent using iPhoto's built-in email features.
  
  Auto Import
  
  This folder is created by iPhoto 7 and later. There does not seem to
  be any mention of this folder in iPhoto's documentation, but if you
  put some photos into it, then quit and reopen iPhoto, it will
  automatically import those photos into the iPhoto library and then
  delete them from the Auto Import folder. There is also an "auto
  import" Applescript command which does not appear to do anything when
  called. It's not clear if this was a planned feature for iPhoto 7 that
  ended up getting pulled out (but not completely, apparently), and it
  doesn't seem to be very useful for anything, especially since that
  folder is buried inside a package now, but that's what it does if
  anyone is curious.
  
  Backup
  
  If a library has been upgraded from an earlier version of iPhoto to
  iPhoto 9, a copy of the original database files from the library are
  stored in this folder before performing the upgrade.
  
  Caches
  
  Only present in iPhoto 8 or later, this folder contains additional
  data for the iPhoto library. Unlike some other Caches folders that can
  be safe to delete, this one is not, so don't go deleting it in an
  attempt to clear up disk space.
  
  com.apple.iPhoto.plist
  
  This file is actually not written out by iPhoto itself, but rather by
  iPhoto Library Manager. It is a copy of the preferences file that is
  associated with this library. When you switch between different iPhoto
  libraries, iPhoto Library Manager will swap out this preference file
  for the existing preferences before opening the library up.
  
  Contents/PkgInfo
  
  This is part of the new package structure in iPhoto 7 that gives the
  package a type and creator code so that the Finder knows what
  application the package belongs to.
  
  face.db, face_blob.db
  
  Contains the data for faces identified by the face recognition feature
  added in iPhoto 8.
  
  iLifeShared
  
  Starting in iPhoto 9, the AlbumData2.xml file is now stored within
  this folder rather than at the root level of the library package.
  
  Info.plist
  
  iPhoto 9 added this file, containing basic version information about
  the library
  
  iPhoto.ipspot
  
  This file is written out by iPhoto and read in by Spotlight in order
  to index the information about the photos in your photo library. You
  must have iPhoto 5.0.2 or later for this file to be present.
  
  iPhotoLock.data
  
  This file is used by iPhoto to help prevent more than one copy of
  iPhoto from accessing the library at one time.
  
  iPod Photo Cache
  
  This folder is created by iTunes if you choose to sync your iPhoto
  library with a photo capable iPod. It contains cached information
  about the last time the photos were synced and help speed up the
  syncing process, allowing iTunes to tell which photos have changed
  since the last sync and only update those ones. You can delete it if
  you want to clear up space, but iTunes will have to create it all over
  again the next time you sync your iPod's photos.
  
  Library.data, Dir.data (iPhoto 2), Library.iPhoto, iPhoto.db (iPhoto 4, &amp; 5), Library.iPhoto6 (iPhoto 6 &amp; 7), iPhotoMain.db, iPhotoAux.db
  (iPhoto 8), Database (iPhoto 9)
  
  These files/folders serve as the central database where iPhoto stores
  your library information. All your event, album, and photo metadata is
  stored in these files.
  
  Data, Originals, and Modified
  
  iPhoto 6 organizes its photos fairly differently that previous
  versions. Imported photos will initially be stored inside the
  "Originals" folder. Within that folder, photos are organized into
  subfolders based on the roll that they are in, so each roll gets its
  own folder. Those rolls are then sorted by date (2006, 2005, etc.) and
  put into dated folders accordingly. So, if you had a photo in a roll
  named "Vacation" and dated February 24, 2004, to find that photo, go
  into the "Originals" folder, then into "2004", then into the folder
  named "Vacation". When you edit a photo in iPhoto, the original stays
  where it is, and the edited photo is placed in the "Modified" folder,
  which has the same per-roll organization scheme within it as the
  "Originals" folder does. The "Data" folder contains all the scaled
  down thumbnail version of photos in your library. If you upgrade to
  iPhoto 6 from a previous version, iPhoto will rearrange all your
  photos from the old scheme into the new scheme. After upgrading, you
  may still see one or more leftover folders named "2004" and such.
  These folders should no longer contain any files being used by iPhoto
  6, and can be disposed of safely.
  
  Thumbnails, Masters, and Previews
  
  iPhoto 9 organizes photos in much the same way as iPhoto 6-8, but uses
  the folder names Thumbnails, Masters, and Previews instead of Data,
  Originals, and Modified
  
  Metadata Backup
  
  Created by iPhoto 8, containing backup copies of the metadata for your
  photos, events, albums, and other library content. This information
  can be used by iPhoto to recover a library whose main database has
  been corrupted.
  
  ProjectDBVersion.plist, Projects.db, Projects.db-journal, SharingActivity.db
  
  These additional data files exist only in iPhoto 9 and contain
  information relating to "keepsake" items such as books and slideshows,
  and information for albums published on MobileMe, Flickr, or Facebook.
  
  ThemeCache
  
  A cache file used by iPhoto to store theme data used to make books,
  calendars, and cards
  
  Thumb32Segment.data, Thumb64Segment.data, ThumbJPGSegment.data
  
  In order to improve performance, when you add photos to your library,
  iPhoto creates small "thumbnail" versions of your photos and caches
  them in these files. In iPhoto 5 and earlier, these files are instead
  called Thumb32.data, Thumb64.data, and ThumbJPG.data.


Note that there are some small and some large differences in the folder structure depending on what version of iPhoto you're using.