Solved

cardinality vs Ordinality in JPA

Posted on 2011-09-06
3
1,746 Views
Last Modified: 2012-05-12
I was reading about JPA. I read about
 Roles, Directionality, Cardinality( used in many to one, many to many),Ordinality(used in one to one, one to many).
I have not clearly understtod what each of them used for. what are their differences and similarities, advantages, disadvantages. Thanks in advance
0
Comment
Question by:gudii9
  • 2
3 Comments
 
LVL 47

Accepted Solution

by:
for_yan earned 500 total points
ID: 36493365
raed here about Cardinality and ordinality
http://what-when-how.com/enterprise-javabeans-3/domain-modeling-and-the-jpa-ejb-3/
search for "Multiplicity, or cardinality")


Multiplicity, or cardinality

 not all relationships are one-to-one. That is, there may be more than one object on either side of a relationship. For example, a Category can have more than one Item. Multiplicity or cardinality refers to this multifaceted nature of relationships. The multiplicity of a relationship can be:

¦ One-to-one—Each side of the relationship may have at most only one object. An Employee object can have only one ID card and an ID card can only be assigned to one employee.

¦ One-to-many—A particular object instance may be related to multiple instances of another. For example, an Item can have more than one Bid. Note that, taken from the point of view of a Bid, the relationship is said to be many-to-one.

¦ Many-to-many—If both sides of the relationship can have more than one object, the relationship is many-to-many. For example, an Item can be in more than one Category and a Category can have multiple Items.



Ordinality, or optionality

Ordinality, or optionality, of a relationship determines whether an associated entity exists. For example, we have a bidirectional one-to-one association between User and Billinglnfo, and every user need not always have billing information, so the relationship is optional. However, Billinglnfo always belongs to a User and hence the optionality for the Billinglnfo-User association is false. Having established the basic concepts of domain modeling, we can now start discussing how the domain model is persisted using the EJB 3 Java Persistence API and actually begin implementing our domain model.
0
 
LVL 7

Author Comment

by:gudii9
ID: 36584365
>>>One-to-many—A particular object instance may be related to multiple instances of another. For example, an Item can have more than one Bid. Note that, taken from the point of view of a Bid, the relationship is said to be many-to-one.

>>>Note that, taken from the point of view of a Bid, the relationship is said to be many-to-one.


is is is point of view of bid many-one or point of view of item many-one. i was thinking point of view of item. please advise

0
 
LVL 47

Expert Comment

by:for_yan
ID: 36584390

One Item may have many Bids - one-to-many from the point of view of item - so basically Item may  have the whole  collection of Bids


Many Bids may point to the same Item  - each Bid corresponds to one Item, but different Bids may refer to the same Item - many-to-one

Seems understandable to me



0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now