2

There is an association between "Car" and "Parking Lot" which read "A car can have 0..1 parking lots" "A parking lot can have 0..1 cars"

However, these does not seem to cooperate well, when trying to create a car and a parking lot in MDriven's Autoforms, you have to create a parking lot in order to have a car created, and vise versa, which makes it impossible to create either one of them.

There is no option to have "0 cars in parking lot" even if the association implies this.

Is this a bug or does the problem lie in the original association?

2 Answers2

2

This should be perfectly fine - and even if you would have 1-1 instead of 0..1-0..1 it should still be fine but you would get constraints violation warnings.

The constraint warning does not stop you from saving but signals that you are not compliant with the broken constraint.

Is it the constraint warning that stops you of is it something else?

Hans Karlsen
  • 2,275
  • 1
  • 15
  • 15
  • It is not a constraint violation. There just seemes to be a problem in use of composition between these two classes even though there are no composition associations made, the only active association is the one explained in the question (0..1 - 0..1). The making of one class shouldn't be dependent on another unless the association implies that , correct? – Joe Andersson May 01 '18 at 15:18
1

I'm not familiar with the specific tool, but it sounds like you may have a bidirectional relationship where you only want a unidirectional relationship. If you are "car" centric, the car can "be in 0 or 1 parking lot. If you are "parking lot" centric, the parking lot can have either 0 or 1 car (although it seems like it is more likely 0 to many cars). Also, make sure you are not using composition. The car and the parking lot can exist independently of each other.

Bruce
  • 2,230
  • 18
  • 34
  • 1
    The tool makes automated viewmodels for an easy look on how coherent the base structure is. I am not sure if other programs also has this but I am glad MDriven has it since it is very handy. – Joe Andersson May 01 '18 at 15:21
  • Also, regarding the problem, since the association is reads 0..1 to 0..1, I think it's neither, maybe that is the problem, obviously there can't be an instance with 0 cars in 0 parking lot, it's not intuitive for the database. – Joe Andersson May 01 '18 at 15:24
  • @Bruce: The question, and the topic of association multiplicities, is not related to the issue of unidirectional versus bidirectional associations, which is about how to implement an association with reference properties. – Gerd Wagner May 03 '18 at 11:49