Presentation is loading. Please wait.

Presentation is loading. Please wait.

Database Development Tr ươ ng Quý Quỳnh. References UDEMY: SQL Database MasterClass: Go From Pupil To Master! Database Systems - A Practical Approach.

Similar presentations


Presentation on theme: "Database Development Tr ươ ng Quý Quỳnh. References UDEMY: SQL Database MasterClass: Go From Pupil To Master! Database Systems - A Practical Approach."— Presentation transcript:

1 Database Development Tr ươ ng Quý Quỳnh

2 References UDEMY: SQL Database MasterClass: Go From Pupil To Master! Database Systems - A Practical Approach to Design, Implementation, and Management by Thomas Connolly

3 Outline Sub-Queries Joins User-defined functions Stored procedures Views SQL profiler, Optimizing

4 Sub-Queries A Subquery is a Select within a Select or a From or a Where. Example: Select Id,(Select Name from Person where Id=Class.PersonID), PersonID from Class. Select ID, PersonID from (Select * from Class) C. Select ID,PersonID from Class where PersonID in (SelectID from Person where Name=“QuynhTQ”)

5 Sub-Queries Advantages – To quickly get more data from another Table. – To Optimize a SQL Statement. Disadvantages – Performance issues.

6 Joins Inner join – When use inner join, you are telling the DB that I have 2 tables and those tables have relationship where value1=value2. – When use inner join, I will not show value from either table or row where this statement is not true. Outer join – Usually used “left outer join”.

7 User-defined functions Scalar function – Returns only 1 value. – Can not join to scalar function – If you put it in select, it will execute 1 time for every row. Table function – Returns a table variable – Can join to table function

8 Stored procedures Store procedure is similar to UDFs but returns zero or more values.

9 Views A view is a way to save a query for later use. A table holds all its data, but view is a smaller portion. Like a window looking to the house at the table.

10 View Advantages. – Save queries. – Security. Disadvantages. – Performance.

11 Introduction to SQL profiler

12 Optimize SQL Remove Scalar UDFs (Replace with view wherever possible) Join properly Move where to join clause if possible Query object order Add indexes Remove cursors


Download ppt "Database Development Tr ươ ng Quý Quỳnh. References UDEMY: SQL Database MasterClass: Go From Pupil To Master! Database Systems - A Practical Approach."

Similar presentations


Ads by Google