Populating a relational database
I've been over the docs and cant find anything regarding to populating relational databases. See attached images of my current setup. Eg when data is created, the columns where the relation should be is empty (the users "notifications" column is empty when a notification is created. Is this done automatically of do I need to set this up manually when the data is created?
5 Replies
I'm not sure I understand the question. Is it about database seeding?
Apologies no, for example in my code the notifications column in the users table should be an array of their notifications, but when I generate a notification it doesn’t show up in the relevant column in Drizzle Studio. So I just want to make sure whether that link between the notifications table and the users notifications column (array of notifications) is created automatically or manually in my code.
Heres a screenshot of the empty user notification column and the notification which should be displayed within it
Okay I found this video which explains it (https://www.youtube.com/watch?v=5R2gem0GSmw), so relational data needs to be added manually. In prisma this was automated which is why i wanted to confirm.
Sakura Dev
YouTube
Inserting New Data Is Complex in Drizzle ORM 😰
❤️Please Support me by subscribing to my channel 👉🏻https://www.youtube.com/@sakuradev?sub_confirmation=1
In this video I will talk about inserting new data into data base tables with drizzle orm considering their relationship with other tables including one-to-one, one-to-many and many-to-many relations.
so do not underestimate this tutorial.
#...
I have not seen the video, but as long as you add your notification with the userId of the correct user, the notifications will be linked to that user
The user won't have a column of notification arrays, but it can be linked to it via joins or the relational queries