https://github.com/tomdoestech/prisma-relationships
https://github.com/tomdoestech/prisma-relationships
database prisma
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/tomdoestech/prisma-relationships
- Owner: TomDoesTech
- Created: 2022-10-26T03:46:46.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-26T03:47:13.000Z (over 3 years ago)
- Last Synced: 2025-04-08T08:46:33.970Z (about 1 year ago)
- Topics: database, prisma
- Language: TypeScript
- Homepage: https://youtu.be/phixQBZNZwU
- Size: 22.5 KB
- Stars: 17
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## What will you learn?
* How to build relationships between data with prisma
* Querying relationships
* Creating data with relationships
## Relationships
## One to one relationship (1-1)
A user has one profile and a profile belongs to one user
## One to many relationship (1-m)
An order has one user, a user can have many orders
## Many to many relationship (m-m)
Docs: https://www.prisma.io/docs/concepts/components/prisma-schema/relations/many-to-many-relations
A product can have multiple categories and a category can belong to multiple products
- Explicit m-m
- Manually create join table
- More control
- Implicit m-m
- Prisma defines join table
- Less code
## One to many relationship that references itself
A category can have a parent category and a parent category can have multiple children