Skip to content

Database Schema

Database Schema

14Build uses a well-structured database schema to manage key entities such as users, projects, tenders, SOQs, and escrows. The database is designed to ensure data integrity, scalability, and seamless interaction with the on-chain Stellar blockchain.


1. Overview of Database Tables

The following are the key tables in the 14Build database:

Table NamePurpose
usersStores user information and role-based data.
projectsHolds details about projects and their lifecycle.
tendersManages tenders, RFPs, RTS submissions, and bids.
soqsTracks the Schedule of Quantities (SOQ).
escrowsHandles escrow details and payment workflows.

Each table is designed with relationships to ensure consistency and efficiency.


2. Users Table

The users table manages all user-related data, including decentralized identities and roles.

Schema

ColumnTypeDescription
user_idUUID (Primary Key)Unique identifier for the user.
didVARCHAR(255)Decentralized Identity (on-chain DID).
nameVARCHAR(255)Full name of the user.
emailVARCHAR(255)User email for contact and authentication.
roleENUMUser role (e.g., Client, Contractor, Engineer).
kyc_statusENUMKYC verification status (Verified / Pending).
created_atTIMESTAMPAccount creation date.
updated_atTIMESTAMPLast update timestamp.

Relationships

  • Linked to projects table through user_id (project creator).
  • Referenced in the tenders and escrows for role-specific actions.

3. Projects Table

The projects table holds all information about created projects, including links to tenders, SOQs, and escrows.

Schema

ColumnTypeDescription
project_idUUID (Primary Key)Unique identifier for the project.
created_byUUID (Foreign Key)References the user_id of the project creator.
nameVARCHAR(255)Project name.
descriptionTEXTDetailed description of the project.
statusENUMProject status (Draft, Tendering, Completed).
budgetDECIMALProject budget.
start_dateDATEStart date of the project.
end_dateDATEEnd date of the project.
created_atTIMESTAMPProject creation date.

Relationships

  • Linked to the users table (created_by).
  • Linked to the tenders table through project_id.
  • Linked to the soqs and escrows tables for project-specific details.

4. Tenders Table

The tenders table manages the tendering workflow, including RFPs, RTS submissions, and bid evaluations.

Schema

ColumnTypeDescription
tender_idUUID (Primary Key)Unique identifier for the tender.
project_idUUID (Foreign Key)References the associated project_id.
created_byUUID (Foreign Key)References the user_id of the tender creator.
statusENUMTender status (Open, Closed, Awarded).
rfp_detailsTEXTScope, requirements, and deadlines.
rts_submissionsJSONBArray of bid submissions with amounts and details.
awarded_bidJSONBSelected bid details (e.g., contractor, cost).
created_atTIMESTAMPTender creation date.

Relationships

  • Linked to the projects table (project_id).
  • Linked to the users table (created_by for tender creator).
  • Linked to the escrows table when bids are awarded.

5. SOQs Table

The soqs table tracks Schedule of Quantities (SOQ) for each project.

Schema

ColumnTypeDescription
soq_idUUID (Primary Key)Unique identifier for the SOQ.
project_idUUID (Foreign Key)References the associated project_id.
categoriesJSONBList of SOQ categories (e.g., materials, labor).
jobsJSONBDetailed jobs with quantities, unit costs, and labor.
variationsJSONBChange requests or updates to the SOQ.
total_costDECIMALSum of all costs in the SOQ.
created_atTIMESTAMPSOQ creation date.

Relationships

  • Linked to the projects table (project_id).
  • Referenced in the tenders table when generating RFPs.

6. Escrows Table

The escrows table handles all escrow transactions tied to projects and tenders.

Schema

ColumnTypeDescription
escrow_idUUID (Primary Key)Unique identifier for the escrow.
tender_idUUID (Foreign Key)References the awarded tender_id.
milestone_idUUIDReferences project milestone (if applicable).
client_idUUID (Foreign Key)References the user_id of the client.
contractor_idUUID (Foreign Key)References the user_id of the contractor.
amountDECIMALAmount locked in the escrow.
statusENUMEscrow status (Pending, In Progress, Released).
proof_of_workJSONBUploaded milestone proofs (off-chain hashes).
released_atTIMESTAMPDate when funds were released.

Relationships

  • Linked to the tenders table (tender_id).
  • Linked to the users table (client_id and contractor_id).

7. Relationships Diagram

Users
|-- Projects (created_by)
|-- Tenders (project_id)
|-- Escrows (tender_id, client_id, contractor_id)
|-- SOQs (project_id)

8. Summary

The 14Build database schema ensures:

  • Data Integrity: Relationships and constraints maintain consistency across entities.
  • Scalability: JSONB and efficient indexing allow for large datasets (SOQs, RTS).
  • Security: Sensitive data like user identities and escrow details are encrypted.
  • On-Chain Integration: Critical records link to on-chain entities for transparency.