If I have a class titled Article
, and I want to add an Author
column (which is class type User
), should I use relation or pointer? There can only be one Author
, but that Author
can write many articles. I'm assuming pointer, but just making sure.
Thanks!
A general rule of thumb is to use a pointer for one-to-one or one-to-many relationship. Use a relation when you have a many-to-many relationship. I would say in your case it sounds like you want to use a pointer type. This guide is useful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With