tailieunhanh - Joe Celko s SQL for Smarties - Advanced SQL Programming P73

Joe Celko s SQL for Smarties - Advanced SQL Programming P73. In the SQL database community, Joe Celko is a well-known columnist and purveyor of valuable insights. In Joe Celko's SQL for Smarties: Advanced SQL Programming, he picks up where basic SQL training and experience leaves many database professionals and offers tips, techniques, and explanations that help readers extend their capabilities to top-tier SQL programming. Although Celko denies that the book is about database theory, he nevertheless alludes to theory often to buttress his practical points. This title is not for novices, as the author points out. Instead, its intended. | 692 CHAPTER 30 GRAPHS IN SQL The step1 node is where I begin the path. The other columns are the second step third step fourth step and so forth. The last step column is the end of the journey. The total_cost column is the total cost based on the sum of the weights of the edges on this path. The path length column is harder to explain but for now let s just say that it is a count of the nodes visited in the path. To keep things easier let s look at all the paths from s to y in the graph. The INSERT INTO statement for constructing that set looks likes this INSERT INTO Paths SELECT it is s in this example it is y in this example CASE WHEN NOT IN THEN 1 ELSE 0 END CASE WHEN NOT IN THEN 1 ELSE 0 END CASE WHEN NOT THEN 1 ELSE IN 0 END CASE WHEN NOT THEN 1 ELSE FROM Edges AS G1 Edges AS G2 Edges AS G3 Edges AS G4 WHERE s AND AND AND AND y IN 0 END I put in s and y as the out_node and in_node of the path and made sure that the in_node of each step in the path was the out_node of the next step in the path. This is a combinatorial explosion but it is easy to read and understand. The sum of the weights is the cost of the path which is easy to understand. The path_length calculation is a bit harder. This sum of CASE expressions looks at each node in the path. If it is unique within Paths in a Graph 693 the row it is assigned a value of one if it is not unique within the row it is assigned a value of zero. All paths will have five steps in them because that is the way the table is declared. But what if a path shorter than five steps exists between the two nodes That is where the self-traversal rows are .

crossorigin="anonymous">
Đã 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.