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
20
votes
4 answers
Laravel Eloquent ORM replicate
I have a problem with replicating one of my models with all the relationships.
The database structure is as follows:
Table1: products
id
name
Table2: product_options
id
product_id
option
Table3: categories
id
name
Pivot table:…

Zoli
- 1,081
- 1
- 8
- 28
20
votes
6 answers
Java sockets: multiple client threads on same port on same machine?
I am new to Socket programming in Java and was trying to understand if the below code is not a wrong thing to do. My question is:
Can I have multiple clients on each thread trying to connect to a server instance in the same program and expect the…

espcorrupt
- 201
- 1
- 2
- 3
20
votes
4 answers
How do I rename relationships in Neo4j?
I realized only after importing a ton of nodes that I had created relationships called START, which is a reserved keyword. Querying the DB through the Cypher console hence always complains about the reserved keywords:
SyntaxException: reserved…

ulkas
- 5,748
- 5
- 33
- 47
19
votes
3 answers
What is the best way to implement many-to-many relationships using ORMLite?
I'm currently playing with ORMlite to make a model with tables and relationships.
One relationship is a many-to-many relationship. What's the best way to implement that?
To be more concrete:
Let's say I've got these two tables
Product
id
…

Romain Piel
- 11,017
- 15
- 71
- 106
19
votes
8 answers
Rails, how to avoid the "N + 1" queries for the totals (count, size, counter_cache) in associations?
I have a these models:
class Children < ActiveRecord::Base
has_many :tickets
has_many :movies, through: :tickets
end
class Movie < ActiveRecord::Base
has_many :tickets
has_many :childrens, through: :tickets
belongs_to…
user4412054
19
votes
1 answer
CoreData optional to-many relationships can never be nil?
Quirk I just discovered, and wanted to confirm with anyone here whether or not this is avoidable. Basically, if I have a very simple two entity model:
With a to-many relationship between Entity1 and Entity2. The relationship is optional, with…

Jonathan Crooke
- 912
- 7
- 19
19
votes
6 answers
Calculate Family Relationship from Genealogical Data
I would like to be able to calculate the family relationship between two individuals in a family tree, given the following data schema (simplified from my actual data schema, only showing columns that directly apply to this…

defines
- 10,229
- 4
- 40
- 56
18
votes
4 answers
Cosine similarity vs Hamming distance
To compute the similarity between two documents, I create a feature vector containing the term frequencies. But then, for the next step, I can't decide between "Cosine similarity" and "Hamming distance".
My question: Do you have experience with…

caw
- 30,999
- 61
- 181
- 291
18
votes
2 answers
Entity Framework Core: Update relation with Id only without extra call
I'm trying to figure out how to deal with 'Single navigation property case' described in this doc:
Let's say we have 2 models.
class School
{
public ICollection Childrens {get; set;}
...
}
and
class Child
{
public int Id {get;…

silent_coder
- 6,222
- 14
- 47
- 91
18
votes
3 answers
How to find its owner DataGrid and DataGridRow from DataGridCell in WPF?
In an event handler for a Command for a DataGrid, I get DataGridCell in ExecutedRoutedEventArgs. However, I couldn't figure out how to get its associated DataGrid and DataGridRow. Your help is much appreciated.

newman
- 6,841
- 21
- 79
- 126
18
votes
3 answers
SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias on relationship
So, I'm receiving the following error from Laravel framework; but I couldn't find why this framework is producing this error:
SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias: 'participants' (SQL: select…

ChrisBratherton
- 1,540
- 6
- 26
- 63
18
votes
1 answer
neo4j: one-directional / two-directional relationships?
So I looked into neo4j, and I may be using it in an upcoming project since its data model might fit my project very well. I looked through the docs but I still need an answer to this question:
Can I set relationships to be one-directional?
It seems…

joschua011
- 4,157
- 4
- 20
- 25
17
votes
3 answers
Room relations with conditions
How to add conditions to the relation?
For example, we have object Pet
@Entity
public class Pet {
@ PrimaryKey
int id;
int userId;
String name;
String type;
// other fields
}
and…

waldemar
- 655
- 2
- 10
- 24
16
votes
3 answers
SQLAlchemy: add a relationship using id instead of object?
Is it possible to add to a SQLAlchemy relationship using ids rather than objects?
For example, consider two declarative SQLAlchemy classes, Review and Artist, with a relationship between them:
class Review(Base):
artist_id = Column(Integer,…

Ollie Glass
- 19,455
- 21
- 76
- 107
16
votes
2 answers
How are `ghc-pkg` and `cabal` programs related? (Haskell)
As I know cabal is a program to manage installation of packages like FreeBSD's pkg_add.
But there is another tool called ghc-pkg. I don't know why there are two different programs. What's the role of each of them and how are they related?

eonil
- 83,476
- 81
- 317
- 516