3 ms·
Familiarity makes consistency the only real guide in any formatting guide. So, apart from formatting rules, there are still a few bits to argue about. Try to u
by deburo 8y ago
Familiarity makes consistency the only real guide in any formatting guide. So, apart from formatting rules, there are still a few bits to argue about.
Try to use only standard SQL functions instead of vendor specific functions for reasons of portability.
I don't think this is too important as the many places I've worked at had been using the same vendor for many years. Depends on your future plans, I guess.
Include comments in SQL code where necessary. Use the C style opening closing where possible otherwise precede comments with -- and finish them with a new line.
I prefer always using -- so that adding a new line of comment only consist of prefixing it with -- instead of going on the preceding line, backspacing a bit and then starting your new line.
Do not prefix with tbl or sp_ [...]
More-so because in SQL Server, sp_ means special and not stored procedure.
Avoid, where possible, concatenating two table names together to create the name of a relationship table. Rather than cars_mechanics prefer services.
I don't think this is a good example. This table is there to support the many-to-many relationship, ye? The name "Services" doesn't really convey that.
Object oriented design principles do not effectively translate to relational database designs—avoid this pitfall.
This is too generic and deserve additional details and examples.
- mdaniel 8y ago> I don't think this is too important as the many places I've worked at had been using the same vendor for many years. Depends on your future plans, I guess. Just as a "for your consideration," using the standard ones also increases the likelihood of a new person joining the team who has also had experience with them and need not context switch to look up whatever vendorism there is. A super common case would be all the variants of `substr`: 0-indexed, 1-indexed, start+length or start+end, that kind of jazz. I deeply appreciate that a new person is only new for a little while, then they _have_ said context. I just wanted to point out that the mythical "database vendor portability" isn't the only reason to use a standard vocabulary/syntax.