flafff
flafff
DTDrizzle Team
Created by flafff on 8/27/2024 in #help
User Settings architecture
Hey, I am very new to everything related with backend and I recently started my full stack side project. The application will have "modules" for the user to choose from, they are stored in the DB:
export const user = pgTable('user', {
id: serial('id').primaryKey().notNull(),
email: varchar('email', { length: 255 }).notNull().unique(),
firstName: varchar('first_name', { length: 255 }).notNull(),
lastName: varchar('last_name', { length: 255 }).notNull(),
})

export const moduleType = pgEnum('type', [
'sport',
'finance',
'family',
'school',
])

export const module = pgTable('module', {
id: serial('id').primaryKey().notNull(),
type: moduleType('type').notNull(),
})
export const user = pgTable('user', {
id: serial('id').primaryKey().notNull(),
email: varchar('email', { length: 255 }).notNull().unique(),
firstName: varchar('first_name', { length: 255 }).notNull(),
lastName: varchar('last_name', { length: 255 }).notNull(),
})

export const moduleType = pgEnum('type', [
'sport',
'finance',
'family',
'school',
])

export const module = pgTable('module', {
id: serial('id').primaryKey().notNull(),
type: moduleType('type').notNull(),
})
and I am wondering what is the best practice/pattern to make a relation between those two tables with a requirement that the user selects multiple modules NOTE that there will also be theme, currency etc. for the user to select Is creating a third table like preferences a good idea? if soo how should the table look like ?
2 replies