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
1 answer

How can I model a polymorphic, custom name relationship using Mongoid

I'm attempting to define a series of model relationships using custom names for a model in some instances, and it's native name in others. Furthermore, the model can be referenced by multiple classes, necessitating a polymorphic relationship. The…
kevinthompson
  • 574
  • 3
  • 15
3
votes
3 answers

PHP ORMs and optimized relationship queries

I need a PHP ORM to work with relations well. Please consider code below in Zend: $persons = new Persons(); $person = $persons->find(5)->current(); echo 'Name: '.$person->fullname; $phones = $person->findDependentRowset('Phones'); foreach($phones…
AHHP
  • 2,967
  • 3
  • 33
  • 41
3
votes
2 answers

How to model Friendship relationships

I have been trying to figure out how to do this, and even with looking at other examples, I can't get it figured out, so maybe I can get some personalized help. I've got two tables, users_status and friendships. In the users_status table I have a…
vertigoelectric
  • 1,307
  • 4
  • 17
  • 37
3
votes
1 answer

querying from a many to many relationship sqlalchemy

I have this database scheme, a many-to-many relationship: Base = declarative_base() association_table = Table('association', Base.metadata, Column('book_id', Integer, ForeignKey('book.book_id')), Column('author_id', Integer,…
CMorgan
  • 645
  • 2
  • 11
  • 33
3
votes
1 answer

Adding relationships to an array of relationships in hyperledger-composer

In my hyperledger composer app, I have Clients and Consultants. A Client has read access to Consultants that have been added to his/her "readAccessList". Here are the models of these two participant types: participant Client identified by id { o…
Tommy
  • 699
  • 4
  • 11
  • 26
3
votes
0 answers

Nested embedded and relations with Room

I have a database structure like that: Item - id - status_id - title Status - id - name Feature - id - name ItemFeature - item_id - feature_id - value I'd like to load the entire graph in a LiveData> collection... I know I have to…
Alessandro
  • 3,666
  • 2
  • 28
  • 41
3
votes
2 answers

override relationship behaviour in sqlalchemy

Say I have three tables in a declarative fashion, Parent, Child, and Pet, in such way that Parent has a many-to-many relationship with both Child and Pet Child has a one-to-many relationship with Pet The code for them is (using Flask-SQLAlchemy,…
bluesmonk
  • 1,237
  • 13
  • 31
3
votes
2 answers

How to load a nested relationship in Laravel

I have a model called CallbackRequest the model has a relationship with Loan model and that is the only relationship for CallbackRequest model. CallbackModel: public function loan() { return $this->belongsTo(Loan::class); } Now Loan model…
user7175325
3
votes
1 answer

Fetch all children of parents in Core Data using predicate

I have a data model relationship of Person - Children in Core Data. So for example, A Person can have children and his children can have children, and so his children's children can have children and so on. How would I be able to fetch all the…
SleepNot
  • 2,982
  • 10
  • 43
  • 72
3
votes
1 answer

Eloquent Has Many Through with Many To Many (belongsToMany)

I have this given table structure: How can I access the 'curso.name' from my 'visita' class using eloquent? I assigned the many to many relationships but can only access the 'turma.curso_id', but I wanna get something like $visita->curso['nome']. I…
3
votes
1 answer

Laravel 5.4: Cannot retrieve data from a relationship

I'm trying to display the name of the assignee (foreign key from Users table) of each ticket by storing each name in an array from two UNION'd tables (Accesses and Reports) but it gives me this error. ErrorException Undefined property:…
Grant Gubatan
  • 265
  • 5
  • 14
3
votes
1 answer

Laravel Many to Many, attach one model, multiple times

I have a many to many relationship between 2 models: Tours and Locations, and I have some extra pivot-table fields (days and nights of staying in each location). Everything is set up and working just fine. Each Tour can have multiple locations,…
MeeDNite
  • 159
  • 3
  • 13
3
votes
1 answer

Laravel inter-user messaging system

I am developing a messaging system for my app, and currently, I have two tables: 1) messages table: Schema::create('messages', function (Blueprint $table) { $table->increments('id'); $table->text('subject'); …
Sir George
  • 423
  • 3
  • 8
  • 20
3
votes
3 answers

One-To-Many Relationships in laravel eloquent

Good morning, I am having a little trouble with model relationships in Eloquent, I need to link articles and images for those articles with an intermediate table. In the intermediate table I'd like to add the id's of both article and image, and I…
Santiago Capdevila
  • 125
  • 1
  • 1
  • 13
3
votes
2 answers

Quick CoreData -- inverse delete rules

Quick simple question. Apple's CoreData docs explain how delete rules work on a department's employees relationship. Delete a department, and various different things can happen to the associated employees. But what about an employee's department…
ed94133
  • 1,477
  • 2
  • 19
  • 40