❔ Database Models and Tracking Reference
I'm really new to EFCore and databases in general.
I'm looking for a bit of guidance.
I have 3 tables (see screenshot), I want the Infraction to track on with the User and the Server.
How do I go about this?
In the future, I'm going to need to search for all infractions made on a specific server and all the infractions a user has been given.
10 Replies
Due to a lack of keyword knowledge for this area, ChatGPT wasn't much help here. 🙂
Not exactly sure how to phrase the question either which doesn't help. 😄
are you asking for db structure?
generally you connect these via foreign keys
I guess.
Yeah a friend suggested foreign keys, but I don't get how to use them at all 😂
Do I put the foreigns to the User & Server from the Infraction Model?
Kinda like this? and have no reference in the User and Server model to the Infraction model?
A user can have many infractions, which all need to have the sending server.
it's implied via the navigation properties that these are foreign keys
Right, but is this the correct usage?
Should these FK's be in this model?
yes
yes, but not necessarily
you can also have collection a collection of infractions for the user and for the server as navigation properties
How would this be achieved?
read on navigation properties
Appreciate your time! 🙂 Will take a look!
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.