From ef07ea019356fa809324bbf4da452b93abd5edd1 Mon Sep 17 00:00:00 2001 From: Rhet Turnbull Date: Sun, 5 Jul 2020 16:50:13 -0700 Subject: [PATCH] Updated Photos version 5 database (markdown) --- Photos-version-5-database.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Photos-version-5-database.md b/Photos-version-5-database.md index 42b2380..bb9b14b 100644 --- a/Photos-version-5-database.md +++ b/Photos-version-5-database.md @@ -28,6 +28,23 @@ Under the hood, Photos.app uses [Core Data](https://developer.apple.com/library/ ## Albums +### Album Sort Order +In Catalina, the table `Z_26ASSETS` maps albums to photos. It has 3 columns: + +- `Z_26ALBUMS`: foreign key to `ZGENERICALBUM` +- `Z_34ASSETS`: foreign key to `ZGENERICASSET` +- `Z_FOK_34ASSETS`: while this appears to be a foreign key I think it's actually a sort order (see discussion below) + +If you add photos to an album, the value for `Z_FOK_34ASSETS` for each photos begins at 2048 then increments by 1024 (2^10) for each photo added, e.g. 2048, 3072, 4096, 5120. In the screenshot below, album with `Z_26ALBUMS` = `64` (`ZGENERICALBUM.Z__PK` = 64) has 4 photos added one at a time but not manually sorted: + +Screenshot 2020-07-05 16 42 44 + +In the screenshot below, the last photo (`Z_34ASSETS` = 2) was manually re-ordered to the beginning of the album and has a new value for `Z_FOK_34ASSETS` of 1024 which places it before the previous first photo with value of 2048. + +Screenshot 2020-07-05 16 45 10 + +If you change the sort order manually, the value of `Z_FOK_34ASSETS` of the photo(s) you manually moved changes so that if ordered by `Z_FOK_34ASSETS`, the photos will be arranged in the new order. + **TODO** Document the following * [ ] Joining assets