13
RagnarDB SQL KAI LU AND PATRICK JENNINGS

MidtermDemo

  • Upload
    kai-lu

  • View
    95

  • Download
    1

Embed Size (px)

Citation preview

Page 1: MidtermDemo

RagnarDB SQLKAI LU AND PATRICK JENNINGS

Page 2: MidtermDemo

Project Goals Create an Object Oriented SQL Querying plugin in Gosu

Interpret Data Definition Files Create Types based on these descriptions Add Object Oriented Functionality to these types Add support similar to that in more common languages Compare to Java Object Oriented Querying Library (jOOQ)

Page 3: MidtermDemo

Parsing Recursive descent parsing Top Down Approach Testing for correctness via ANTLR Lexing code into Tokens

Page 4: MidtermDemo

Parsing

DDL CreateTable

ColumnDefinition

Constraint

Extracting data we care about A DDL File contains many tables Tables contain many Column Definitions and many Constraints

Page 5: MidtermDemo

Type system Metaprogramming

Information from the parser is loaded into the Gosu Typeloader at Compile time

Types for each table are created Methods related to tables can also be invoked statically We use this to support custom query building

Page 6: MidtermDemo

Query Construction

At this point, our new classes still don’t do much So we added support for construction of SQL queries Queries can be called off of constructed types statically

Insert instances of types into database SQLConstraint Class describes clauses in SQL statements

Page 7: MidtermDemo

Query Functionality Select Statements

Specify Rows returned Join Statements, On statements

Recursive Support for multiple Joins Where Statements

Is In Constraints SQL SubQueries

Is Equal to / Greater, Less than, etc Is Like Boolean Logic For multiple constraints

Order By Limit Clauses

Page 8: MidtermDemo

Fine-grain control for complex queries

SELECT name, phone, email, address FROM customers AS contactInfo WHERE country = ‘US’;

WITH RECURSIVE destinations(city, country) AS ( SELECT city, country FROM connections WHERE start = ‘Foster City’ UNION ALL SELECT city, country FROM connections WHERE start = city)SELECT * FROM destinations

SELECT game FROM ign WHERE rating > (SELECT rating FROM ign WHERE game = ‘Tales Of Symphonia’)

Page 9: MidtermDemo

SQL Files are now Gosu Types

PresentationQuery1.sql: SELECT * FROM Contacts WHERE Name = ‘Kai Lu’;->var kais = MyQuery.execute()

for(kai in kais){ print(kai.Name) }->Kai Lu

ID Name Email Age1 Patrick Jennings pjennings 192 Kai Lu klu 193 Luca Boasso lboasso ??4 Kyle Moore kmoore ??

Contacts

Page 10: MidtermDemo

Query Execution:

Page 11: MidtermDemo

Parameterization

@variableName:variableType exposes a parameter of type variableType, called variableName to the plugin

Page 12: MidtermDemo

Applications

Page 13: MidtermDemo

Moving Forward

Full Set of Data Types (arrays, date/time, XML) Transactions and multiple queries Connection management Cache management Error Handling Resolving the N+1 queries problem