Create database models
Create models for storing data in the database.
In this section
Create the Django models for storing data in the database
Creating the database models
We're going to create a Work model and an Expression model. Both models are uniquely identified by their respective FRBR URIs.
See Introductory concepts for background on Works, Expressions and FRBR URIs.
We'll store all the raw metadata in a single metadata
JSON field. We'll also extract certain fields from that metadata and store that information separately, so we can query it more easily.
Note:
The
frbr_uri
on bothWork
andExpression
must be unique.One work can have multiple expressions, hence the ForeignKey from
Expression
toWork
.Expressions require a work, so
PROTECT
any expressions if a work is deleted.Only key pieces of metadata needed for the legislation reader app have been specified on the
Work
model. Themetadata
field is used for storing the rest.
You'll need to make and run migrations after adding these models.
Last updated