Skip to main content
Version: v2.x

BigQuery: Relationships between Tables/Views

Introduction

Let's say we have the following tables in our database: authors, passport_infos, articles and tags.

Table relationships

The tables/views in any relational database are typically related to each other via one of the following types of table relationships:

TypeExampleMeaning
one-to-oneowner and passport_infos
  • an owner can have one passport_info
  • a passport_info can have one owner
one-to-manyauthors and articles
  • an author can have many articles
  • an article can have one author
many-to-manyarticles and tags
  • an article can have many tags
  • a tag can have many articles

GraphQL schema relationships

Each table relationship, as you can see from the above section, will have two component relationships (one in either direction) in the GraphQL schema. These relationships can be one of the following types:

TypeExampleMeaning
object relationship (one-to-one)an article can have one authoran article object will have a single nested author object called author
array relationship (one-to-many)an author can have many articlesan author object will have an array of nested article objects called articles
Note

The relationship name is used to refer to the nested objects in queries. For example, "articles" of an author and "author" of an article.

Managing GraphQL relationships

See the following to manage the object/array relationships between tables/views for the GraphQL schema: