schemacrawler / SchemaCrawler

Free database schema discovery and comprehension tool
http://www.schemacrawler.com/
Other
1.62k stars 200 forks source link

Attribute definitions for virtual PK #429

Closed aisbergde closed 3 years ago

aisbergde commented 3 years ago

New Feature Request

Describe the solution you'd like

attribute definition https://www.schemacrawler.com/attributes.html allow adding virtual PK; especially to views, because it is not possible to do this in real database virtual PK could be shown like normal PK or they could be marked as virtual

related: #407

sualeh commented 3 years ago

@aisbergde - you mean being able to specify and display alternate keys, right?

aisbergde commented 3 years ago

Alternative key is also a good idea. This would be even more general.

My primary request was only a way to define virtual PK on views, because in SQL Server (and I think in other systems) you can define only real PK on tables.

But in DWH there are often more views than tables and the logic should be documented. I have all these virtual PK and also unique keys in Repositories and should be able to create these yaml files.

You already implemented attributes. This would be a good place to allow to define additional PK or unique keys.

amother idea would be to use extended Properties to store this information and to extract them: For example some "PK_list", and the value could be a comma separated list of the Columns of the PK.

Any solution would be fine: extended Properties would be better, because they could be stored directly in the database. But attribute Yaml also would be fine.

sualeh commented 3 years ago

@aisbergde - good. SchemaCrawler supports this out of the box. Please see Data Dictionary Extensions and in particular ADDITIONAL_INFO.ADDITIONAL_TABLE_ATTRIBUTES. You can extract this information using templates. See the Velocity, Thymeleaf or Mustache examples in the main download, and pick a templating language that you like.

aisbergde commented 3 years ago

Suppose I somehow manage to extract these ADDITIONAL_TABLE_ATTRIBUTES. But then they are still not displayed like PK in the diagrams. However, the idea is that you can define virtual PK that are displayed and handled like real PK.

Or is this also possible using templates? I don't know Java, Velocity, Thymeleaf, Mustache, groovy, Javascript, maven, ruby ... I see that there are many possibilities. However, I have to familiarize myself with them first. For the beginning it would be good if I learn to use grep correctly :-)

sualeh commented 3 years ago

Ok, in that case, let me think about allowing you to specify alternate keys in the attributes file, and get those displayed in the output.