Building the schema

I want to archive the content for a scholar who writes a series of posts related to a single subject, this series will have different shape for it's posts than other serieses. for example a series of posts have a verseId, chapterId, point_1, point_2, point_3. another series posts may look like this: characterName, content. And there will be a serieses created in the future I need some help and ideas on how to achieve that.
5 Replies
Anas Badran
Anas BadranOP2w ago
I want to to build a dashboard to create the the serieses and their posts dynamically, any ideas on how to do it, and what tools to use to accomplish this?
Alessandro Buonocore
For the first point you need relations Second point it kinda depends on what u need to do but i guess Vite will work just fine
Anas Badran
Anas BadranOP2w ago
the second point is related to the first, my question is about how build the schema to be flexible and dynamic, and allow the admin who control the dashboard to build the shape of the posts for a certian series.
RaphaelEtim
RaphaelEtim2w ago
Hi @Anas Badran You could consider using a schema that includes a base Series model and a flexible Post model. For example:
model Series {
id String @id @default(cuid())
title String
posts Post[]
}

model Post {
id String @id @default(cuid())
seriesId String
series Series @relation(fields: [seriesId], references: [id])
content Json // Flexible JSON field to store varying post structures
}
model Series {
id String @id @default(cuid())
title String
posts Post[]
}

model Post {
id String @id @default(cuid())
seriesId String
series Series @relation(fields: [seriesId], references: [id])
content Json // Flexible JSON field to store varying post structures
}
The content field as Json allows you to store different structures for different series. For building a dashboard to create series and posts dynamically, you could consider using a full-stack framework like Next.js with Prisma. This combination allows for type-safe database access and flexible API creation.
Anas Badran
Anas BadranOP2w ago
after some discussions with chatGPT, I think I almost got what I want:
model Series {
id String @id @default(cuid())
title String
description String
posts Post[]
comments Comment[]
requiredFields SeriesField[] // Relation to define fields specific to this series
}

model SeriesField {
id String @id @default(cuid())
seriesId String
series Series @relation(fields: [seriesId], references: [id])
fieldName String // Name of the field (e.g., "verseId", "surahId", "points")
fieldType String // Type of the field (e.g., "string", "number")
}

model Post {
id String @id @default(cuid())
title String
content String
seriesId String
series Series @relation(fields: [seriesId], references: [id])
customFields CustomField[]
}

model CustomField {
id String @id @default(cuid())
postId String
post Post @relation(fields: [postId], references: [id])
key String // Name of the custom field (e.g., "verseId", "surahId", etc.)
value String // Value of the custom field stored as a string
}
model Series {
id String @id @default(cuid())
title String
description String
posts Post[]
comments Comment[]
requiredFields SeriesField[] // Relation to define fields specific to this series
}

model SeriesField {
id String @id @default(cuid())
seriesId String
series Series @relation(fields: [seriesId], references: [id])
fieldName String // Name of the field (e.g., "verseId", "surahId", "points")
fieldType String // Type of the field (e.g., "string", "number")
}

model Post {
id String @id @default(cuid())
title String
content String
seriesId String
series Series @relation(fields: [seriesId], references: [id])
customFields CustomField[]
}

model CustomField {
id String @id @default(cuid())
postId String
post Post @relation(fields: [postId], references: [id])
key String // Name of the custom field (e.g., "verseId", "surahId", etc.)
value String // Value of the custom field stored as a string
}
Want results from more Discord servers?
Add your server