Questions in this tag typically involve the association that a set of data has with other set(s) of data.
Questions tagged [relationship]
5577 questions
16
votes
1 answer
Laravel "with" changes variable case to snake case
In my Laravel app, I have A model that defines a relationship like:
public function vitalCategories()
{
return $this->belongsToMany(
'App\Models\Diagonals\VitalLabelCategory',
'vitalLabelCategoryMap',
'vitalLabelId',
…

Wesley Smith
- 19,401
- 22
- 85
- 133
15
votes
3 answers
UML Class diagram, how to show a Class extends thread?
I have a class called ServerSide in which another class resides called Cserver. The following code fragment should explain what I am talking about:
public static void main (String [] args) throws Exception
{
System.out.println("The server is…

CurryMaster
- 151
- 1
- 2
- 5
15
votes
2 answers
SQLAlchemy import tables with relationships
I have problem with separating tables with relationships in different files. I want the tables below to be in three separate files and to import TableA in third party page, but I can not manage the load order.
In most of the time I'm receiving the…

bozhidarc
- 834
- 1
- 11
- 25
14
votes
2 answers
SQLAlchemy Declarative + relationships across multiple different databases
It took me a while, but I figured out how to use SQLAlchemy to model a relationship across two different kinds of databases:
Base = declarative_base()
class Survey(Base):
__tablename__ = 'SURVEY'
survey_id =…

coredumperror
- 8,471
- 6
- 33
- 42
14
votes
1 answer
Room Persistence Deletes Child On Update
I am using Room Library to persist data in my Android App. I have 2 main table, which are Task and Group. The relation is One-to-Many, where a task can belong only to 1 group, but a group can belong to many tasks.
The persistence works fine, but the…

Herbert Souza Silva
- 175
- 1
- 9
14
votes
1 answer
Many-to-many self-referential relationship in sqlalchemy
I'm trying to make a self-referential many-to-many relationship (it means that Line can have many parent lines and many child lines) in sqlalchemy like this:
Base = declarative_base()
class Association(Base):
__tablename__ = 'association'
…

mike
- 141
- 1
- 4
14
votes
2 answers
core data how to filter (NSPredicate) including a relationship requirement and given the relationship object?
How would I filter (construct an NSPredicate) for the following.
Have a SCHOOL and PERSON entities
One-to-many relationship, i.e. a PERSON has one SCHOOL, SCHOOL has many PERSONs
Input to the filter method are (a) persons Name (e.g. all with a…

Greg
- 34,042
- 79
- 253
- 454
14
votes
2 answers
How do I make the parent dirty when I change a hasMany/belongsTo relationship in Ember-Data?
My main problem with Ember Data, right now, is that when I change a relationship (hasMany or belongsTo), the parent doesn't get dirty.
I need this because:
I'm depending on the isDirty property to show a save/cancel button
hasMany and belongsTo ids…

miguelcobain
- 4,734
- 4
- 32
- 45
14
votes
5 answers
MySQL / PHP: Find similar / related items by tag / taxonomy
I have a cities table which looks like this.
|id| Name |
|1 | Paris |
|2 | London |
|3 | New York|
I have a tags table which looks like this.
|id| tag |
|1 | Europe |
|2 | North America |
|3 | River |
and a…

Tom
- 33,626
- 31
- 85
- 109
13
votes
4 answers
backbone.js - handling model relationships in a RESTful way
I'm using backbone.js
For example, let's suppose we have a "products" model and a "categories" model which have a many-to-many relationship. In one of my views, say I need to retrieve a list of all categories and know whether or not each one is…

Matthew
- 15,282
- 27
- 88
- 123
13
votes
3 answers
Laravel Eloquent - Attach vs. SyncWithoutDetaching
What is the difference between syncWithoutDetaching and attach in Laravel?

Abdulrahman Hashem
- 1,481
- 1
- 15
- 20
13
votes
1 answer
Neo4j - Count distinct nodes
I have this kinds of relationships:
(:User)<-[:MENTIONS]-(:Tweet)-[:ABOUT]->(:Topic)
I would like to count all the users mentioned in the tweets regarding some topic.
With the following query
match (n:Topic)<--(t:Tweet)-[:MENTIONS]->(u:User)
where…

sirdan
- 1,018
- 2
- 13
- 34
13
votes
6 answers
store many of relation 1:1 between various type of objects : decoupling & high performance
I have 300+ classes. They are related in some ways.
For simplicity, all relation are 1:1.
Here is a sample diagram.
(In real case, there are around 50 relation-pairs.)
Note: For some instances, some relation may not exist.
For example, some…

javaLover
- 6,347
- 2
- 22
- 67
13
votes
1 answer
Delete a Has-Many Relationship ONLY
I have a: has_and_belongs_to_many :friends, :join_table => "friends_peoples".
To add a friend I do: @people.followers << @friend which create the relationship and a new person profile.
Now I'd like to delete the relationship ONLY and not the person…

Alextoul
- 839
- 3
- 9
- 19
13
votes
1 answer
Getting a list of related models in rails
Suppose I have an object Person, which has_many :foos and :bars.
Given an instance, p (p = Person.new), how do I programmatically determine what relationships are available?
i.e. p.some_method => ["foo", "bar"]

Paul Schreiber
- 12,531
- 4
- 41
- 63