Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 1. Writing Readable SQL

Chapter 1. Writing Readable SQL

It is important to ensure that SQL code is laid out in the way that makes it easiest for the team to use and maintain it. Before you work out how to enforce a standard, you have to work out what that standard should be, and this is where the trouble often starts. SQL, unlike a language such as Python, doesn't require code to follow any formatting or layout rules in order to compile and run and, as William Brewer has noted, it's hard to find two database developers who agree in detail on how it should be done (see the summary at the end of this chapter).

In large corporations, there is often a software architect who decides on an organization-wide standard, and expects all developers to adopt the naming and layout conventions it prescribes. In smaller companies, the standard is often worked out between developers and maintenance teams at the application level. In either case, if there is no existing standard, one must be devised before coding starts. By laying SQL out carefully and choosing sensible object names you greatly assist your team members, as well as anyone who inherits your code.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial