0

It is possible to create a UUID column in SQL:

create table table_name (
    uuid_column_name uuid,
);

Is it possible to create a SourceURI column in SQL as well? E.g.:

create table table_name (
    source_uri_column_name ?,
);

Note that a question mark has been added as internet research and several attempts were unsuccessful.

Discussion

Perhaps the definition of SourceURI is incorrect in our company? We define a SourceURI like this:

prefix:UUID:UUID

In which a prefix is a String, e.g. "hello" and a UUID is a UUID, e.g. cd15b4ef-f3c4-49bd-92f4-10a93c041c75.

When I searched for SourceURI I did not find the same definition as for UUID. It seems we have another definition regarding sourceURI in the company or it is not valid at all?

0
4

Common practice when modelling compound values like your SourceURI is to split them into the component parts, which have a column each. These are given the types basic to the DBMS i.e. string and UUID.

On retrieval the parts are passed to the application as-is, or concatenated with appropriate punctuation. You may choose to create a calculated column or similar to ensure consistentcy across the application.

Postgres has the composite type construct which may simplify implementation. I have not used it so cannot comment on the implications.

1
  • The composite type looks like it would be perfect for this. – Robert Harvey Feb 28 '16 at 0:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.