Btw I think your SQL example is called "EAV Schema" and does have a legitimate purpose once in a while.
I've always wondered why more people didn't actually issue DDL for these kinds of databases. Like if you want to let your user define their own custom fields, just take what they enter and actually CREATE TABLE / ALTER TABLE to build the the tables they need. And then more or less you could just write regular queries.
Turns out sysadmins get REALLY nervous when you tell them your application needs permission to use DDL at runtime. It required a lot more filling out forms.
I was talking about an application and its accompanying database, which would still be paid for and administered by the customer, not a database outside the application which it would be accessing.
That still raised many eyebrows.
If this is the main concern, you could have two databases (or schemas, if your database supports it).
One for application configuration/storage that the application never runs DDL on and another for user data, where the tables can be created/modified dynamically.
That separation means that, at worst, user data is screwed up if there's a bug in the DDL generation, but the application should still be able to run.
At least, that was my read.
A bunch of dictionaries containing UUID/data, where each dimension is its own dict, and the dicts might or might not be running on the same system?
Well, technically, the database's own system tables have tables with such column names and responsibilities.
E.g.:
<claims>
<nameid>[email protected]</nameid>
<givenname>Foo</givenname>
<surname>Bar</surname>
<extensions>
<myCustomClaim>010231239dfadsf</myCustomClaim>
</extensions>
</claims>
It's also possible to use namespaces for extensibility, and this can even be used to guarantee that the tag names don't conflict.So instead of this garbage:
<saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:Password</saml:AuthnContextClassRef>
You'd have standard namespaced and extensible elements such as: <claims xmlns:saml="urn:oasis:names:tc:SAML:2.0:ac:classes" xmlns:adfs="urn:com:microsoft:ADFS">
<saml:nameid>[email protected]</saml:nameid>
<saml:givenname>Foo</saml:givenname>
<saml:surname>Bar</saml:surname>
<adfs:securityId>S-0-1-52534-12362341234-12312315</adfs:securityId>
<adfs:objectGuid>47e3a2d3-266a-48ad-b080-b785b4d0b45f</adfs:objectGuid>
</claims>
This would enable clients to validate the claims they do understand and ignore the claims they don't. Similarly to how X.509 does it, elements could be added to "must process" or "optional" parent elements to ensure correctness and security even in the face of a wide range of client capabilities.This is common in the XML world, but SAML had to invent its own wheels.
> attribute statement / attribute name / attribute value style
Does that even have a benefit? Is it any different that simply validating that a string is valid xml/json/something syntax?
Yeah, that's known as "entity-attribute-value model" (or just "EAV") and is considered an anti-pattern unless you actually need the flexibility it provides (which is fairly rare).
It doesn't have to be. We use this (under SQL Server) for our simple "custom attributes" mechanism (some irrelevant details omitted):
CREATE TABLE private_data.ATTRIBUTE_VERSION (
OBJECT_ID bigint,
ATTRIBUTE_NAME nvarchar(255),
ATTRIBUTE_GEN bigint,
IS_TRASH bit NOT NULL,
VALUE_BOOL bit,
VALUE_INT bigint,
VALUE_DECIMAL decimal(38, 9),
VALUE_DATETIME datetime2,
VALUE_STRING nvarchar(255),
ATTRIBUTE_TYPE AS private_attributes.ATTRIBUTE_VALUE_TO_TYPE(
VALUE_BOOL,
VALUE_INT,
VALUE_DECIMAL,
VALUE_DATETIME,
VALUE_STRING
),
CONSTRAINT ATTRIBUTE_VERSION_PK PRIMARY KEY (OBJECT_ID, ATTRIBUTE_NAME, ATTRIBUTE_GEN),
CONSTRAINT ATTRIBUTE_VERSION_FK1 FOREIGN KEY (OBJECT_ID, ATTRIBUTE_NAME) REFERENCES private_data.ATTRIBUTE,
CONSTRAINT ATTRIBUTE_VERSION_FK2 FOREIGN KEY (ATTRIBUTE_GEN) REFERENCES private_data.GENERATION,
CONSTRAINT ATTRIBUTE_VERSION_C1 CHECK ( -- At most one of the various value types can be non-NULL.
private_attributes.ATTRIBUTE_VALUE_CHECK(
VALUE_BOOL,
VALUE_INT,
VALUE_DECIMAL,
VALUE_DATETIME,
VALUE_STRING
) = 1
)
);
Since SQL Server encodes NULLs in a bitmap, having a bunch of NULLs for every non-NULL takes almost no extra space at all. But even on a "wasteful" database such as Oracle, this shouldn't add more than an extra byte per NULL.> The system does have type checking enforced by the application, but multiple applications access the data.
Traditionally, this is solved by funneling all applications through a public API of stored procedures and views/functions which enforce the desired business logic, but I understand this approach has fallen out of favor in recent years (decades?).
In the context of SAML, these values are completely arbitrary metadata without fixed meaning in the protocol itslef.
You could even use attribute names that aren't valid for XML tag names.
It's the same reason why -- for example -- AWS APIs return tags as a similar entity list. You don't see
<Name>Example</Name>
<BillingGroup>prod</BillingGroup>
but rather <tagSet>
<item>
<key>Name</key>
<value>Example</value>
</item>
<item>
<key>BillingGroup</key>
<value>prod</value>
</item>
</tagSet>
---Database EAV would likewise be 100% appropriate if users could use the database to store arbitrary attributes. (Think JIRA custom fields.)
But if users are limited to certain attributes, then encode that in the schema.
Well, that's the problem though. YAGNI, KISS, and all that.
>The reason for that is that you still want to be able have an XSD to validate.
Well, you can still validate fine when you have specific fixed metadata...
What we have now are groups like OASIS, the Shibboleth Consortium, eduGAIN, and InCommon, each defining the schema their members agree to support, and an explosion of competing standards.
By the way, even Microsoft can't interoperate with themselves. Traditional ADFS SAML can handle arbitrary multi-value attributes that Azure ADFS rejects.
It's not XML, it's XML squared: using XML to encode XML concepts instead of just using XML directly.