Update database documentation
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
- [Tables Description](#tables-description)
|
- [Tables Description](#tables-description)
|
||||||
- [Records](#records)
|
- [Records](#records)
|
||||||
- [Records Search Index](#records-search-index)
|
- [Records Search Index](#records-search-index)
|
||||||
|
- [Artist Infos](#artist-infos)
|
||||||
- [Views](#views)
|
- [Views](#views)
|
||||||
- [Artist Records View](#artist-records-view)
|
- [Artist Records View](#artist-records-view)
|
||||||
- [Triggers](#triggers)
|
- [Triggers](#triggers)
|
||||||
@@ -34,8 +35,9 @@ erDiagram
|
|||||||
map musicbrainz_data
|
map musicbrainz_data
|
||||||
string[] release_ids
|
string[] release_ids
|
||||||
string[] included_release_group_ids
|
string[] included_release_group_ids
|
||||||
|
string selected_release_id
|
||||||
datetime purchased_at
|
datetime purchased_at
|
||||||
string release
|
string release_date
|
||||||
map artists
|
map artists
|
||||||
datetime inserted_at
|
datetime inserted_at
|
||||||
datetime updated_at
|
datetime updated_at
|
||||||
@@ -52,10 +54,21 @@ erDiagram
|
|||||||
string[] included_release_group_ids
|
string[] included_release_group_ids
|
||||||
string cover_hash
|
string cover_hash
|
||||||
datetime purchased_at
|
datetime purchased_at
|
||||||
string release
|
string release_date
|
||||||
map artists
|
map artists
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ARTIST_INFOS {
|
||||||
|
uuid id PK
|
||||||
|
map musicbrainz_data
|
||||||
|
map discogs_data
|
||||||
|
blob image_data
|
||||||
|
string image_data_hash
|
||||||
|
integer image_data_width
|
||||||
|
datetime inserted_at
|
||||||
|
datetime updated_at
|
||||||
|
}
|
||||||
|
|
||||||
ARTIST_RECORDS {
|
ARTIST_RECORDS {
|
||||||
uuid musicbrainz_id
|
uuid musicbrainz_id
|
||||||
uuid record_id
|
uuid record_id
|
||||||
@@ -63,7 +76,8 @@ erDiagram
|
|||||||
}
|
}
|
||||||
|
|
||||||
RECORDS ||--o{ RECORDS_SEARCH_INDEX : "syncs via triggers"
|
RECORDS ||--o{ RECORDS_SEARCH_INDEX : "syncs via triggers"
|
||||||
RECORDS ||--o{ ARTIST_RECORDS : "extracted from artists JSON"
|
RECORDS ||--o{ ARTIST_INFOS : "references via musicbrainz_id"
|
||||||
|
RECORDS ||--o{ ARTIST_RECORDS : "extracted via view"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Tables Description
|
## Tables Description
|
||||||
@@ -73,11 +87,14 @@ erDiagram
|
|||||||
The main table storing music records. Key features:
|
The main table storing music records. Key features:
|
||||||
|
|
||||||
- Uses UUID as primary key
|
- Uses UUID as primary key
|
||||||
- Stores basic record information (title, type, format, year)
|
- Stores basic record information (title, type, format)
|
||||||
- Includes MusicBrainz integration with IDs and additional data
|
- Includes MusicBrainz integration with IDs and additional data
|
||||||
- Stores cover image data and URLs
|
- Stores cover image data and URLs
|
||||||
- Embeds artists data directly in a JSON field
|
- Embeds artists data directly in a JSON field
|
||||||
- Includes timestamps for record keeping
|
- Includes timestamps for record keeping
|
||||||
|
- Tracks purchase status via `purchased_at` field
|
||||||
|
- Stores release information including multiple release IDs and a selected release ID
|
||||||
|
- Maintains release date information
|
||||||
|
|
||||||
### Records Search Index
|
### Records Search Index
|
||||||
|
|
||||||
@@ -87,6 +104,16 @@ A virtual FTS5 (Full Text Search) table that mirrors the records table for effic
|
|||||||
- Optimized for full-text search operations
|
- Optimized for full-text search operations
|
||||||
- Contains most fields from the records table
|
- Contains most fields from the records table
|
||||||
- Some fields are marked as UNINDEXED for efficiency
|
- Some fields are marked as UNINDEXED for efficiency
|
||||||
|
- Updated to use `release_date` instead of `release` field
|
||||||
|
|
||||||
|
### Artist Infos
|
||||||
|
|
||||||
|
A table that stores additional artist information:
|
||||||
|
|
||||||
|
- Uses UUID as primary key
|
||||||
|
- Stores MusicBrainz and Discogs data for artists
|
||||||
|
- Maintains artist image data with dimensions
|
||||||
|
- Includes timestamps for record keeping
|
||||||
|
|
||||||
### Views
|
### Views
|
||||||
|
|
||||||
@@ -103,6 +130,12 @@ CREATE VIEW artist_records AS
|
|||||||
json_each(records.artists)
|
json_each(records.artists)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
This view is crucial for querying artist information as it:
|
||||||
|
- Extracts individual artists from the embedded JSON array in the records table
|
||||||
|
- Provides a normalized view of the artist-record relationships
|
||||||
|
- Makes it easier to query records by artist
|
||||||
|
- Maintains the relationship between records and their artists without requiring a separate join table
|
||||||
|
|
||||||
### Triggers
|
### Triggers
|
||||||
|
|
||||||
The following triggers maintain the search index:
|
The following triggers maintain the search index:
|
||||||
@@ -133,6 +166,10 @@ The following indices are maintained for performance:
|
|||||||
5. The database supports both collection and wishlist functionality through the `purchased_at` field:
|
5. The database supports both collection and wishlist functionality through the `purchased_at` field:
|
||||||
- Records with `purchased_at IS NOT NULL` are in the collection
|
- Records with `purchased_at IS NOT NULL` are in the collection
|
||||||
- Records with `purchased_at IS NULL` are in the wishlist
|
- Records with `purchased_at IS NULL` are in the wishlist
|
||||||
|
6. The schema has been updated to use `release_date` instead of `release` for better clarity
|
||||||
|
7. A new `selected_release_id` field has been added to track the primary release for a record
|
||||||
|
8. The `artist_infos` table has been added to store additional artist metadata and images
|
||||||
|
9. The `artist_records` view provides a normalized way to query artist-record relationships
|
||||||
|
|
||||||
## WHY ONE TABLE?
|
## WHY ONE TABLE?
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user