i have entity car
, entity race
. both entities has attribute called carclass
. problem want create relation between them on joining carclass
.
basically want create relation in core data represents possible competitors of race, depending on carclass
, in other words if create race specific carclass
, call competitors
on race want list of cars same carclass
.
my question is, possible create using core data relations
, i'm thinking adding nspredicate
relation.
thanks in advance.
update
i think didn't explained want achieve.
car{ carclass:string } race{ carclass:string competitors<-->>cars.carclass == carclass }
and competitors
should fetched automatically, don't have add manually competitors, should retrieve matching cars cars model.
the simplest model this:
carclass{ name:string race<-->race.carclass cars<-->>car.carclass } car{ name:string carclass<<-->carclass.cars } race{ name:string carclass<-->>carclass.race }
don't think sql terms, think of in object terms. each entity should represent real-world object, event or condition want simulate. relationships between objects should mimic real-world relationships. if both race
, car
real-world things have common relationship carclass
condition put in model.
unlike sql, object models can arbitrarily complex , can contain behaviors well. not stuck tables, columns , rows.
update:
(see update in op reference)
when find putting same attribute value in 2 or more different entities, means need create new entity model value.
in case, though in terms of data carclass value string logically separate thing altogether related both race
, car
objects. so, accurately model it, need provide separate entity it. in addition, need model competitors need model looks like:
carclass{ class:string race<-->race.carclass cars<-->>car.carclass } car{ name:string carclass<<-->carclass.cars competitor<-->>competitor.car } race{ name:string carclass<-->carclass.race } competitor{ name:string car<-->car.competitor }
(note model assumes races defined carclass , not individual vehicles or drivers.)
so, find competitors of particular race, walk race.carclass.cars.competitor
.
this isn't want can idea or how use entities , relationships model real-world objects, events or conditions , linkages between them.
Comments
Post a Comment