<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/the-challenges-of-supporting-foreign-key-constraints-ipm6rl3vt" -->

---
title: The challenges of supporting foreign key constraints
description: PlanetScale has launched support for foreign key constraints after facing several technical challenges. It took around a year to overcome these challenges and...
canonical: https://daily.dev/posts/the-challenges-of-supporting-foreign-key-constraints-ipm6rl3vt
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: The challenges of supporting foreign key constraints | daily.dev
og:description: PlanetScale has launched support for foreign key constraints after facing several technical challenges. It took around a year to overcome these challenges and...
og:url: https://daily.dev/posts/the-challenges-of-supporting-foreign-key-constraints-ipm6rl3vt
og:image: https://api.daily.dev/og/posts/ipM6RL3VT.png
og:image:alt: The challenges of supporting foreign key constraints
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.

# The challenges of supporting foreign key constraints

**[PlanetScale](https://daily.dev/sources/planetscale)** · 29 min read · 2 upvotes · 0 comments

## Summary

PlanetScale has launched support for foreign key constraints after facing several technical challenges. It took around a year to overcome these challenges and ensure compatibility with branching, Online DDL, gated deployments, online imports, and cross shard support. The challenges included handling branching and deploy requests, handling reverts, and addressing issues with query serving and online DDL. The implementation of foreign key constraints in Vitess is owned by Vitess itself and involves additional locking and communication with the MySQL server. While foreign key constraints are supported in unsharded environments, there are limitations such as no support for cyclic foreign key references and the possibility of orphaned rows with schema reverts.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://planetscale.com/blog/challenges-of-supporting-foreign-key-constraints>

---

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

[View this post on daily.dev](https://daily.dev/posts/the-challenges-of-supporting-foreign-key-constraints-ipm6rl3vt)

```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":"The challenges of supporting foreign key constraints","url":"https://daily.dev/posts/the-challenges-of-supporting-foreign-key-constraints-ipm6rl3vt","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/the-challenges-of-supporting-foreign-key-constraints-ipm6rl3vt"},"datePublished":"2023-12-05T16:05:29.750Z","dateModified":"2023-12-05T16:05:29.078Z","description":"PlanetScale has launched support for foreign key constraints after facing several technical challenges. It took around a year to overcome these challenges and...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/eb110769195349204b0c5c132071af2a?_a=AQAEufR","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/eb110769195349204b0c5c132071af2a?_a=AQAEufR","isAccessibleForFree":true,"articleSection":"PlanetScale","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":"PlanetScale","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/09515c29cafc45618b3f117eab4fccf8","url":"https://daily.dev/squads/planetscale"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/the-challenges-of-supporting-foreign-key-constraints-ipm6rl3vt","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"database,planetscale","timeRequired":"PT29M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"PlanetScale","item":"https://daily.dev/squads/planetscale"},{"@type":"ListItem","position":3,"name":"The challenges of supporting foreign key constraints"}]}
```

