问题
I have to present some complex queries and PL/SQL codes to people who don't know anything about my project. I need to explain how tables are connected, how conditions are affecting the outcome, joins, loops, etc.
Is there a way to document this SQL and PL/SQL logic using UML diagrams?
回答1:
Your question is very broad. Nevertheless some hints:
- Indeed, you can explain the data structure with class diagram. This allows people to understand how the data is related/connected. Moreover, it will be very familiar if your audience is object oriented developer.
- You can explain some specific scenarios with example data, using object diagrams that use the above mentioned classes.
- If the PL/SQL code is very complex, you may use activity diagrams to give a visual overview of the processing logic. Interestingly, activity diagrams also support object flows, which allows to relate the activities to your class model. However, avoid to go into a detailed retranscription (control flow statement by statement): activity diagrams are not meant for visual programming, and it would be counter productive in view of the visual complexity.
If you want to know more:
- an interesting introductory reference about mapping UML associations with SQL joins
- another SO answer on using class models to document data models, including SQL. There's a link to a nice step by step tutorial for UML->SQL.
- a short explanation for reverse engineering for SQL-> UML
- great article from Scott Ambler. It explains that even (PL/SQL DML) triggers can be documented in a class diagram, and it provides a ready to use UML profile that allows to use UML stereotypes to highlight some database constructs;
来源:https://stackoverflow.com/questions/66076001/explain-sql-query-using-uml-diagram