Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relation or Pointer?

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.

enter image description here

Thanks!

like image 382
KingPolygon Avatar asked Oct 22 '14 07:10

KingPolygon


1 Answers

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.

like image 114
Kevin Pimentel Avatar answered Sep 27 '22 17:09

Kevin Pimentel