TAILIEUCHUNG - SQL PROGRAMMING STYLE- P17

SQL PROGRAMMING STYLE- P17: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). | VIEWs Provide Row- and Column-Level Security 137 FROM Projects WHERE authorized_user CURRENT_USER Or if you need to limit access to a team you can create a table of teams to which only team managers have access. CREATE VIEW MyProjects . AS SELECT . FROM Projects AS P WHERE CURRENT_USER IN SELECT team_user_id FROM ProjectTeams AS PT WHERE Another trick is to use the CURRENT_TIMESTAMP or CURRENT_DATE in VIEWs to get an automatic update to schedules and other time-related events. CREATE TABLE AssignmentSchedule ssn CHAR 9 NOT NULL REFERENCES Personnel ssn ON UPDATE CASCADE ON DELETE CASCADE task_code CHAR 5 NOT NULL start_date TIMESTAMP NOT NULL end_date TIMESTAMP NOT NULL CHECK start_date end_date PRIMARY KEY upc start_date CREATE VIEW Assignments now ssn task_code AS SELECT CURRENT_TIMESTAMP ssn task_code FROM AssignmentSchedule WHERE CURRENT_TIMESTAMP BETWEEN start_date AND end_date Each time the VIEW is invoked it will check the clock and see if anything has changed for you. 138 CHAPTER 7 HOW TO USE VIEWS VIEWs Ensure Efficient Access Paths By coding the appropriate join criteria into the VIEW definition SQL you can ensure that the correct join predicate will always be used. Of course this technique becomes more useful as the SQL becomes more complex. VIEWs Mask Complexity from the User Somewhat akin to coding appropriate access into VIEWs complex SQL can be coded into VIEWs to mask the complexity from the user. This can be extremely useful when your shop employs novice SQL users whether those users are programmers analysts managers or typical end users . As an example consider the code for a relational division. Relational division is one of the eight basic operations in Codd s 1979 relational algebra. The idea is that a divisor table is used to partition a dividend table and produce a quotient or results table. The quotient table consists of those values of one column for which a second column had all of the values in the .

TÀI LIỆU MỚI ĐĂNG
65    130    1    26-11-2024
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.