Solved

cardinality vs Ordinality in JPA

Posted on 2011-09-06
3
1,903 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
micro services spring boot application error 3 187
Basic Java Case or If-Else statement... 3 50
tomcat startup error 5 59
hibernate example for saving data 19 37
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

776 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