AAF Data

Locally-Sourced, Artisanal Data™

Delivering Foundational Organizational Agility

AAF Data is the crucial first layer — business entity data modeling and persistence — of the Adaptív Application Foundation (AAF).

Today, AAF Data is:

  • A standalone set of
    • Generalized business entity models,
    • Database creation scripts for roles, schemas, tables, functions, and
    • Scripted lookup/reference data,
  • A Dockerized, RESTful business entity microservice (BEM) providing
    • Basic CRUD operations
      • Create,
      • Read,
      • Update,
      • Delete, and
      • SwaggerDoc OpenAPI application programming interface (API) documentation.

We have ORMs, Repository pattern, and DTOs. Isn’t data a solved problem?

In a word, no.

None of these technologies and tools address or encourage good data design, and all of them lead us down ever more compromising paths that result in unnecessary and expensive code creation and maintenance and poor data design and performance and that shift data operations from the database server, where they belong, to the service layer, forcing all kinds of anti-pattern trade-offs.

Data is absolutely foundational to information systems. If the data ain’t right, ain’t none of it gonna be right. At the very least, teams will spend lots of unnecessary time coding around or in place of things that could and should have been established clearly in the data layer with just a little thought and discipline.

The data layer — database rolesschemastablescolumnsdata typesindexesconstraintsfunctions/stored procedures, Structured Query Language (SQLscripts to create all this structure and to provide reference data, etc — is there to work for us, not the other way around. It’s important that we understand and use the right tools for a given job and that we wisely invest the time to design and create a structure that will pay dividends for years. Yes, this is not only possible but absolutely crucial to your long-term success and that of the organizations you serve. Use the data layer to model business entities and relationships and to persist their data. Design it to collect a complete, consistent data set from day one rather than only adding data elements when they’re asked for.

How Bad Things Happen … in the Data Layer

Object Relational Mappers (ORMs)

  • Are entirely unnecessary, if database column names, service property/attribute names, and user interface (UI) widget field names are all derived from a model and are therefore the same in the data layer, service layer, and presentation layer.
  • Don’t typically encourage custom roles with different privileges, e.g. database owner, database administrator, read/write, read-only, etc, an omission that can easily result in dangerously overprivileged database access and compromised data security.
  • Don’t encourage thoughtful entity or attribute naming, which is vitally important and should therefore be intentional. In AAF Data we wisely invest time thinking carefully about names or adopt naming established by those who have thought carefully in the past.
  • Don’t encourage consistency, completeness, or specificity. In AAF Data we name attributes clearly, e.g. CreatedAtDateTimeUtc, in consideration of our fellow “downstream” developers, report writers, analytics developers, and data scientists, who need to know what to expect without the need to create and maintain a separate data dictionary.
  • Do encourage (and exist in order to facilitate) data entity definition in the service layer — a dangerous anti-pattern that combines:
    • Business data entities that represent the nouns — the persons, places, and things — that our information systems are intended to manage,
    • Business processes that represent the verbs — the actions that operate on and orchestrate the interactions of these entities, and
    • Business rules (or “decisions”) are the logic and conditions that inform and constrain these processes.
  • Don’t typically “layer” data validation by leveraging the database server’s built-in and highly efficient constraints, referential integrity, etc.
  • Don’t seem to understand that any system can be modeled using:
    • Business Entities (e.g. Person, Organization, etc, which can contain scalar text-based and numeric data, as well as foreign key references),
    • Associations (e.g. Employee, which associates a Person with an Organization using their Id values as foreign keys), and
    • Hierarchies (e.g. OrganizationalUnitHierarchy, which can represent hierarchical structures using OrganizationalUnit Id foreign key values as ParentOrganizationalUnitId and ChildOrganizationalUnitId)
  • Don’t discourage poor attribute grouping that often results from the lack of a clear business entity concept, leading to data attributes that actually belong to several different entities being thrown together in a single database table.
  • Discourage the use of database stored procedures/functions. There’s a lot of value to being able to essentially conduct an application’s data operations through the same stored procedure data access layer called from the service layer, and there are certain things that can only be done server side in the database.

The result of all of this is that unexamined, unchallenged, poor data design gets “baked into” the data layer every day and then impedes progress and costs the organization, its stakeholders, and its customers money and time forever, rarely if ever getting fixed because it’s in the foundation, and changing the foundation can put the whole Jenga stack at risk.

It is the mission of AAF Data to provide a clear, complete, consistent, and performant alternative to all of this.

AAF Data Features

Containerized

Services run in Docker containers, available from DockerHub.

The business entity microservice (BEM) validates each HTTP request using a JSON Web Token (JWT) mechanism with optional cryptographic signing and encryption capabilities.

HTTP Request Validation

API-Based Data Persistence, “Soft” Deletes, and No Direct Table Access

Persists and retrieves business entity data via its API, which calls low-level POST, GET, PATCH, and “soft” DELETE database functions to ensure data integrity and performance — NO direct table access.

Consistently follows RESTful style and best practices.

RESTful Best Practices

Standard HTTP Response Codes

Returns standard and appropriate HTTP response codes, e.g. 200 OK, 201 Created, 400 Bad Request, 401 Unauthorized, 404 Not Found, 500 Internal Server Error, etc.

Accepts and returns structured JSON resource/entity data in HTTP request/response bodies as specified for each business entity.

JSON Request/Response Bodies

Entity (Resource)/Process Partitioning

Includes entities in the request URL, e.g. /entities/organization/1234, to partition low-level resource/entity operations from future high-level process invocation, e.g. /processes/InformationSystem/RegisterInformationSystemUser/.

AAF Data Rules

Custom Database Roles

The custom database roles, e.g. AafCoreOwner, AafCoreDataReadWrite, etc, are to be used appropriately (as designed and demonstrated in this project) to improve data security.

The current set of business entities and their descriptions can be retrieved using the custom GetEntityTypeDefinitions database function and includes EntityType, EntitySubtype, Language, Locale, GeographicUnit, GeographicUnitHierarchy, Organization, OrganizationalUnit, OrganizationalUnitHierarchy, Person, Employee, LegalEntity, etc.

Ready-to-Use Business Entities

Complete, Consistent Business Entity Attributes

The current set of business entity attributes and their descriptions can be retrieved using the custom GetEntityTypeAttributes database function and includes *Id bigint, *Uuid uuid, *EntitySubtypeId bigint, *TextKey varchar, LocalizedName varchar, LocalizedDescription varchar, LocalizedAbbreviation varchar, *ResourceName varchar, *Ordinal bigint, *IsActive boolean, *CorrelationUuid uuid, *Digest varchar, *CreatedAtDateTimeUtc timestamp, *CreatedByInformationSystemUserId bigint, *UpdatedAtDateTimeUtc timestamp, *UpdatedByInformationSystemUserId bigint, *DeletedAtDateTimeUtc timestamp, *DeletedByInformationSystemUserId bigint, etc.

The set of common (*) business entity attributes are to be included in each business entity definition and corresponding database table, etc.

Common Business Entity Attributes

Clear, Consistent Naming

These business entity attribute names, data types, Pascal case, etc are intentional, carefully chosen, and NOT to be altered.

When naming entities and attributes, we avoid acronyms and abbreviations, and we strive to think carefully about, to “call things what they really are“, and to be specific, e.g. AtDateTimeUtc.

Common Business Entity Attributes

Database Schema Partitioning

Each entity’s database table is partitioned using a corresponding Postgres schema, e.g. “Organization”.”Organization”.

EntitySubtype, GeographicUnit, GeographicUnitHierarchy, etc represent scripted (canonical) lists of options like an entity’s subtypes, etc.

Scripted Reference/”Look-Up” Data

Standard “Unknown” and “None” Values

Unknown (Id = -1) and None (Id = 0) are standard EntitySubtype and EntitySubtype values indicating a currently unknown/to be determined or an inapplicable entity or entity subtype value, respectively.

Soon AAF Data will also include:

  • Terraform scripts for creating AWS infrastruture and deploying the AAF Data services to the cloud,
  • JWT helper functions (encode/decode),
  • business entity modeler web application and service for extending or modifying these models and their scripted data,
  • structure service for conforming the entity data structures to the model, and
  • CRUD operation event publishing.

AAF Data Screenshots

Person Table SQL Script
BASH and SQL Scripts
Entity Data Microservice
GET EntityType – Request Parameters and JSON Response Data
Consistent Entity Data
Scroll to Top