<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-relationships-work-in-data-connect-eclgcraff" -->

---
title: How Relationships Work in Data Connect | daily.dev
description: Firebase Data Connect supports relational data modeling using GraphQL schema syntax, including one-to-one, one-to-many, and many-to-many relationships. The...
canonical: https://daily.dev/posts/how-relationships-work-in-data-connect-eclgcraff
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How Relationships Work in Data Connect | daily.dev
og:description: Firebase Data Connect supports relational data modeling using GraphQL schema syntax, including one-to-one, one-to-many, and many-to-many relationships. The...
og:url: https://daily.dev/posts/how-relationships-work-in-data-connect-eclgcraff
og:image: https://api.daily.dev/og/posts/ECLGCraFf.png
og:image:alt: How Relationships Work in Data Connect
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How Relationships Work in Data Connect

**[Firebase](https://daily.dev/sources/firebase-blog)** · 7 min read · 0 upvotes · 0 comments

## Summary

Firebase Data Connect supports relational data modeling using GraphQL schema syntax, including one-to-one, one-to-many, and many-to-many relationships. The walkthrough shows how to define primary and foreign keys using directives like @unique and @ref, how composite keys work with the key argument, and how Data Connect auto-generates implicit fields in implicit.gql for tables like Movie, MovieMetadata, User, FavoriteMovie, Actor, and MovieActor join tables.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://firebase.blog/posts/2025/01/dataconnect-relationships>

## Questions this post answers

### How do I define a one-to-one relationship between two tables in Firebase Data Connect?

Use the @unique directive on a reference field in the dependent table. For example, adding movie: Movie! @unique to a MovieMetadata type creates a movieId foreign key field that must be unique, enforcing that each Movie has exactly one associated MovieMetadata record and vice versa.

_Developers modeling relational schemas can track Data Connect guidance like this on daily.dev._

### How do I create a many-to-many relationship with a join table in Firebase Data Connect?

Create a join table type with a composite key referencing both related types, such as MovieActor @table(key: ["movie", "actor"]) containing movie: Movie! and actor: Actor! fields. Data Connect implicitly generates movieId and actorId foreign key fields in implicit.gql, and additional columns like role can store per-pair data.

_Teams designing many-to-many schemas can keep patterns like this handy via daily.dev._

### What does the @ref directive do in Firebase Data Connect schemas?

The @ref directive creates a field in the current table that references the primary key of another type, similar to @unique but without the uniqueness constraint. Writing @ref is often optional since it is implied when a field type points to another table, such as movie: Movie! in a FavoriteMovie table implying @ref(fields: "movieId", references: "id").

_daily.dev helps developers comparing GraphQL-based database tools like Data Connect stay current on schema syntax._

## Similar posts on daily.dev

- [How Firestore Structures Data and How to Perform CRUD Operations With It](https://daily.dev/posts/how-firestore-structures-data-and-how-to-perform-crud-operations-with-it-odioykply) · freeCodeCamp · 1 upvotes · 0 comments
- [Building type-safe applications with Drizzle ORM in Aurora DSQL](https://daily.dev/posts/building-type-safe-applications-with-drizzle-orm-in-aurora-dsql-ysp70xb5v) · AWS Database Blog · 3 upvotes · 0 comments

---

Tags: [#database](https://daily.dev/tags/database), [#graphql](https://daily.dev/tags/graphql), [#firebase](https://daily.dev/tags/firebase)

[View this post on daily.dev](https://daily.dev/posts/how-relationships-work-in-data-connect-eclgcraff)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How Relationships Work in Data Connect","url":"https://daily.dev/posts/how-relationships-work-in-data-connect-eclgcraff","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-relationships-work-in-data-connect-eclgcraff"},"datePublished":"2026-08-23T12:19:03.866Z","dateModified":"2026-08-23T12:24:03.672Z","description":"Firebase Data Connect supports relational data modeling using GraphQL schema syntax, including one-to-one, one-to-many, and many-to-many relationships. The...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d5ba581e847a90b2d0591b519a97ed3f?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d5ba581e847a90b2d0591b519a97ed3f?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Firebase","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Firebase","logo":"https://media.daily.dev/image/upload/s--i395oqZH--/f_auto,q_auto/v1787487448/logos/firebase-blog?_a=BAMAMicg0","url":"https://daily.dev/sources/firebase-blog"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-relationships-work-in-data-connect-eclgcraff","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"database,graphql,firebase","timeRequired":"PT7M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Firebase","item":"https://daily.dev/sources/firebase-blog"},{"@type":"ListItem","position":3,"name":"How Relationships Work in Data Connect"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/how-relationships-work-in-data-connect-eclgcraff#faq","mainEntity":[{"@type":"Question","name":"How do I define a one-to-one relationship between two tables in Firebase Data Connect?","acceptedAnswer":{"@type":"Answer","text":"Use the @unique directive on a reference field in the dependent table. For example, adding movie: Movie! @unique to a MovieMetadata type creates a movieId foreign key field that must be unique, enforcing that each Movie has exactly one associated MovieMetadata record and vice versa. Developers modeling relational schemas can track Data Connect guidance like this on daily.dev."}},{"@type":"Question","name":"How do I create a many-to-many relationship with a join table in Firebase Data Connect?","acceptedAnswer":{"@type":"Answer","text":"Create a join table type with a composite key referencing both related types, such as MovieActor @table(key: [\"movie\", \"actor\"]) containing movie: Movie! and actor: Actor! fields. Data Connect implicitly generates movieId and actorId foreign key fields in implicit.gql, and additional columns like role can store per-pair data. Teams designing many-to-many schemas can keep patterns like this handy via daily.dev."}},{"@type":"Question","name":"What does the @ref directive do in Firebase Data Connect schemas?","acceptedAnswer":{"@type":"Answer","text":"The @ref directive creates a field in the current table that references the primary key of another type, similar to @unique but without the uniqueness constraint. Writing @ref is often optional since it is implied when a field type points to another table, such as movie: Movie! in a FavoriteMovie table implying @ref(fields: \"movieId\", references: \"id\"). daily.dev helps developers comparing GraphQL-based database tools like Data Connect stay current on schema syntax."}}]}
```

