Suppose you download a sample database, whether it be AdventureWorks, Northwind, or whatever other database. What steps do you take to thoroughly understand the layout of the database?
Do you use Excel or some software to note all the table names, columns, and keys? Do you use some tool to draw a Entity Relationship Diagram?
I ask this because if I were to do joins or subqueries, I need to know all the relevant tables, columns, and keys to write the query. What would you do to learn the database layout fully to perform such queries?
Thanks for all the advice!
select object_schema_name(ep.major_id) [Schema], object_name(ep.major_id) TableName, c.column_id ColumnId, c.name ColumnName, ep.value [Description] from sys.extended_properties as ep inner join sys.sysobjects as so on so.id = ep.major_id left outer join sys.columns as c on c.object_id = ep.major_id and c.column_id = ep.minor_id where so."type" = 'U' and so.name <> 'sysdiagrams' and ep.class_desc = 'object_or_column' and ep.name = 'MS_Description' order by object_schema_name(ep.major_id), object_name(ep.major_id);