Mark As Completed Discussion

Identifying Entities and Relationships

In low-level design, identifying entities and relationships is a critical step in understanding the structure and dependencies within a system. Entities are the objects or elements that exist within the system, while relationships define how these entities are interconnected.

In the context of designing a payment app, let's identify some entities and relationships:

  • Entities:

    • User
    • Transaction
    • PaymentMethod
    • Address
  • Relationships:

    • A User can have multiple Transactions
    • A Transaction is associated with a User
    • A Transaction is associated with a PaymentMethod
    • User has multiple Addresses

By identifying the entities and their relationships, we can begin to visualize how the different components of the payment app interact with each other.

Let's take a closer look at an example.

TEXT/X-JAVA
1// Example entity and relationship
2
3class User {
4
5  private int id;
6  private String name;
7  private String email;
8  private List<Address> addresses;
9  private List<Transaction> transactions;
10
11  // constructor, getters, and setters
12}
13
14class Transaction {
15
16  private int id;
17  private User user;
18  private PaymentMethod paymentMethod;
19  private double amount;
20  private boolean status;
21
22  // constructor, getters, and setters
23}
24
25class PaymentMethod {
26
27  private int id;
28  private String name;
29  private String type;
30  private boolean isActive;
31
32  // constructor, getters, and setters
33}
34
35class Address {
36
37  private int id;
38  private String street;
39  private String city;
40  private String state;
41  private String zipCode;
42
43  // constructor, getters, and setters
44}
JAVA
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment