Skip to main content

Database Schema

Each JCB field automatically contributes to the componentโ€™s database schema โ€” eliminating manual SQL creation while preserving full control over structure and constraints

What It Does

In Joomla Component Builder (JCB), every Admin View is backed by a database table. Rather than writing your own table creation scripts, JCB inspects the field definitions you configure and generates the SQL schema automatically.

This includes:

  • Field names (column names)
  • Data types (int, varchar, text, etc.)
  • Field length and precision
  • Nullability (required or nullable)
  • Uniqueness
  • Default values
  • Keys (primary, foreign)

JCB will compile this structure into:

  • install.sql โ€” for first-time installation
  • update.sql โ€” for version-to-version schema migration (optional)
  • uninstall.sql โ€” for clean removal

How It Works

  1. You create or edit an Admin View and add fields.
  2. In each field:
    • You specify data type (e.g., string, int, datetime)
    • You define rules like required, unique, nullable, or default
  3. JCB translates these into SQL column definitions at compile time.
  4. The resulting schema is injected into the install/update/uninstall SQL files and handled by Joomlaโ€™s extension installer.

Bonus Features

  • ๐Ÿ“ฆ Schema Export โ€” Generated SQL is visible in the compiled component package, so you can preview, tweak, or reuse it.
  • ๐Ÿ”„ Schema Diff Logic โ€” JCB intelligently compares previous schema versions to apply only necessary changes during upgrades.
  • ๐Ÿงช Validation Sync โ€” JCB syncs field-level validation with SQL rules to ensure frontend forms and database stay consistent.
  • ๐ŸŒ Multilingual Fields โ€” Multilanguage support integrates directly into field schema with proper index/key structure where needed.

Benefits

  • โœ… Skip Manual SQL โ€” No need to hand-write column structures.
  • โœ… DRY Principle โ€” Define once in GUI, used for DB + validation + form.
  • โœ… Consistent โ€” Prevents mismatch between frontend, backend, and DB logic.
  • โœ… Safe โ€” Outputs clean, scoped, Joomla-native SQL.

Conclusion

JCB makes database schema generation effortless and reliable by tying it directly to your GUI-defined fields. You design your component once โ€” and JCB handles the rest, ensuring that your database structure matches your logic, constraints, and validation rules precisely.