This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-27
Channels
- # announcements (4)
- # beginners (41)
- # biff (8)
- # cider (14)
- # clj-kondo (5)
- # clojure (45)
- # clojure-brasil (1)
- # clojure-europe (20)
- # clojure-nl (1)
- # clojure-norway (30)
- # clojure-uk (10)
- # clojurescript (8)
- # cursive (25)
- # datomic (20)
- # emacs (11)
- # events (1)
- # hoplon (9)
- # humbleui (7)
- # hyperfiddle (6)
- # lsp (63)
- # matrix (1)
- # observability (20)
- # off-topic (36)
- # polylith (11)
- # re-frame (2)
- # releases (1)
- # rewrite-clj (6)
- # scittle (42)
- # sql (6)
- # squint (86)
- # tools-deps (9)
Bit of an open ended question: does anyone have recommendations for how to lean on SQL to create what might be called "self-describing databases?" The stuff most SQL implementations expose via the information_schema
views provides some rudimentary metadata, but because these are system-level views rather than real tables, you can't do things like add a description
column to information_schema.tables
. Usually, this stuff is provided in a data dictionary or documentation outside the DB itself, but having some of it live in the DB seems like it could be very useful - I've begun recording table-level metadata in a metadata
schema to keep it "closer to the data" in a queryable form.
Going too far with this idea seems like another iteration of the https://en.m.wikipedia.org/wiki/Inner-platform_effect; I'm looking to augment rather than replicate the system-level views. Does anyone have resources or recommendations on this?
I've done this where I work. We needed to add attributes to tables, table columns, and table columns in a specific context (e.g., list view, search controls, single record preview, etc). It is nice for semi-technical internal users. The thing that becomes harder is deployments, because now you need to sync not only code, but data as well. When I get a chance, I plan to make it so all of the data can be synced to and from text files (e.g., toml), and run that as a deployment step for at least some of the data if it can be maintained in text.
Interesting that the article you pointed to uses EAV as an example of an inner platform effect. We didn't use EAV, but it isn't obvious to me that it would be a bad idea in this context.
It still makes enforcing relations harder in the metadata context; stuff like "The table_name
col in the load_history
table needs to reference an existing primary key in the table_info
table" is not easy to jam into an EAV table
Yea but there are benefits like being able to add new attributes at runtime. So might be worth it in some cases.
I might be missing what you're trying to do but some databases allow you to add text as metadata to DDL objects. You don't mention which database you're using but PostgreSQL allows you to add COMMENTs to database objects (schemas, tables, columns etc) using syntax like this:
COMMENT ON TABLE <schema-name.table-name> IS 'This is a comment on a table.';
COMMENT ON COLUMN <schema-name.table-name.column-name> IS 'This is a comment on a column.';
You can see these comments when you look at the DDL for the object or you can write a query to return them. Other databases may have similar functionality.