TAILIEUCHUNG - SQL PROGRAMMING STYLE- P11

SQL PROGRAMMING STYLE- P11:Im mot trying to teach you to program in SQL in this book. You might want to read that again. If that is what you wanted, there are better books. This ought to be the second book you buy, not the first. I assume that you already write SQL at some level and want to get better at it. If you want to learn SQL programming tricks, get a copy of my other book, SQL for Smarties (3rd edition, 2005). | Scalar versus Structured Parameters 167 Use Calendar Tables to Perform Temporal Calculations Rationale The first thing to do when you start a new application is to build a Sequence and Calendar table. The calendar table is keyed on a date and the nonkey columns contain information about that date relative to the enterprise. Is this a workday or a holiday What is its Julian date number What fiscal calendar does it fall in In short anything to do with how the enterprise uses time must be detailed. The table for 20 years of data is only about 7 050 rows which is nothing. You can look up programming tricks with this table in newsgroups or in Celko 1999 . Exceptions None Consider Auxiliary Tables to Perform Computations Rationale If a function or computation returns only a few thousand values instead of computing it over and over put the parameters and the results into an auxiliary table that can be joined to the tables to get the answer. SQL is good at JOINs but not at computations play to its strength. Exceptions If the computation can be done with simple four-function math then auxiliary tables could be overkill. If the computation is unpredictable or known to have a huge range then it might not be possible to put it into an auxiliary table. Scalar versus Structured Parameters There are no arrays lists or other data structures in Standard SQL-92. There is only one data structure the table. There are base tables views and derived tables but the operative word in that list is table. Procedural languages depend on other data structures such as arrays lists and records. Newbie programmers who learned to program with such structures want to use them desperately when they get to SQL. The result is that they kludge code with poor performance. Even worse they use dynamic SQL to construct a statement or an entire program on the fly. Stored procedure calls expect scalar parameters not structured or dynamic parameters. By using a few coding tricks you .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.