Presentation is loading. Please wait.

Presentation is loading. Please wait.

SQL PATTERNS A NEW APPROACH FOR TEACHING SQL Karen Renaud Huda Al-Shuaily TLAD 2010 - BNCOD 2010 the 27th International Informationthe 27th International.

Similar presentations


Presentation on theme: "SQL PATTERNS A NEW APPROACH FOR TEACHING SQL Karen Renaud Huda Al-Shuaily TLAD 2010 - BNCOD 2010 the 27th International Informationthe 27th International."— Presentation transcript:

1 SQL PATTERNS A NEW APPROACH FOR TEACHING SQL Karen Renaud Huda Al-Shuaily TLAD 2010 - BNCOD 2010 the 27th International Informationthe 27th International Information systems conferencesystems conference

2 Introduction Difficulty with applying fundamental SQL concepts and writing SQL queries is found to be a complex task Propose a new approach for teaching SQL by using SQL patterns which are based on a checklist approach

3 Content Learning SQL: Issues & Difficulties SQL Patterns: definition, structure, contribution Pilot Study: purpose, Result Current work & Future work

4 GORMAN’S TAXONOMY(2002) Why When How What SQL problem Patterns Solving SQL problem under problem- based learning (PBL) theory Learning Theories Fact Identification Idea Generation Knowledge Deficiencies Applying New Knowledge Abstract Knowledge Evaluation

5 SQL Learning issues Not having enough knowledge & skills to analyze SQL problems Exposing students to SQL problems where the concept is newly introduced and not yet mastered students can’t find the facts embedded within the SQL problem Students can’t generate ideas to solve it Novice SQL writers will not be aware of the deficiencies in their knowledge The time taken to find the required knowledge

6 Benefits of Patterns Help to identify the facts and generate ideas Provides the lacking knowledge in a convenient format. Help students to become familiar with common SQL problems and related solutions. Student’s knowledge and experience will be enhanced

7 Patterns Patterns originated in the field of building architecture. Christopher Alexander defined the patterns as “Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem (Alexander, 1977 as quoted by Gamma et al. 1995, p. 2) SQL Patterns: Each generic problem type, with its related facts, generated ideas and the required knowledge will be collected together to become a 'pattern’

8 Pattern section Definition Reference A unique number to link or refer different patterns NameA name that is easy to remember and track Keyword To summarize the content of the pattern ProblemSQL common problems Fact identification A checklist of the problem related facts will be presented here Idea generation The solution will be based on checklist approach where a number of scenarios will be listed and the learner will select the most appropriate. Knowledge required Many code structures will be presented. Each will match one or more scenario that was selected on previous section (solution) ExamplesSQL code and table snapshot SQL Patterns Structure

9 ProblemGather information from two tables. Fact identification [ ] Information is stored in more than one table [ ] The rows need to be filtered (OPTIONAL) [ ] The returned columns need to be filtered (OPTIONAL) Idea generation Need to link related rows in the two tables Need to filter only the rows that are required by the query Need to filter only the columns that are required by the query Knowledge required 1.Linking two tables is referred to as joining them. This is done by identifying a column in each table which is used as the link between them. In SQL, this is formulated as: WHERE table1.column_name = table2.column_name 2.We filter rows by using a conditional statement in the WHERE part of the query. E.g. WHERE gender=”Female” 3.We filter columns in the SELECT part of the query. E.g. SELECT Name Example 1

10 Example Get the Employee names, department names and salaries of employees whose salary between 500 and 1500. Facts: Information is stored in Employee and Department tables. Both Rows and Columns need to be filtered Ideas: Need to link the two tables using department_id Dept_IdDept_nameLoc_Id 10 Accounting 0011 20 HR 0013 30 IT 0101 40 Sale 0015 50 Shipping 0018 60 Marketing 1101 70 Services 1105 Emp_nameDept_nameSalary AliShipping1500 FayShipping1300 RossServices700 Emp_IdEmp_na me Dept_IdSalary 113 Ali50 1500 205 Fay50 1300 206 Ross70 700 101 Ahmed20 2000 100 King20 5000 SELECT e.Emp_name, d.Dept_name, e.Salary FROM Employee e, Department d WHERE e.Dept_Id = d.Dept_ID And Salary Between 500 and 1500;

11 Example 2 ProblemGather information from one table by multiple references to the same table. Fact identification [ ]All required Information is stored in one table [ ] you need to look more than one time to the same table. [ ] look in the table to find a certain information by looking at specific column and rows. [ ] look in the table again to look for other required information. Idea generation A self-join is simply a normal SQL join that joins one table to itself using table name aliases (ref) to give each "instance" of the table a separate name Knowledge required 1.Linking same tables to itself is referred to as self joining. This is done by identifying a column in each copy of the same table which is used as the link between them. In SQL, this is formulated as: WHERE table1.column_name = table1.column_name 2.We can use table aliases to cheat one table like a different table and then join them together. Eg. WHERE A.column_name = B.column_name 3.We filter rows by using a conditional statement in the WHERE part of the query. Eg. WHERE gender=”Female” 4.We filter columns in the SELECT part of the query. Eg. SELECT Name

12 Examplecreate a query that will return the names of the manager of each employee? Facts: Information is stored in Employee tables. Both Rows and Columns need to be filtered Ideas: Need to link the same tables to itself using employee id and manager id SELECT e.Emp_name, d.Manager_ID FROM Employee e, Employee a WHERE e.Emp_id = a.Emp_id Emp_IdEmp_nameManager ID 17Alinull 18Fay17 19Ross17 20Ahmed20 Emp_IdEmp_nameManager ID 17Alinull 18Fay17 19Ross17 20Ahmed20

13 Pilot study-purpose To focus on Developing skills in solving complex query Minimise effort (time, correctness, etc) taken by learner To highlight the users’ comprehension of the main advantages of using SQL patterns.

14 Question: Write an SQL statement to find all employees who earn more than the average salary in their department. Display Last name, Salary, Department Id and the Average salary for the department. Sort by Average salary Students provided with : Table description Pilot study - Problem

15 Students provided with four patterns: “Group Function” pattern “Grouping Rows” pattern “Sub Queries” pattern. “Querying from one table twice” pattern

16 Pilot study - Assessment The study results were analyzed in light of a pre task, post task questionnaire and participants solution. A pre-task questionnaire : provide insight on students level of knowledge and experience in SQL. A post-task questionnaire : feedback about using SQL patterns The participant’s solutions (with/without patterns) were analyzed as follows : skills in exploring the problem and identifying the related facts, the correctness of the SQL query, and the ability to match the given patterns to the given SQL problem.

17 Pilot study - findings Difficulties in exploring the problem and identifying the related facts Could not solve the problem without the given patterns Claimed that it was hard to remember how to solve the query Could not produce a 100% correct solution after giving them the patterns Questions average SQL patterns in general helped me to understand the given problem. 2.7 I was able to match the given patterns to the given SQL problem 3.7 SQL patterns helped me to recall the knowledge I need to solve the query 4 SQL patterns helped me to write the correct SQL syntax 3.7 SQL patterns helped me to explore the problem better and identify the related fact that was embedded. 3 SQL patterns helped me to solve the related problem faster. 4 SQL pattern helped me to discuss my solution with other. 3 SQL patterns are easy to understand 4.3 1 means strongly disagree 5 Means strongly agree & N=3

18 Common participant errors include missing the linkage clause from self-join table query not including the non-aggregated attributes in the GROUP BY clause although the given patterns included such information Pilot study - findings

19 We intend to embark on further research in order to Examine students’ attitudes towards learning SQL Finding the other related issues in learning SQL. Identifying the most difficult concepts in SQL Refining SQL patterns and obtaining more empirical evidence of their efficacy in learning SQL Finding a tool that supports learning SQL. Current and Future work

20 Issues with teaching and learning SQL Novice struggles with solving SQL queries Proposed SQL patterns as a solution to overcome some of the discussed issues. Presented a preliminarily study of using SQL patterns in solving SQL problem. Future research needed to investigate the contribution of SQL patterns in novice learning SQL. Summary

21 Any Questions?


Download ppt "SQL PATTERNS A NEW APPROACH FOR TEACHING SQL Karen Renaud Huda Al-Shuaily TLAD 2010 - BNCOD 2010 the 27th International Informationthe 27th International."

Similar presentations


Ads by Google