Solved

cardinality vs Ordinality in JPA

Posted on 2011-09-06
3
1,981 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
java jdbc batch example 8 40
Java exception bubble up 2 21
Java basic valueOf question 1 29
restrict decimal places for double datatype 10 19
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…
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 …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

809 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