lowlydba / dba-multitool

:hammer_and_wrench: T-SQL scripts for the long haul: optimizing storage, on-the-fly documentation, and general administrative needs.
https://dba-multitool.org
MIT License
90 stars 26 forks source link

[Request] sp_doc - virtual PK, real and virtual Relations (FK, object references, column references) #191

Closed aisbergde closed 3 years ago

aisbergde commented 3 years ago

Is your feature request related to a problem? Please describe.

Most PK and relations in my databases are virtual, most of them between views. I also want to document them. There are 3 kinds of relations I want to document

Describe the solution you'd like

There should be a way to write them into the database and to read them out for documentation. A good idea would be to use extended properties to write this information into the database and to use them. There could be a specific syntax (specific names for these properties and a specific format) which could be recognized by sp_doc

Currently, I am working on an open source project to connect an additional repository database to a normal database, I sync some metadata with extended properties, there are also virtual PK, virtual index, virtual relations, SQL code parsing to detect column data lineage and some more: https://github.com/DataHandwerk/DataHandwerk-toolkit-mssql It is not yet documented, only some description of the architecture, for example https://raw.githack.com/DataHandwerk/DataHandwerk-toolkit-mssql/main/docs/build/html5/dhw-arc42.html#section-building-block-view

The question is: how to document this, how to visualize.

Describe alternatives you've considered

lowlydba commented 3 years ago

Interesting project and ideas! This would be a pretty big scope and I'd like to make the approach as generic as possible if it were to be added to sp_doc.

If I'm understanding correctly, a basic implementation may look something like:

I'm going to be busy with some personal things for the next month or two, so not sure how much time I can dedicate to this short term, but I think its a really promising enhancement and will noodle over the idea. Of course, feel free to open a pull request as well in the mean time :)

aisbergde commented 3 years ago

I could learn how this procedure is built and try to create pull requests step by step

lowlydba commented 3 years ago

I should finally have some time to work on this soon.

I am planning to start with the generic "show all EPs in a table" approach and then do some testing to see if I can efficiently auto-detect when an EP value refers to a column or other object, then make it a link.

This would be the most simple approach to implement and to use, since it wouldn't require defining custom key/value formats at all.

lowlydba commented 3 years ago

@aisbergde The new parameter @AllExtendedProperties is now on the dev branch, if you want to do any light QA since you seem to have great edge cases in your existing data :)

It should allow you to view n extended properties for any given column/object/etc. which I hope will be a big step forward for your needs.

aisbergde commented 3 years ago

Currently I am on holidays. I could do this only in 2 weeks. But you should not wait.