Documentation is used as way to layout and explain what's going on for reference
This should include descriptions and notes of whatever you're trying to keep a record for
This is an instruction set that is easy to share with others
Documentation is like a love letter to your future self, it's a way to say "future self, I love you so much I'm writing down everything I'm doing so you don't have to remember it later" If you don't believe me try and recall what you were doing 6 months ago in detail or a year ago, in detail.
Having everything written down makes it easier to share with others and reference later
Making sure you have the notes of what you did is important for when you have to redo or fix things
Documentation is useful in a lot of places, not just for databases, it's a way of making sure everyone is in agreement for what's going on
Having documentation also means decisions can be made and recorded so you can always look back on what you need to do if you switch projects
Documentation can be useful for the creators, but also the end-user
Documentation timing
There are a number of times you might create and update your documentation
Design documentation before database is created and write up everything you know about how you want your database to work
Updating documentation as database is used so you can fix "In my ideal world this would happen" when it crashes into "The real world of data wants to talk"
Documentation should also be reviewed on a regular basis to make sure it's staying up to date
Automated vs manual documentation
Some documentation can be automated by the database and you can run commands to update it
Schema can be created by the database after it's created so you can see how close your original planning schema is to the real world
Automating where you can is important so that your documentation is maintained well
Some documentation needs to be done by a human
Sometimes we use a combination
For example, Data Definition Language (DDL) scripts are useful for creating and modifying things, but the scripts themselves need to be documented so that everyone knows what they should be doing
How to combine manual and automated documentation tools
Automate away what you can, if there is a reasonable option to have something automatically update the documentation, do it
Have a human check everything over for making sense and matching
This can be a reasonable use case for AI, but only if it meets privacy and security standards (most don't especially on sensitive data)