sql - Best practices when implementing Relational Models who need constraining logical cardinality across several entities -


there n cities.

each city disposes m different types of souvenir fridge magnets

then there y travelers. every traveler collects z magnets, single 1 per city @ most. 2 different travelers buy same city magnet.

 n city 1 <--> m magnets z <--> y traveler 

i'd appointed best way enforce traveler can have z magnets if , if each magnet corresponds single city, in relational fashion keys or better normalization, or know best practice strategy it.

uml

1.magnet * <--> 1 city

2.bought - association class beetwen city , traveler

3.bought * <--> 1 magnet

4.ocl constraint: context bought inv:city=magnet.city

database

city

1.idcity (pk)

traveler

1.idtraveler (pk)

magnet

1.idcity (pk, fk)

2.idmagnet (pk)

bought

1.idcity (pk, fk1)

2.idmagnet (fk1)

3.idtraveler (pk, fk2)


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -