Questions tagged [table-relationships]

220 questions
2
votes
1 answer

rails relationship one-to-many; can't build child objects?

class Photo < ActiveRecord::Base has_many :boosts, class_name: BoostedPhoto ... end class BoostedPhoto < ActiveRecord::Base belongs_to :photo end This is how I have it set up so far, but when i try to do this in the console: photo =…
2
votes
1 answer

I am trying to change follower status from 'requested' to 'approved' in relationship model

I have a relationship table with followed_id, follower_id, and status. I am using "has many through" in my user model to create the association. A user has many following through and is following many through a reverse relationship. The status…
2
votes
1 answer

MySQL, need help defining multiple join query to return complete info

So, I have modified a query I learned from this thread, however when I filter between tags and cats, the result is undesirable. Filtering for category 5 will return just the category list info and tags will be empty, while the opposite applies for…
Turtleface
  • 35
  • 4
2
votes
2 answers

MySQL Database Design: one to one,many to many, many to one, or too many?

I am in the process of setting up tables in my database for my first project. (Exciting!) I am having a hard time deciding what types of relationships I need to set up. I have the following basic tables planned.…
404error
  • 575
  • 2
  • 4
  • 16
2
votes
2 answers

HOW TO: When record on table A gets deleted all records on table B, that are associated with table A, should ALSO be deleted?

By having into consideration the following scheme: We need to make sure that, if an association gets deleted, all the dogs that belong to that association, should also be deleted. However, it makes sense to, while doing this, keep the relation that…
MEM
  • 30,529
  • 42
  • 121
  • 191
2
votes
1 answer

CakePHP: finding information in distantly related models

I have a News model, which has a HABTM relationship with an Artists model, and an artist in turn hasMany tourdates. If I want to find all tourdates related to the current news item, what is an efficient way of phrasing that for CakePHP? This is what…
2
votes
2 answers

limitations of :finder_sql

In a rails app, I using the :finder_sql option in a has_many declaration. The rails docs say that when I do this, "find_in_collection is not added." What does this mean?
allyourcode
  • 21,871
  • 18
  • 78
  • 106
2
votes
1 answer

Odoo multiple many2many or One2many fields on single model

I'm inheriting the project.project module where I've added multiple Many2many fields: 'Buyers', 'Sellers', 'Contacts', etc. All related to res.partner. Know when I add multiple records to one of the fields, for example add some buyers. These buyers…
Jesse
  • 727
  • 13
  • 44
2
votes
4 answers

What is the best solution to design sql table relationship for a table that will be used by other tables

I came upon a rather interesting situation where I need guidance to help me design my Database schema that follows "best practises" or is done "the recommended way". My dilemma is as follows: I have an Event table with basic properties such as Id,…
2
votes
3 answers

Rails 4.2: Role Based Auth and Separate Attributes

I am creating an app with 3 types of Users which could end up with a 4th... Admin Provider Member (patient) The tricky part is each share some common attributes such as 'first_name' and 'last_name', but will have more attributes that differ. If…
2
votes
2 answers

Not allowed to create or change a record in MS Access

I have read numerous thread on the above question, but none of the answers satisfy the problem. My problem is two tables that are linked to each other (in a one to one relationship) using an "ID" field which is also the primary key. When I try to…
Marnu123
  • 77
  • 2
  • 10
2
votes
1 answer

How do I see the EER Model for an mySQL database I have created using DDL

I've created a new schema/database in DDL query thing in MySQL Work Bench. (I hope I explain myself well enough since I can't post images without 10 Rep apparently... Like the code below sort of stuff). CREATE DATABASE IF NOT EXISTS…
DevilsD
  • 545
  • 1
  • 5
  • 12
2
votes
2 answers

how to design the tables for customer orders and bills

Am designing a database schema (orders and bills) for a hotel system. The attached image shows the tables in the database schema. The question is how do I design the bills table, so that I can calculate the customer bill from orders the customer…
2
votes
1 answer

Laravel 4 - Many to Many - pivot table not updating

I get no obvious errors when adding a new job to my database. My industry job goes into the jobs table but the relationship with divisions in my join table goes nowhere. I just can't see where I'm going wrong JOIN…
user3189734
  • 665
  • 1
  • 9
  • 27
2
votes
3 answers

many to many relationships in ms access

I have a database (for a pet sitting company) containing tables for the following: Customers emergency contacts phone numbers phone types The phone numbers are stored in a separate table to allow for efficient storage of a virtually unlimited…
1
2
3
14 15