Archive

Posts Tagged ‘entity relations’

Correcting optionalities at MS Visio

March 29, 2013 3 comments

The past month, I was studying the basics of databases, and among the things I had to learn along the way are Entity Relations (ER). Databases are composed of tables (called entities) that are to be connected based on their dependencies towards each other. Our instructor introduced us Microsoft Visio as a good tool to make Entity Relationship Diagrams.

In an ERD, each table has its own columns (called attributes) with at least one of them set as primary key to identify uniquely to that table. Depending on the relationship between entities, a table can inherit the primary key of another table as foreign key, and thus become a child to the table (parent) it is referencing to. Out-bound parent links can be set as mandatory or optional, and the child link cardinalities can be set such that parent-to-child relationships are:

Mandatory

Optional

1 TO 0 or more

0 or 1 TO 0 or more
1 TO 1 or more

0 or 1 TO 1 or more
1 TO 0 or 1

0 or 1 TO 0 or 1
1 TO 1

0 or 1 TO 1
1 to Range [at least N, at most M]

0 or 1 to Range [at least N, at most M]

In visual representation, the entity closest to the crow’s feet is the child.

When we were doing our case study on a hospital database, I had trouble trying to create a mandatory link from the parent entity (which should be displayed as two straight lines, instead of just a line and a ring). (Shown below)

ms_visio_00

In this scenario, ROOM is the parent entity and MEDICAL_SERVICE is the child entity and we need to fix their relation (highlighted below).

ms_visio_01

Under Miscellaneous > Child has parent, what we are supposed to do is to uncheck Optional.

ms_visio_02

The problem (the problem!) is that it’s grayed out (disabled). So …

Here’s the workaround:
Under Definition, disconnect associated relations. Make sure the key you choose is the one being inherited (in this case, Room_No)

ms_visio_03

Go back to Miscellaneous > Relationship type, make sure it’s set to Non-identifying. Under Child has parent, you can now (finally) uncheck Optional.

ms_visio_04

and voila!

ms_visio_05

There’s the mandatory relation right there.