Relationships and Cardinality

In real world, entities have relationships with other entities.  Relationships define how two entities are associated with each other. The data modeling captures the nature of relationship between two entities. For example, the entity 'Customer' buys the 'Product' and the entity 'Vendor' sells the 'Product'. It captures the rules between these two entities. If two entities are Person and Telephone Number, the relationship may capture the rule "Each Person may have many Telephone Numbers" and "Each Telephone Number must belongs to one Person." 
Data rules are instructions on how data relate to one another.  There are two types of data rules, Cardinality Rules and Referential Integerity (RI) data rules.

Cardinality rules define the quantity of each entity instances that can participate in a relationship. For example: 
  • Each Person can have one or many Phone Numbers.
  • Each User ID must belongs to one User.
  • Each Bus can contain many Seats.
Referential Integrity (RI) rules focus on ensuring valid values. For example:
  • A Customer cannot exist without a valid Email Address.
  • An Order cannot exist without a valid Product.
  • A Shipment cannot exist without a valid Postal Address
Action Rules are instructions on what to do when data fields contain certain values. For example:
  • New Users can download at most 5 Articles a year for free.
In data models, we can represents the data and enforce data rules (Quantity and Valid relationships), but we cannot enforce action rules on a data model. A online magazine data model can capture User Status such as New User or Existing User, as well as the number of Articles each User reading downloading each year, but cannot enforce that a New User download no more than 5 Articles.


Relationship Cardinality


As we already discussed cardinality defines the quantity of each entity instances that can participate in a relationship. Cardinality represented by symbols that appears on both end of the relationship line. Cardinality used to specify data rules and to enforce it. The domain values to choose from to represent cardinality on relationship is limited to three values: zero, one or many. In data modeling, the small line means "one". The circle means "zero" or "optional". The triangle with a line through the middle means "Many", this symbol also known as a crow's foot. Relationship lines are labeled to clarify the relationship and express the rule that the relationship represents.



Recursion:


A recursive relationship is a rule that exist between instance Relationships and Cardinalities of the same entity. A one-to-many recursive relationship describes a hierarchy, whereas a many-to-many relationship describes a network.



Sub-typing:


Sub-typing groups the common data fields and relationships of entities, while retaining what is unique within each entity. The sub-typing relationships implies that all of properties from the super-type are inherited by the subtype.




This post gives you an idea about relationships and cardinalities in data modeling. Next post let us discuss about the keys in data modeling.

2 comments:


  1. My name is Kimberly Nicholas from Sydney,I never believed in love spells or magic until i met this spell caster once when i went to Africa in February this year on a business summit. I meant a man who’s name is (Great Matatan powerful Spell ), he is really powerful and could help cast spells to bring back one’s gone, lost, misbehaving lover and magic money spell or spell for a good job or luck spell .I’m now happy & a living testimony cos the man i had wanted to marry left me 3 weeks before our wedding and my life was upside down cos our relationship has been on for 4 years. I really loved him, but his mother was against us and he had no good paying job. So when i met this spell caster, i told him what happened and explained the situation of things to him. At first i was undecided, skeptical and doubtful, but i just gave it a try. And in 7 days when i returned to Sydney, my boyfriend (now husband) called me by himself and came to me apologizing that everything had been settled with his mom and family and he got a new job interview so we should get married. I didn’t believe it cos the spell caster only asked for my name and my boyfriends name and all i wanted him to do. Well we are happily married now and we are expecting our little kid, and my husband also got the new job and our lives became much better. His email is:(  matatanspell@yahoo.com .  )  

    ReplyDelete
  2. Very interesting blog. A lot of blogs I see these days don't really provide anything that I'm interested in, but I'm most definitely interested in this one. Just thought that I would post and let you know how to make him miss you and commit

    ReplyDelete