Association
=================
An Association is a relationship between two or more Entities, often characterized by interdependence or similarity. It can be a One-To-One (monotone), one-to-many (multitone), or Many-To-Many relationship.
Types of Associations
1. One-To-One (Monotone) Association
A One-To-One Association is where each entity in the first category has only one corresponding entry in the second category.
| Entity A | Attribute A |
|---|---|
| Employee1 | Sales = 100,000 |
| Employee2 | Sales = 200,000 |
In this example, Employee1 and Employee2 are related by a single row in the “Employee” table with two columns: “Name” and “Sales”.
2. One-To-Many (Multitone) Association
A one-to-many Association is where each entity in the second category has multiple corresponding entries in the first category.
| Entity A | Attribute A |
|---|---|
| Employee1 | Sales = 100,000 |
| Entity B | Attribute B |
|---|---|
| Client1 | Customer ID = 101 |
| Client2 | Customer ID = 102 |
In this example, each client can have multiple sales associated with them, but each employee has only one customer.
3. Many-To-Many Association
A Many-To-Many Association is where two or more Entities in the first category are related to two or more Entities in the second category.
| Employee1 | Category A |
|---|---|
| John Smith | Sales = 100,000 |
| Employee2 | Category B |
|---|---|
| Jane Doe | Customer ID = 101 |
| Client1 | Product A |
|---|---|
| John Smith | Order ID = 201 |
| Jane Doe | Order ID = 202 |
In this example, an employee can have multiple Categories (sales), and a client can have multiple Products. Similarly, an employee can be associated with multiple Customers, and a product can be ordered by multiple Clients.
Relationships Between Entities
1. Active Relationship
An Active Relationship is where the entity on the left is the dependent entity and has a One-To-One or Many-To-One relationship with another entity.
| Employee | Category A |
|---|---|
| John Smith | Sales = 100,000 |
In this example, Employee John Smith has a One-To-One relationship with Category A.
2. Passive Relationship
A Passive Relationship is where the entity on the left does not have a direct Association with another entity.
| Employee1 | Department A |
|---|---|
| John Smith |
Department A does not have an Association with Employee1, as it only has one employee (John Smith).
Data Modeling and Database Design
1. One-To-One Table
In a One-To-One table, each row represents one entity, while the other column(s) represent attributes of that entity.
| Entity Name | Attribute A |
|---|---|
| Employee | Sales = 100,000 |
2. Many-To-Many Tables
In Many-To-Many tables, there are multiple rows per entity, and each row represents a relationship between two Entities.
| Category Name | Product ID |
|---|---|
| Sales | Order1 |
| Sales | Order2 |
| Customer A | Product X |
| Customer B | Product Y |
3. Joining Tables
When Joining Tables, the database engine combines rows from both tables based on matching values in a common column.
Employee Table
| Employee ID | Name | Category |
|---|---|---|
| 1 | John Smith | Sales |
| 2 | Jane Doe | Customer |
Sales Table
| Sale ID | Product ID | Quantity |
|---|---|---|
| 1 | Order1 | 1000 |
| 2 | Order2 | 2000 |
In this example, the database engine combines rows from both tables based on matching Sale ID and Product ID.
Real-World Examples
1. E-commerce Website
An e-commerce website uses Many-To-Many associations to allow Customers to purchase multiple Products in one order.
| Customer | Order |
|---|---|
| John Smith | Order1, Order2 |
| Product A | Quantity Ordered |
|---|---|
| 1000 | Order1 |
| 2000 | Order2 |
2. Social Media Platform
A Social Media platform uses Many-To-Many associations to allow users to follow multiple accounts in one profile.
| Profile | Followed By |
|---|---|
| John Smith | Employee1, Client1 |
| Account A | Followers |
|---|---|
| Order1 | Client1 |
| Order2 | Jane Doe |
In this example, a user can have multiple followers (Employees or Clients), and each follower can be followed by multiple accounts.
Conclusion
An Association is a fundamental concept in Data Modeling, allowing Entities to represent Relationships between other Entities. Understanding the different types of associations, relationship structures, and Database Design principles is crucial for building scalable and maintainable databases. By applying these concepts to real-world examples, developers can create robust and efficient systems that accurately capture complex Relationships between Entities.