MusicBrainz Database / Schema

Contents

Objects

Artist

An artist is generally a musician, group of musicians, a collaboration of multiple musicians or other music professional.

Artist credit

List of artists, variations of artist names and pieces of text to join the artist names. Examples:

Release group

Represents an abstract "album" (or "single", or "EP") entity. Technically it's a group of releases, with a specified type. Examples:

Release

Real-world release object you can buy in your music store. It has release date and country, list of catalog number and label pairs, packaging type and release status. Examples:

Medium

Piece of media, included in a release. Contains information about the format, position in the release and an optional title, plus a list of tracks. Has attached CD TOCs. Examples:

Track

This object is not visible to users on its own, only in the context of a release. It has an MBID, and contains a link to a recording, title, artist credit and its position on its medium.

Recording

Represents an unique mix or edit. Has title, artist credit, duration, list of PUIDs and ISRCs. Examples (all are different Recordings):

Work

One layer above recordings ("song", "composition", etc.). While recording represents audio data, work represents the composition behind the recording. Advanced Relationships should be used to link recording and work.

Label

Labels represent mostly (but not only) imprints.

Area

A country, region, city or the like.

Place

A venue, studio or other place where music is performed, recorded, engineered, etc.

Schema

This schema diagram shows the core database tables and relationships between them. Core entities are blue, mostly-static lists are yellow, and external identifiers are red. There is also a higher resolution schema diagram.

ngs.png

Relationship table structure

ngs-ars.png

There are tables for every possible combination of primary entities (artist, label, recording, release, release_group, url, work), all prefixed with l_ and all with the same format. Two of them are shown in the diagram. They contain a field, edits_pending that is a count of pending changes to the AR, and three foreign keys: link that points back to the associated entry in the link table, and entity0 and entity1 that point to the associated entry in the corresponding primary entity table (i.e. artist, recording, url, etc.).

There are two tables that assist with avoiding unnecessary duplication:

link table

The link table contains the begin and end date info, and the link_type foreign key field that specifies what kind of AR it is. It also has a count of how many other attributes that particular link has in the attribute_count field, and a created field that specifies when it was created.

Each AR attribute either applies to a particular AR or it doesn't. The link_attribute table stores this information, having a record for each attribute_type (a foreign key field for link_attribute_type) of each link.

The AR types and attributes are defined in three other tables, shown at the top of the diagram. They can only be modified by the AR editors.

link_type table

The link_type table defines the types of ARs available. AR types are arranged in a number of trees, for ease of finding. This tree structure is expressed with the parent and child_order fields; parent is the id of the parent AR type, or null if it's at the root, and child_order orders the children of a given parent AR type. Each AR type has a unique uuid, stored in the gid field, for use in permalinks and external applications. The link between a particular AR type and the corresponding l_ table is formed by the entity_type0 and entity_type1 fields.

The attributes are themselves defined in the link_attribute_type table. Like AR types, attributes form a number of trees (the vast majority of them are individual musical instruments). Besides the parent and child_order fields shared with the link_type table, the link_attribute_table also has a root field, showing the root of the tree that the attribute is part of. Attributes also have names and descriptions which appear various places they are displayed, as well as gids and a last_updated timestamp.

The link_type_attribute_type table specifies what attributes can be applied to particular types of ARs; it has the necessary foreign key fields (link_type and attribute_type) and it also specifies how many instances of the attribute (or one of it's children) can be added to the particular AR type in the min and max fields. Currently, most of them allow the attributes to merely be present or absent, a few allow any number of copies of the attribute, or none. The "creative commons licensed download" attribute has to be included exactly once, while the instrument attribute (of the instrument type AR), requires at least one instance.

Cover Art Archive table structure

cover art.png

The Cover Art Archive table structure is fairly simple. The cover_art table stores the actual cover art and associations to edits. art_type stores the acceptable cover art types, and cover_art_type links the two together. release_group_cover_art links a release group to the release whose cover art should represent the release group.

This image also shows the links to tables in the main diagram (as well as the edit table), but not their full schemas; please see other diagrams or the real schema specification for details.

There is one view not shown, which is the index_listing view -- this makes for a slightly nicer interface than joining the tables manually, by providing an array of cover art types and easy pointers for is_front and is_back. Otherwise it largely resembles the cover_art table.