190 likes | 311 Views
SQL. Seminar Programmiersprachen – FG Praktische Informatik Pablo Pinés León . Introduction . SQL is a language for managing data in RDBMS SQL stands for Structured Query Language Originally called SEQUEL
E N D
SQL SeminarProgrammiersprachen – FG PraktischeInformatik Pablo Pinés León
Introduction • SQL is a language for managing data in RDBMS • SQL stands forStructuredQuery Language • Originallycalled SEQUEL • Basedon Edgar Codd’sRelational Model, whichhadattracted a lot of attention at that time • Currentlywidelyused • First experimental implementation: System R, by IBM • Firstcommercialimplementation: Oracle
Initial objectives of design • Language based on common english, easy to write, based in tables • Procedural, but avoiding some mathematical concepts • High level querying concepts, as grouping
Initial objectives of design • More functionality: data management not relying solely on database administrators • It should serve both as query language and as a development language • Unique opportunity: free from backward compatibility
Evolution of System R • Name changed • New facilities: Join, having • Null values, three-value logic • New predicates: Like • Pragmatic decisions
Subsets • DML - Data Manipulation Language • Insert, Merge, etc • Transactions • DDL – Data Definition Language • Create, Drop, etc
99 bottles of beer SELECT CASE (bottlecount) WHEN 0 THEN 'No more bottle of beer on the wall, no more bottles of beer. ' || 'Go to the store and buy some more, 99 bottles of beer on the wall.' WHEN 1 THEN '1 bottle of beer on the wall, 1 bottle of beer. ' || 'Take one down and pass it around, no more bottles of beer on the wall.' WHEN 2 THEN '2 bottles of beer on the wall, 2 bottles of beer. ' || 'Take one down and pass it around, 1 bottle of beer on the wall.' ELSE rtrim (cast((BottleCount) as char(2))) || ' bottles of beer on the wall, ' || rtrim (cast((BottleCount) as char(2))) || ' bottles of beer. ' || 'Take one down and pass it around, ' || rtrim (cast((BottleCount)-1 as char(2))) || ' bottles of beer on the wall.' END FROM ( SELECT avalue * 10 + bvalue as bottlecount FROM (VALUES (9), (8), (7), (6), (5), (4), (3), (2), (1), (0)) a(avalue), (VALUES (9), (8), (7), (6), (5), (4), (3), (2), (1), (0)) b(bvalue) ) as valuelist;
Don Chamberlin • Born in 1944 in San José, USA • M.Sc and PhD in electrical engineering by Stanford University. Minored in computer science • Worked for IBM Research, last years in Almaden • XQuery • He was awarded by the ACM in 1988
Ray Boyce • Born in 1947 in New York • PhD in Computer Science at Purdue • Worked in Yorktown Heights for IBM => Boyce-Codd Normal Form • He moved to San Jose to work with Don Chamberlain • Died of brain aneurysm in 1974
Basis • Important for any language: Well defined data model (though you can retrofit it later) • SQL is declarative: • Optimizability • Data independence • High level is easier “There was significant uncertainty about whether a declarative language as complex as SQL could be implemented with the degree of performance required for commercial applications”
Concurrency in shared data • Consistency is a must • Definition of ACID properties for transactions (atomicity, consistency, isolation, durability) • Degrees of isolation (thehigherthe isolation is, thebiggerportionitmightlock up) • Sidenote: halloweenproblem
Design principles • Not all of them were well observed in SQL • Closure • Completeness • Orthogonality: concepts defined independently and avoiding special rules • A expression that returns a certain type should be allows to be used in any context where that data type is expected • Consistency “I think the history of SQL illustrates the importance of having a specific set of principles that guide the process of language design”
Design principles • Simplicity • Extensibility • Abstraction (data independence in DB) • Optimizability: where possible, the semantic specification should be declarative • Resilience
Reasons for its sucess • Database administration tasks • Quite easy to learn • Various implementations • Interfaces with popular programming languages • ANSI and ISO standards • Propitious time “I think that the main reason for the popularity of SQL derives from the power and simplicity of Ted Codd’s relational data model”
Unexpected evolution • SQL injection attacks • Now it’s an object-relational language • User-defined types and methods • They expected “casual users” to use it