Skip to content
Sandra Hilleard

Designing Relational Schemas for Custom Academic Citation Engines

// BLUF (Bottom Line Up Front)

A citation engine stays reliable when works, contributors and citations live in separate tables, DOIs are stored in one normalised form with a unique index, and citations are modelled as a self-referencing many-to-many relationship.

Sandra Hilleard • • Updated
6 min read
Cover image with the title "Designing Relational Schemas for Custom Academic Citation Engines" and gold line icons of code brackets, a globe and a database on a dark background.

Any project that manages references, whether a research portal, a course library or a knowledge base that cites its sources, eventually runs into the same problems. The same paper appears three times with slightly different titles. An author's name is spelt two ways. A DOI is stored as a full URL in one place and in capitals in another. A clean relational schema prevents most of this before it starts.

This note walks through a schema for a custom citation engine in Laravel, and why each decision matters.

What are the core entities in a citation engine?

Strip a reference list down and you find four concepts:

  • Works: anything that can be cited, such as journal articles, books, chapters, reports, datasets and web pages.
  • Contributors: the people (and sometimes organisations) who author, edit or translate works.
  • Contributions: the link between a work and a contributor, including their role and their position in the author list.
  • Citations: the link between a citing work and a cited work.

Keeping these separate is the most important decision of all. Storing authors as a comma-separated string on the work, or citations as free text, makes deduplication and querying almost impossible later.

How should DOIs be stored?

A Digital Object Identifier has the form 10.<prefix>/<suffix>; the DOI Handbook itself, for example, is 10.1000/182. Two details cause most of the trouble:

  1. DOIs are case-insensitive. 10.1000/ABC and 10.1000/abc identify the same object, so store one canonical form (lowercase is the usual choice) and compare on that.
  2. DOIs arrive in many wrappers, such as https://doi.org/…, http://dx.doi.org/… or doi:…. Strip these on input and store only the bare DOI. Build the resolver URL when you need it.

In Laravel, a mutator keeps this consistent everywhere the attribute is set:

// app/Models/Work.php
protected function doi(): Attribute
{
    return Attribute::make(
        set: fn (?string $value) => blank($value) ? null : Str::of($value)
            ->trim()
            ->replaceMatches('#^(https?://(dx\.)?doi\.org/|doi:)#i', '')
            ->lower()
            ->toString(),
    );
}

Combined with a unique index on the column, the database itself now refuses duplicates.

What does the schema look like?

Schema::create('works', function (Blueprint $table) {
    $table->id();
    $table->string('type');                         // article-journal, book, chapter, report…
    $table->string('title');
    $table->string('container_title')->nullable();  // journal or book title
    $table->string('doi')->nullable()->unique();
    $table->string('url')->nullable();
    $table->date('issued')->nullable();
    $table->string('volume')->nullable();
    $table->string('issue')->nullable();
    $table->string('pages')->nullable();
    $table->string('publisher')->nullable();
    $table->timestamps();
});

Schema::create('contributors', function (Blueprint $table) {
    $table->id();
    $table->string('family_name');
    $table->string('given_name')->nullable();
    $table->string('orcid', 19)->nullable()->unique(); // e.g. 0000-0002-1825-0097
    $table->timestamps();
});

Schema::create('contributions', function (Blueprint $table) {
    $table->foreignId('work_id')->constrained()->cascadeOnDelete();
    $table->foreignId('contributor_id')->constrained()->cascadeOnDelete();
    $table->string('role')->default('author');      // author, editor, translator
    $table->unsignedSmallInteger('position');       // order in the author list
    $table->primary(['work_id', 'contributor_id', 'role']);
});

Schema::create('citations', function (Blueprint $table) {
    $table->foreignId('citing_work_id')->constrained('works')->cascadeOnDelete();
    $table->foreignId('cited_work_id')->constrained('works')->cascadeOnDelete();
    $table->text('context')->nullable();            // the sentence where it is cited
    $table->primary(['citing_work_id', 'cited_work_id']);
});

A few of these choices are worth explaining:

  • type uses the CSL vocabulary (article-journal, book, chapter and so on). CSL, the Citation Style Language, is what reference managers such as Zotero use to format citations in thousands of styles. Adopting its types and field names now makes export trivial later.
  • Names are split into family and given parts. Citation styles format names differently (initials, order, particles), which is impossible to do reliably from a single name string.
  • position lives on the pivot table, because author order belongs to a particular work, not to the person.
  • ORCID iDs are unique when present. An ORCID iD is the most reliable way to tell apart two researchers with the same name.

How do you model citations between works?

Citations are a self-referencing many-to-many relationship: a work cites many works and is cited by many works. In Eloquent that is two relationships on the same model:

public function references(): BelongsToMany
{
    return $this->belongsToMany(Work::class, 'citations', 'citing_work_id', 'cited_work_id')
        ->withPivot('context');
}

public function citedBy(): BelongsToMany
{
    return $this->belongsToMany(Work::class, 'citations', 'cited_work_id', 'citing_work_id');
}

With this in place, questions such as "which works in this collection are cited most?" become simple queries: Work::withCount('citedBy')->orderByDesc('cited_by_count')->get().

How do you avoid duplicate works?

Duplicates are the main enemy of any citation database. A practical strategy has three steps:

  1. Match on DOI first. If an incoming reference has a DOI, look it up. With normalisation and a unique index, this match is exact.
  2. Enrich from the source. Crossref's public REST API (https://api.crossref.org/works/{doi}) returns authoritative metadata for DOIs registered with Crossref, so titles, authors and dates can come from there rather than from hand-typed input.
  3. Fall back to careful fuzzy matching for works without a DOI. Compare a normalised title (lowercase, punctuation removed) together with the year and the first author's family name, and flag likely duplicates for review instead of merging them automatically.

How does this help search engines and AI tools?

Well-structured data is easy to publish in the formats machines already understand:

  • schema.org JSON-LD using ScholarlyArticle or Book, with the DOI as an identifier, authors as Person objects (with their ORCID iD in sameAs) and references in the citation property.
  • Highwire Press meta tags such as citation_title, citation_author, citation_publication_date and citation_journal_title, which Google Scholar's inclusion guidelines recommend.
  • CSL-JSON export, so readers can import references straight into Zotero or similar tools.

When the underlying records are consistent, each of these outputs is a straightforward mapping, and search engines and AI tools receive the same unambiguous facts every time. That consistency matters more than any single markup format.

Takeaway

Treat works, people, contributions and citations as separate things. Store identifiers in one canonical form and let the database enforce uniqueness. Borrow field names from CSL so that export is a mapping rather than a migration. The schema is small, but it removes most of the problems that make reference data unreliable.

The same idea of keeping source records clean and interpretation separate is at the heart of Isolating Analytical Overlay in Raw Perceptual Data Pipelines. More technical notes are collected under Web Architecture & Technology.

// FAQ

Frequently Asked Questions

Are DOIs case-sensitive?

No. DOIs are case-insensitive, so 10.1000/ABC and 10.1000/abc refer to the same object. Store one canonical form, usually lowercase, strip prefixes such as https://doi.org/ before saving, and add a unique index so the database itself prevents duplicate records.

How should citations between works be modelled in a database?

As a self-referencing many-to-many relationship: a citations table with a citing work ID and a cited work ID, both pointing to the works table. In Laravel this becomes two belongsToMany relationships on the same Work model, typically named references and citedBy.

Why use CSL field names in a citation schema?

CSL, the Citation Style Language, is the standard reference managers such as Zotero use to format citations in thousands of styles. Using its item types and field names in your schema means exporting to CSL-JSON, and from there to any citation style, is a direct mapping.

What structured data should a citation page publish?

Publish schema.org JSON-LD (ScholarlyArticle or Book) with the DOI, authors and references, and add Highwire Press citation meta tags such as citation_title and citation_author for Google Scholar. Consistent underlying data matters most, because every format is generated from it.


Written by Sandra Hilleard

Cognitive Architect & Systems Designer exploring the intersection of non-local perception, instructional design, and Laravel software systems.