# Module

A **Module** represents a **sub‑section of an Entity screen** where input fields and data presentation components are placed.\
Modules are the primary layout building blocks used to design Smart Forms in ONEWEB.

Each module defines **how data is structured, displayed, and stored**, and serves as a bridge between **user interface design** and **database persistence**.

***

### Purpose of Module

Modules are used to:

* Organize input fields into logical screen sections
* Define the layout structure using rows and columns
* Map UI components to database tables
* Control how data is retrieved, saved, and displayed
* Enable reusable and modular form design

A well‑designed module helps keep Smart Forms **clean, readable, and scalable**.

***

### Module and Layout Design

Within a module, users can:

* Add **rows and columns** based on UI design requirements
* Drag and drop input fields into the module layout
* Arrange fields to match business workflows
* Create complex forms while maintaining structure

Modules allow flexible design while enforcing a consistent data model.

***

### Database Mapping

Each **Module is mapped to exactly one database table**.

During module configuration, users must define:

* **Database Table Name**
* **Primary Key(s)**
* **Sequence or Auto‑increment logic**

This mapping ensures that:

* Data entered via forms is persisted correctly
* Updates and retrievals are consistent
* The entity maintains data integrity

***

### Module Configuration Capabilities

Module configuration provides advanced features, including:

* Definition of table keys and sequences
* Field‑to‑column mapping
* Control over insert, update, and search behavior
* Option to write **manual SQL queries**

#### Manual SQL Support

Users can optionally define custom SQL queries to:

* Retrieve data using alternate logic
* Handle complex joins or conditions
* Optimize performance for specific use cases

This provides flexibility beyond standard CRUD operations when required.

***

### Types of Modules in App Designer

App Designer supports **three types of modules**, each serving different data modeling scenarios.

***

#### 1. One‑to‑One (1–1) Module

* Represents a **single record** associated with the entity
* Commonly used for main entity details
* Example: Customer Profile, Order Header

**Use cases**

* Core business data
* Simple, flat data structures

***

#### 2️. One‑to‑Many (1–Many) Module

* Represents **multiple child records** related to a parent entity
* Typically used for detail or line‑item data
* Example: Order → Order Items, Invoice → Invoice Lines

**Use cases**

* Lists or tables of related data
* Repeating data sections

***

#### 3️. Reusing Module

* Reuses an existing module across multiple entities or forms
* Promotes **standardization and reuse**
* Reduces duplication of configuration and logic

**Use cases**

* Shared address blocks
* Common reference data sections

***

### Usage Guidelines

* Design modules based on **business structure**, not just UI needs
* Keep one module mapped to one database table
* Use 1–Many modules for repeating data
* Use Reusing modules for shared form sections
* Avoid overly complex modules—split when necessary
* Use manual SQL only when standard configuration is insufficient

***

### Summary

The **Module** is the core building unit of Smart Forms in ONEWEB.

Key points:

* Modules define screen sections and layout
* Each module maps to one database table
* Supports flexible UI design with row/column structures
* Provides strong database integration
* Supports 1–1, 1–Many, and Reusing module types

Proper module design ensures Smart Forms are **structured, maintainable, and aligned with underlying business data models**.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.onewebstack.com/designer-reference/app-designer/entity/create-new-entity/module.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
