Data management, warehousing, and reporting in SQL Server.
['mandi' (mun-dHee) is Telugu for 'storehouse, warehouse, godown.']
"These are important." - Laszlo
-
Always include the name of the 'product', and then a $. Otherwise things won't sort nicely and maintenance becomes a nightmare. For example, if the view relates to MS grades, preface the name with
GRADES$
. -
Generally speaking the 'product' name should match the subfolder that it lives in.
-
When picking a name, think about the class of data in question, broadly. There are a few notable exceptions to this rule, namely
EMAIL$
(all things notifications) andREPORTING$
(views for the progress trackers and others). -
Views don't get a 'v_' prefix database side, but use the prefix on the file name [views should be functionally interchangeable with tables, so no prefix].
-
If there is a school-specific aspect, use
#SCHOOL
ABBREVIATION to indicate. -
Put
|refresh
after the file name if this is a script that refreshes a local table. -
If it is a Powerschool table name, put it in ALL CAPS. Otherwise generally use lower case for the name of your file. (
EMAIL$failure_monitoring#NCA
) -
Stored procedures should have
sp_
in front of their name.
Jokes are fine but please be descriptive about what changed.
-
Use the flag
/*--UPDATE FIELD FOR CURRENT TERM--*/
for code that requires regular turnover (hex, trimester, etc.) to allow for easy Find/Replace action. Or better yet, make yourJOIN
dynamic. -
When creating or adjusting a cached refresh, use the following procedure to quickly replicate a static table from your view:
EXEC sp_CacheView '[DATABASE]', '[VIEW]', '[DROP/REBUILD? (1/0)]'
-
All users are granted
READ
permission through thedb_data_tool_reader
server role. Any public-facing views must be explicity given access throughGRANT SELECT
:GRANT SELECT ON [DATABASE]..[TABLE OR VIEW NAME] TO db_data_tool_reader
-
Avoid hard-coding dates. If the date range is part of a regularly occuring reporting term, add an entry to the
REPORTING$dates
table. -
Avoid hard-coding termid parameters. Instead, use the scalar-valued function
dbo.fn_Global_Term_Id()
-
Avoid hard-coding academic year parameters. Instead, use the scalar-valued function
dbo.fn_Global_Academic_Year()
Follow along at home with this Asana Project