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
3 answers

Django Models ManyToMany and Foreign Key

Trying to get a better handle on how django database relationships are handled. Any thoughts are appreciated. Considering the following example models: class Things(models.Model): name = models.CharField(max_length=20) class…
Nick B
  • 9,267
  • 17
  • 64
  • 105
2
votes
1 answer

`execute_non_query': Cannot add a NOT NULL column with default value NULL (DataObjects::SyntaxError)

class User include DataMapper::Resource property :id, Serial property :name, String property :email, String has n, :records end class Project include DataMapper::Resource property…
user1136228
  • 967
  • 9
  • 22
2
votes
2 answers

MYSQL modeling relationships: Design and UPDATE/DELETE

I am trying to understand relationships fully, and have gone through alot of tutorials. Still i linger on a few things (using MySQLWORKBENCH): 1. Every user can upload a product 2. Every product can have multiple categories, bids, ratings, etc 3.…
user1163859
  • 123
  • 2
  • 14
2
votes
1 answer

Symfony2 / Doctrine - Joining Mysql and Sqlite Entities

I'm having a problem with Symfony2 / Doctrine. I'm starting to think that I'm trying to do the impossible, joining 2 seperate databases together via a relationship. I've got a mysql database, and an sqlite database. I've got 2 bundles (each…
egruz
  • 21
  • 1
2
votes
0 answers

Querying for a relationship in ruby on rails and update results via Ajax

I have a ROR app that has many players, and many proposed games. The games display on a feed and a player can decide to hide them from this feed. The hidden function works like this: in player.rb: has_many :hides, :foreign_key=> "hider_id", …
slovak_100
  • 782
  • 2
  • 10
  • 33
2
votes
1 answer

Ruby on Rails 3.1: Am I setting this relationship up correctly?

I am making my first app in Ruby on Rails 3.1....Do I have these relationships setup correctly? Essentially, a student/client will be able to login and rate a teacher. A client can have many teachers and a teacher can have many clients. Each…
user1096557
2
votes
1 answer

Doctrine Relationship on a namespaced table

I have several doctrine models that have relationships to other models. Let's call those ItemsOne, ItemsTwo, ItemsThree. Each has a relationship defined to the Products doctrine class (products table) and the relationship is defined…
Nikolaos Dimopoulos
  • 11,495
  • 6
  • 39
  • 67
2
votes
1 answer

Counting entries where relationship to each other is not determined

I want to count a list of entries in my database that all have specified relationships to one person, but I need to count by their relationship to each other - in other words, they are listed as sons and daughters, brothers and sisters of the main…
nevermind
  • 137
  • 2
  • 10
2
votes
1 answer

Xcode4 Core Data Relationships

I've once again read through the Apple developer Core Data documentation and found it lacking when it comes to the graphical Xcode 4 editor when creating SQLLite entities much as I found it lacking when IB was separate in Xcode 3. Three…
Justin
  • 859
  • 4
  • 15
  • 30
2
votes
2 answers

"Virtual Relationships" in Rails

I'm trying to do a "virtual relationship" (what I call it - don't know if there's a real term for it) in Rails. Here's one that I have that is definitely working: Address belongs_to Business and Business has_many Addresses. Addresses have a…
istrasci
  • 1,331
  • 1
  • 18
  • 40
2
votes
2 answers

Specifying conditions on a relationship in Ruby on Rails

I have the following has_many :administrators, :class_name => "User", :conditions => "role_id = 4" and it works fine, but instead of using the foreign key "role_id = 4" I would prefer to specify the actual role string in the roles table, that that…
pingu
  • 8,719
  • 12
  • 50
  • 84
2
votes
2 answers

Django model class that can either have one relationship or another?

To give you an idea of the problem I'm trying to solve I'll use an example. The issue is that there can be multiple possible relationships between classes, and how to represent this in the models file. In a shopping website the Department can either…
2
votes
1 answer

Rails: capture model id in the create form for another model

I currently have three models and am trying to bring in a reference of one of the models (webpage.id) into another model (Micropost) - here is the situation: class Member < ActiveRecord::Base has_many :microposts end class Webpage <…
2
votes
2 answers

Relationship doesnt work in Laravel

In my User model i have 2 relationships public function role() { return $this->belongsTo(Role::class, 'role_id'); } public function city() { return $this->belongsTo(City::class, 'city_id'); } The second City doesnt work when i use $user…
gasprice admin
  • 143
  • 2
  • 11
2
votes
0 answers

PrepareForDeletion in xCode 9.4 - why are object relationships deleted by this point?

Okay - I might be losing my mind and I hope I am, because the alternative seems worse right now. I upgraded to Xcode 9.4 and all of a sudden my Core Data app started acting crazy. I think I've found something, but it makes no sense to me. All of a…
SAHM
  • 4,078
  • 7
  • 41
  • 77