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
108
votes
14 answers

How to delete/create databases in Neo4j?

Is it possible to create/delete different databases in the graph database Neo4j like in MySQL? Or, at least, how to delete all nodes and relationships of an existing graph to get a clean setup for tests, e.g., using shell commands similar to rmrel…
rmv
  • 3,195
  • 4
  • 26
  • 29
69
votes
10 answers

SQLAlchemy cannot find a class name

Simplified, I have the following class structure (in a single file): Base = declarative_base() class Item(Base): __tablename__ = 'item' id = Column(BigInteger, primary_key=True) # ... skip other attrs ... class Auction(Base): …
Ross
  • 46,186
  • 39
  • 120
  • 173
63
votes
2 answers

anybody tried neo4j vs titan - pros and cons

Can anybody please provide or point out to a good comparison between Neo4j and Titan? One thing i can see is in terms of scale - Titan is scaleout and requires an underlying scalable datastore like cassandra. Neo4j is only for HA and has its own…
DevD
  • 1,201
  • 2
  • 12
  • 20
60
votes
3 answers

Understanding Core Data delete rules on One to Many

I am a little fuzzy about Core Data Relationships deletion rules. So if someone could help me answer a few questions about them. I have Entities A and B. A has a to-Many relationship with B, and B has a to-One relationship with A. A<--->>B Now, if I…
Shamy
  • 723
  • 1
  • 8
  • 13
37
votes
2 answers

Hibernate: Where do insertable = false, updatable = false belong in composite primary key constellations involving foreign keys?

When implementing composite primary keys in Hibernate or other ORMs there are up to three places where to put the insertable = false, updatable = false in composite primary key constellations that use identifying relationships (FKs that are part of…
Kawu
  • 13,647
  • 34
  • 123
  • 195
28
votes
6 answers

Laravel merge relationships

Is there a way to merge 2 relationships in laravel? this is the way it's setup now, but Is there a way I could return both merged? public function CompetitionsHome() { return $this->HasMany( 'Competition', 'home_team_id' ); } public…
Kiwi
  • 2,713
  • 7
  • 44
  • 82
24
votes
5 answers

MySQL Foreign Key On Delete

I am trying to figure out relationships and deletion options. I have two tables, User and UserStaff, with a 1:n relationship from User to UserStaff (a user can have multiple staff members). When my User is deleted, I want to delete all of the…
Baub
  • 5,004
  • 14
  • 56
  • 99
19
votes
3 answers

How to setup conditional relationship on Eloquent

I have this (simplified) table structure: users - id - type (institutions or agents) institutions_profile - id - user_id - name agents_profile - id - user_id - name And I need to create a profile relationship on the Users model, but the following…
Ju Nogueira
  • 8,435
  • 2
  • 29
  • 33
18
votes
4 answers

JPA/Hibernate: @ManyToOne and @OneToOne relationships tagged as FetchType.LAZY and optional = false not loading lazily on em.find()?

I have the following entity (only relevant mappings shown): @Entity @Table(name = "PQs") public class PQ implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column private Integer id; @Column …
Kawu
  • 13,647
  • 34
  • 123
  • 195
18
votes
1 answer

Laravel Sync error

I am running the following code, if( $organisation->save() ) { if(isset($members)) { $organisation->users()->sync($members); } if(isset($teams)) { $organisation->teams()->sync($teams); } …
Udders
  • 6,914
  • 24
  • 102
  • 194
17
votes
11 answers

CakePHP select default value in SELECT input

Using CakePHP: I have a many-to-one relationship, let's pretend it's many Leafs to Trees. Of course, I baked a form to add a Leaf to a Tree, and you can specify which Tree it is with a drop-down box ( tag) created by the form helper. The only thing…
erjiang
  • 44,417
  • 10
  • 64
  • 100
14
votes
3 answers

Sequelize hasMany Join association

I'm expanding my application and I need to join two models I had previously created with Sequelize, they are as follows: Meal sequelize.define('meal', { mealId: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement:…
leofontes
  • 898
  • 4
  • 16
  • 40
14
votes
1 answer

Modeling a more complex entity relationship in a RESTful way (boxes and nodes)

Here's an example to set up my question. I have a model which contains 'boxes', and they have a REST endpoint: /boxes, /boxes/{boxId} This model also contains 'nodes': /nodes, /nodes/{nodeId} Nodes can sit on the borders of boxes, and this is a…
mhelvens
  • 4,225
  • 4
  • 31
  • 55
14
votes
3 answers

How to GROUP and SUM a pivot table column in Eloquent relationship?

In Laravel 4; I have model Project and Part, they have a many-to-many relationship with a pivot table project_part. The pivot table has a column count which contains the number of a part ID used on a project, e.g.: id project_id part_id count 24 …
Thomas Jensen
  • 2,138
  • 2
  • 25
  • 48
14
votes
2 answers

Laravel Relationships

I've been looking over relationships in Laravel 4 in the documentation and I'm trying to work out the following. I have a table in my database called 'events'. This table has various fields that mainly contain ID's that relate to other tables. For…
Gareth Daine
  • 4,016
  • 5
  • 40
  • 67
1
2 3
55 56