Modeling Data Structures with Liferay Objects

The first step in building an application is to model its data structures. This requires some brainstorming about the types of data entities you want to store, along with their attributes and relationships. Once determined, you can implement your data structures as discrete Liferay objects. From there, you can add custom business logic and continue to iterate as your application evolves.

In this lesson, you'll consider the fundamentals of effective data modeling with Liferay Objects.

Identifying Data Entities

Data entities represent discrete types of information stored and used within an application, such as a “customer” in an e-commerce solution. Each entity has specific attributes (e.g., name, email) that determine the data it stores. You can implement your data entities as object definitions. These objects can be anything from insurance claims and support tickets to courses and commerce products.

Adding Attributes

Attributes represent database columns that store specific types of information for an application, such as text, numeric, and date values. Defining attributes for data models involves adding fields to object definitions to receive user input. You can also create picklists and use them with objects to provide users with predefined single-select and multi-select fields. You'll explore object fields more thoroughly in Module 2.

Defining Relationships

Relationships are key to creating data models that accurately represent real-world entities. They determine how data is connected in your application and capture entity interactions and dependencies. You can define one-to-many and many-to-many relationships between definitions. These relationships add fields or tables to each object for relating their entries, empowering you to access entry data in different object contexts. You'll explore object relationships more thoroughly in Module 3.

Best Practices for Data Modeling with Liferay Objects

Effective data modeling is essential to successful Liferay Objects implementations. Understanding the alternative techniques available helps you design solutions that are efficient, adaptable, and consistent across Liferay DXP.

Two Schools of Thought

Data modeling is often characterized by two competing perspectives:

  • Normalized modeling: Originating from relational database management systems (RDBMS) and online transaction processing (OLTP) applications, this approach favors smaller, interconnected objects. It minimizes data duplication and retrieves data only when necessary, relying on the RDBMS's efficient joining capabilities. A normalized model's success generally depends on its level of normalization, with Third Normal Form (3NF) as a common baseline for ensuring data integrity and storage efficiency.
  • Denormalized modeling: Commonly used in reporting platforms and online analytical processing (OLAP) applications, this approach favors larger, self-contained objects. It prioritizes retrieving complete entities (even with potential data duplication) to optimize read performance, especially with large datasets. Denormalized models often employ a flattened structure, reducing the need for joins and other database operations.

Both approaches are valid when working with Liferay Objects.

Guiding Principles

Regardless of which modeling approach you favor, follow these principles to when modeling your data structures with Objects:

  • Use System Objects: Before creating a custom object, check whether one of Liferay's existing system objects (e.g., User, Account, Organization) already meets your requirements. Extend a system object whenever it fits your use case.
  • Balance Fragmentation and Grouping: Avoid both over-fragmentation (splitting data across too many objects) and over-grouping (consolidating unrelated data into a single object). When deciding where to draw the lines, weigh the trade-offs for data integrity, development effort, and future adaptability.
  • Use Relationships Strategically: Employ relationships primarily when dealing with repeating data. Define the repeatable data as separate objects and establish relationships to link them.
  • Separate Data by Permission Needs: Considering splitting object definitions when distinct parts of your data model require different permissions.
  • Use Meaningful Names: Apply clear, consistent, and descriptive names to object definitions, fields, and relationships to avoid ambiguity or confusion. This improves long-term usage and maintainability.
  • Organize with Folders: Structure your object definitions in folders, using clear names to improve organization and simplify migration.

While not exhaustive, these principles provide a solid framework for designing effective, maintainable data models with Liferay Objects.

Conclusion

Effective data modeling is the cornerstone of successful Liferay Objects implementations. By applying the guiding principles above, you can design solutions that are robust, adaptable, and aligned with your application's specific needs.

Next, you’ll see how Clarity's solutions can implement the principles you’ve learned.

Loading Knowledge