?
Solved

cardinality vs Ordinality in JPA

Posted on 2011-09-06
3
Medium Priority
?
2,216 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 47

Accepted Solution

by:
for_yan earned 2000 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month12 days, 18 hours left to enroll

777 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