?
Solved

cardinality vs Ordinality in JPA

Posted on 2011-09-06
3
Medium Priority
?
2,454 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 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses
Course of the Month14 days, 19 hours left to enroll

839 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