Skip to main content

Creating a DB Entity

DB Entities are used to define data that requires persistence. For each DB Entity created, a corresponding database table is generated.

Example: In an e-commerce application, entities such as Customer, Address, Order, OrderItems, and Product are defined as DB Entities since they need to be stored persistently.

Key Characteristics of a DB Entity​

  1. Uniqueness – Each entity has a unique identifier, often called a Primary Key.
  2. Attributes – Entities have properties that describe them, known as fields or columns in a database table.
  3. Relationships – Entities can be linked to other entities through relationships (e.g., one-to-many, one-to-one, many-to-many).
  4. Persistence – For every DB Entity a relational table is created.

Add Folder​

For better organization and accessibility, users can group database entities into folders.

  1. Create a Folder:
    • Right-click DB Entities in the Explorer Menu.
    • Select Add Folder and provide a name for the folder.

Creating a DB Entity​

Steps to Create a DB Entity​

  1. Add a New Entity

    • Open the Explorer menu.
    • Right-click on DB Entities/Folder.
    • Select Add Entity.
  2. Configure Entity Properties

    In the Properties Panel, set the required fields:

    PropertyDescriptionComments
    Name*Name of the entity.Must start with an uppercase letter followed by alphanumeric characters or ''. No spaces or special characters except ''. Cannot start with a number. Maximum length: 50 characters. Specifies the table name in the database.
    Plural Name*Plural form of the entity name.Automatically generated based on the Name field. Plural name used to create API route URL for the default service actions.
    SuffixA DB entity suffix is an optional string appended to the table name.Values: Yes/No. Default: No.
    Is BinaryUsed to store files within a database table as described below.Values: Yes/No. Default: No.
    Is ActiveIndicates if the entity is active.Values: Yes/No. Default: Yes.
    DescriptionDescription of the entity.Optional.
  3. Save the Entity

    • Click the Save icon.
    • Upon successful creation, you should see the message: "DB Entity saved successfully".

Entity Suffix​

A DB entity suffix is an optional string appended to the table name when creating an entity in a database. Suffix is used to distinguish or categorize tables without modifying the core entity name.

Purpose of a Suffix in a DB Entity​

  • Helps differentiate similar entities (e.g., User_Log vs. User_Details).
  • Can indicate entity type, function, or versioning (e.g., _Archive, _Temp).
  • Useful for naming conventions in large-scale applications.

Examples​

Entity NameSuffixFinal Table Name
Order_HistoryOrder_History
User_DetailsUser_Details
Transaction_ArchiveTransaction_Archive

Binary Entity​

A Binary Entity is a specialized type of DB Entity designed specifically for storing files within an application. Storing binary data (such as images, PDFs, or other files) in a dedicated table improves performance and maintainability by preventing frequent updates to regular entities, which can negatively impact database efficiency.

Scenario: Managing User Profiles with Profile Pictures​

When designing an application that stores user profiles along with profile pictures, you can choose between:

  1. Storing profile pictures within the UserProfile table (not recommended).
  2. Separating profile pictures into a dedicated Binary Entity (ProfilePic) (recommended for better performance).

Why Separate ProfilePic into a Different Table?​

  • Performance Optimization – Frequent updates to user profiles (e.g., name, email, preferences) won't affect large binary data.
  • Reduced Database Load – Queries on UserProfile remain fast since they don't load binary data.
  • Better Scalability – Storing binary data separately allows using optimized storage solutions (e.g., cloud storage).
  • Efficient Caching – Profile data can be cached efficiently without storing large image blobs.

Recommendation: Store large files in external storage (e.g., Blob Storage, S3) and maintain only a reference in the Entity.

Default Attributes of a Binary Entity​

When a Binary Entity is created, it automatically includes the following attributes:

AttributeDescription
Id (Primary Key)Unique identifier for the binary entity record.
FileNameName of the uploaded file.
BinaryDataThe actual binary content of the file (stored in a BLOB field).
FileExtensionThe file type extension (e.g., .png, .pdf).
FileSizeSize of the file in bytes.
ContentTypeMIME type of the file (e.g., image/png, application/pdf).
URLA reference or direct access URL.

Additional attributes can be added based on the specific requirements.

Structure of a DB Entity​

When a DB Entity is created, it consists of the following components:

  1. ID Attribute (Primary Key)

    • Automatically generated as the primary key.
    • Ensures uniqueness for each record.
  2. List of Attributes

    • Represents the properties of the entity.
    • Each attribute has a name, data type, and optional constraints (e.g., required, unique).
    • Example attributes for a Customer entity:
      • CustomerID (Primary Key)
      • Name (String)
      • Email (String, Unique)
      • CreatedDate (DateTime)
  3. Actions Folder (CRUD Operations)

    Contains pre-built operations for managing entity data:

    • Create – Adds a new record.
    • Read – Retrieves existing records.
    • Update – Modifies existing data.
    • Delete – Removes a record from the database.
    • Bulk Create or Update – Adds multiple records.
  4. Indexes Folder

    • Stores database indexes that improve query performance.
    • Can be manually added for optimizing searches on frequently queried attributes.