Questions tagged [object-relationships]

36 questions
49
votes
4 answers

Retrieving relationships of relationships using Eloquent in Laravel

I have a database with the following tables and relationships: Advert 1-1 Car m-1 Model m-1 Brand If I want to retrieve an Advert, I can simply use: Advert::find(1); If I want the details of the car, I could…
Ben Thompson
  • 4,743
  • 7
  • 35
  • 52
11
votes
2 answers

How to set a 0..* relationship in Entity Framework Code First?

I have the next code for two classes: public class Object { public int ObjectID { get; set; } public int Object2ID { get; set; } public virtual Object2 Object2 { get; set; } } public class Object2 { public int Object2ID { get; set;…
Jorge Díaz
  • 137
  • 1
  • 1
  • 10
7
votes
2 answers

JPA - Entity design problem

I am developing a Java Desktop Application and using JPA for persistence. I have a problem mentioned below: I have two entities: Country City Country has the following attribute: CountryName (PK) City has the following attribute: CityName Now…
Amit
  • 33,847
  • 91
  • 226
  • 299
7
votes
2 answers

Performance considerations on deleting Managed Objects using Cascade rule in Core Data

I searched within SO but I didn't find a any suggestions to boost performances on deleting Managed Object in Core Data when dealing with relationships. The scenario is quite simple. As you can see there are three different entities. Each entity is…
Lorenzo B
  • 33,216
  • 24
  • 116
  • 190
6
votes
1 answer

"is A" VS "is Like A" relationships, what does each one mean and how do they differ?

First an example to discuss: class Foo { // Attributes: int attribute1, attribute2; // Methods: virtual void Foo1() { /* With or without Implementation */ } virtual void Foo2() { /* Also with or without…
Tamer Shlash
  • 9,314
  • 5
  • 44
  • 82
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
2 answers

Design classes in C#

Recently I had attended an interview and was given this question: Question: With the following entities with you, design a class diagram or skeleton code: The entities are: garment shirt pant fabric buttons zip The best I could do was this: class…
2
votes
1 answer

Join 2 tables via a 3rd one - One table to rule them all

I've done my research, spent hours on tutorials but couldn't find an easy to understand way to create what I need. I'm new to Access but so eager to learn. I do tons of reports on Excel but tired of how slow it can be when too much data on my data…
2
votes
2 answers

Django Two Way relationship

I am building a blog site and have models in respect of Category and Posts. Posts have a Many to Many relationship for Category. class Post(models.Model): categories = models.ManyToManyField(Category) Everything is working fine aside from the…
KevTuck
  • 113
  • 8
1
vote
0 answers

ActiveRecord belongs_to with an 'or' statement

I've got a bit of a strange system here where the app I'm developing has a local db, but also connects to an external db for some data. One of the requirements was that if a manufacturer is not found in the external db, it have a temporary entry…
pedalpete
  • 21,076
  • 45
  • 128
  • 239
1
vote
3 answers

EF CF Mapping complex relationship with Fluent API

I am trying to create the following constraint in my model so that a Tag object's TagType is valid. A valid TagType is one whose OperatingCompanyId matches the Tag's Website's OperatingCompanyId. I realize that this seems convoluted however it makes…
1
vote
0 answers

When given Json file names as input "org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]"

When given Json file names as input "org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]" ` The following files are used in the below code. JSONObject output1 = new JSONObject("E:\\Bharathi\\json sample…
1
vote
1 answer

Flexible Object Relationships

I am trying to develop a data model for a very diverse set of interconnected objects. As the application matures, the types of objects supported will increase significantly. I want to avoid having to modify the model/schema whenever new object types…
SArcher
  • 264
  • 1
  • 9
1
vote
2 answers

Rails - CanCan - Basic Questions

How can I use CanCan from a Model? Let's say I have a relationship like this: Employee belongs_to Store, and Boss manages_many (has_many) Stores. How exactly do I use CanCan (the right way) to restrict each particular boss's access to be able to…
Mr Mikkél
  • 2,577
  • 4
  • 34
  • 52
1
vote
2 answers

CakePHP - Custom hasOne Object Association - Using a Join Table instead of in-table foreign keys?

In CakePHP, I'm trying to build a $hasOne relationship, but I can't add a foreign key to the tables (for legacy reasons). Is there any way I can create a join table (object1_object2) and link them together like this? I want to leverage Cake's…
Harry
  • 863
  • 3
  • 10
  • 26
1
2 3