Hi Iraiana,
Hope you're doing well.
That is an interesting point to discuss :)
You are indeed correct. There is a difference between the Logical Database (the one you see in Service Studio) and the Physical Database (the one you see using for example SQL Server).
About the columns (meaning attributes), please check this documentation:
https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Data/Database_Reference/How_Data_Model_Changes_are_Handled
I believe you will understand how things work and why. It explains how OutSystems platform handles deleting, adding or renaming attributes, as well as changing their properties.
About the tables (meaning entities), the process is exactly how you described. If you deleted a table in the application model (Logical Database), it won't be deleted in the Physical Database. The main reason why this happens is because if you rollback to a previous version, both the table and the data are still preserved and stored in the database.
That said, if you end up creating a new table with the same logical name, its physical name will be created with a sufix (Table1, Table2, etc.).
An exception to these rules are indexes. If you create an index using Service Studio, it will be created in the Physical Database. On the other hand, it will be deleted from the Physical Database if you delete it in Service Studio.
Overall, the main reason why OutSystems preserve this information (tables and columns) is because of versioning and to preserve data. Of course, you can end up having unnecessary tables and attributes in your physical database. My suggestion is that you keep your physical database as clean as possible :)
Like Agno Silveira posted, there are already some tools and components that may help you removing these unused elements from your database.
Personally, I suggest this one:
https://www.outsystems.com/forge/component-overview/5018/db-cleaner-on-steroids
Hope that this helps you!
Kind regards,
Rui Barradas