Questions tagged [relationships]

Relationships refer to mappings between elements of one set to another set, such as one-to-one, one-to-many, many-to-many.

Relationships can be implicit or explicit depending upon the data model.

Types of relationships

References

832 questions
3
votes
4 answers

laravel relation model how to get author's name in comment model through post model

I have a question about Laravel's relation model comment table id post_id post table id author_id author table id name I want use relation model to get author's name in comment model through post table, how to realize…
陈孝右
  • 33
  • 1
  • 5
3
votes
1 answer

convert DB:table query to eloquent

I have a method in my controller where I return an array of books from a database like so: $books= DB::table('books')->where('category_id', $category_id)->orderBy('title', 'asc')->paginate(20); Now I want to be able to use an eloquent relationship…
Magearlik
  • 523
  • 1
  • 6
  • 18
3
votes
3 answers

How to set up associations with data in redux store

I'm using redux with an api middleware similar to the one here, which normalizes response data and stores the results in the entity field of my state. So, if I made a request to the customers endpoint and it returned something like: customers: [{ …
Danny Andrews
  • 456
  • 4
  • 10
3
votes
1 answer

Laravel Relationships can't access

I have 3 models: User, A, B and C. User.php public function a() { return $this->belongsTo('App\A'); } A.php public function b(){ return $this->belongsTo('App\B'); } B.php public function cRelation(){ return…
angelocala94
  • 125
  • 1
  • 9
3
votes
0 answers

Neo.DatabaseError.Statement.ExecutionFailure: Relationship X has been deleted

I am creating a principal node in neo4j and creating its relationship with School, it works and principal object and relationship succesfully created in neo4j. SchoolHasPrincipal school_has_principle = new SchoolHasPrincipal(school,…
Govind Singh
  • 15,282
  • 14
  • 72
  • 106
3
votes
0 answers

Strongloop Loopback Native SQL

I have the following situation in a loopback application: I have a 'Person' class that extends from built in 'User' I have students ('Person' class with Role 'student') I have teachers ('Person' class with Role 'teacher') I have classgroups…
Ernie
  • 972
  • 1
  • 10
  • 23
3
votes
1 answer

Symfony2: Disconnect Associations on delete

I have two entities - Background and Action. a Background has many Actions. When I delete a Background I want to keep the Action but null the foreign key. Effectively orphaning the entity in a way that will satisfy constraints. I have read so many…
darkbluesun
  • 817
  • 8
  • 15
3
votes
1 answer

Django equivalent of Rail's has_one through

Is there something equivalent to has_one :through in Django? I have User, Company, and CompanyMember models. CompanyMember has foreign keys to User and Company. A User can belong to a Company through the CompanyMember model. Assume User is unique…
kentor
  • 1,104
  • 2
  • 9
  • 19
3
votes
2 answers

Core Data migration of to-one relationship to to-many relationship

I have a deployed app that samples measurements from sensors (e.g., Temp °C, Pressure kPa). The user can create Experiments and collect samples. Each sample is stored as a Run, such that there is a one-to-many relationship from Experiment to Run. In…
3
votes
2 answers

Django One to One - Don't want delete related model

So here is the problem. I got 2 models: RefereeLevel and Referee Here is both: class RefereeLevel(models.Model): level = models.PositiveSmallIntegerField(blank=False,default=1,verbose_name=_("level"),unique=True) salary =…
Ara Sivaneswaran
  • 365
  • 1
  • 10
  • 25
3
votes
2 answers

SQL How to find out if relationship is many to many

I am trying to understand many to many relationship. I have read articles on this topic but I am still not getting it. Let's take team and player as an example. One team can have multiple players, but one player can only play in one team? I know…
Peter F
  • 83
  • 2
  • 3
  • 12
3
votes
2 answers

OOP relationships between two classes

I have been struggling with the abstraction that lies between two classes when it comes to the issue of Inheritance or Composition...the IS-A vs HAS-A relationship between classes like LoginManager and AuthenticateManager. The way I see it…
Cozzbie
  • 1,014
  • 2
  • 12
  • 26
3
votes
5 answers

1-n relationship

I dont get 1-n relationship. I have read some articles but still cant figure it out. I get 1-many, 1:1 and many-to-many. But what does 1-n mean?
ajsie
  • 77,632
  • 106
  • 276
  • 381
3
votes
2 answers

Calling SQL foreign key data with PHP

I need to get a better grasp on the process of manipulating and utilizing the SQL tables I need to make so I can continue figuring out exactly how I should make them and structure them to work. If I have a table for shirts and another table for…
Optiq
  • 2,835
  • 4
  • 33
  • 68
3
votes
1 answer

Multiple relations to the same model CakePHP

Hey we have three tables in our database which are connected through two relationships which are Account and Invoices. Accounts (id....) Invoices (id, sender_id, receiver_id) Relationships (id, sender_id, receiver_id) Sender and receiver are both…
user1402677
  • 269
  • 2
  • 12