Top "Associations" questions

Associations typically refer to relationships between models in ORMs such as ActiveRecord.

How to filter by conditions for associated models?

I have a belongsToMany association on Users and Contacts. I would like to find the Contacts of the given User. …

cakephp associations conditional-statements cakephp-3.0 query-builder
Linq To SQL Without Explicit Foreign Key Relationships

I am working with a few legacy tables that have relationships, but those relationships haven't been explicitly set as primary/…

linq linq-to-sql class foreign-keys associations
What is the best way to implement Polymorphic Association in SQL Server?

I have tons of instances where I need to implement some sort of Polymorphic Association in my database. I always …

sql-server associations polymorphic-associations database-normalization
Associations in Sequelize migrations

My app currently uses the Sequelize sync() method to create the database, and I want to change it to use …

node.js associations database-migration sequelize.js
How can I delete child objects when the parent is deleted in rails?

model a: has_many :b, :dependent => :delete_all model b: belongs_to :a belongs_to :c model c: has_…

ruby-on-rails activerecord associations cascade
Same Model for Two belongs_to Associations

I have an model PointOfContact which has_many Systems. From the Systems side I want to identify the PointOfContact as …

ruby-on-rails-3 associations model-associations
How to have many-to-many relationship in rails

I am new to rails, and am trying to set up a many-to-many relationship in my rails project. I have …

ruby-on-rails migration associations has-and-belongs-to-many
Rails - Parent/child relationships

I'm currently using a standard one-to-one relationship to handle parent/child relationships: class Category < ActiveRecord::Base has_one :category …

ruby-on-rails associations parent-child
Entity Framework, Code First, Update "one to many" relationship with independent associations

It took me way too long to find a solution to the scenario described below. What should seemingly be a …

entity-framework associations code-first dbcontext
How to build many-to-many relations using SQLAlchemy: a good example

I have read the SQLAlchemy documentation and tutorial about building many-to-many relation but I could not figure out how to …

python many-to-many sqlalchemy associations