In object modeling, a link and an association are concepts used to represent relationships between classes and objects.
Link:
- A link defines the relationship between two or more objects. It is considered as an instance of an association, representing a connection between instances of classes.
- Classes: Person and Company Association: Ownership Link: Jhon owns stock in a company, Marry owns stock in a company, etc.
- Suppose there’s an association called “Ownership” between Person and Company classes .Jhon, Marry, James, Sue, Kriti are instances of the Person class. The link is the specific connection between, for example, Jhon and the company he owns stock in.
2. Association:
- An association is a group of links that relates objects from the same classes.
- It represents a more generalized relationship between classes.
Example:
- Classes: Person and Company
- Association: Ownership
Explanation:
- The association “Ownership” describes the relationship between instances of Person and Company classes.
- It signifies that a person can own stock in zero or more companies, and a company may have several persons owning its stock.
Class Diagram: