CSC 104 Tutorial Notes Bowen Hui August 03rd 2005 General Questions ================= - open questions AI and Machine Learning ======================= 1. Assume that an interface agent observes actions made by a user and creates (learns) rules, which can be used in the future to assist the user. The agent has currently learned the following rule: IF (user selects menu X) AND (X contains option "Print") THEN (user selects option "Print") - why/when is this rule useful? - creating shortcuts - predicting user actions, help completion, etc. - shortening the menu bars by using ">>" Imagine now that at some point the user selects a menu "File" (user selects menu "File"), which contains the option "Print" ("File" contains "Print"), but the user finally selects the option "Save" (user selects option "Save"). - what happens? - it seems that the system has arrived at a contradiction - is the original rule still valid? - yes, because there might be cases of X->Print still to occur - how does this example highlight why computers do the wrong thing? - pre-programmed rules are too rigid - pre-programmed rules need to be modified - not all possible cases can be pre-programmed - how might the system accomodate this new experience? - ignore new experience - add a new rule like this: IF (user selects menu X) AND (X contains option "Save") THEN (user selects option "Save") but this is now ambiguous -- after the user selects menu "File", does the user want to save? or print? if this is the solution, it needs some additional resolution mechanism - add more context into the original rule: IF (user selects menu X) AND (X contains option "Print") AND (document is unmodified) THEN (user selects option "Print") Databases ========= Assume that a CD store maintains a relational database that stores information about CDs, customers and CD purchases. The database contains the following tables: Customer(CID, Name, Age, Address, ) CD (CDNumber, Title, Artist, Price) Purchase(CID, CDNumber, Date) - what is a primary key? primary key = unique identification per record (row in table) - one attribute or a set of attributes - what is the primary key in each of the tables? - customer: CID - cd: CDNumber - purchase: concat(CID,CDNumber) both must be used - what does the following SQL query return? SELECT Customer.Name FROM Customer, Purchase WHERE Customer.CID = Purchase.CID AND Purchase.Date = "05/08/2005" "show me the customer's name who purchased a CD on august 05th 2005" - why does it have to be "FROM Customer, Purchase", and not just "FROM Purchase"? - because the .Name field is only available in the customer's table, yet we have a constraint on the date of purchase Recall that the WHERE part of the SQL query contains a condition (Boolean expression). Aside: the syntax used in JavaScript is not the same as that of SQL. JavaScript: BoolExp SQL: BoolExp Meaning condition constraint var_x == var_y var_x = var_y BoolExp && BoolExp BoolExp AND BoolExp BoolExp || BoolExp BoolExp OR BoolExp - write the following in SQL: "get all the CD titles whose price is either greater than $30 or less than $10" step 1. write down all 3 parts SELECT FROM WHERE step 2. decide if info pertains to 1 table, or more. all info can be found in: CD (CDNumber, Title, Artist, Price) SELECT FROM CD WHERE step 3. fill in which attribute to SELECT in table SELECT Title FROM CD WHERE step 4. identify constraints on attribute SELECT Title FROM CD WHERE Price ... OR Price ... step 5. final query SELECT Title FROM CD WHERE Price > 30 OR Price < 10