43. Operations
• projection: subset of available columns
• selection: subset of available rows
• cartesian product
• set union
• set intersection
• rename
44. Operations
• projection: subset of available columns
• selection: subset of available rows
• cartesian product
• set union
• set intersection
• rename
45. A Join
select * from foo, bar where foo.ipsum = bar.lorem
First you take the cartesian product....
foo: bat ipsum bar: cat lorem
me 5 X us 5
you 4 them 4
bat ipsum cat lorem
me 5 us 5
= me 5 them 4
you 4 us 5
you 4 them 4
46. A Join
select * from foo, bar where foo.ipsum = bar.lorem
Then you select the rows that satisfy the join condition:
bat ipsum cat lorem bat ipsum cat lorem
me 5 us 5 me 5 us 5
me 5 them 4 => you 4 them 4
you 4 us 5
you 4 them 4
47. A Join
select * from foo, bar where foo.ipsum = bar.lorem
First you take the cartesian product....
foo: bat ipsum bar: cat lorem
me 5 X us 5
you 4 them 4
bat ipsum cat lorem
me 5 us 5
= me 5 them 4
you 4 us 5
you 4 them 4
48. A Join
select * from foo, bar where foo.ipsum = bar.lorem
First you take the cartesian product....
foo: bat ipsum bar: cat lorem
me 5 X us 5
8,000,000
you 4 them 4
bat ipsum cat lorem
me 5 us 5
= me 5 them 4
you 4 us 5
you 4 them 4
49. A Join
select * from foo, bar where foo.ipsum = bar.lorem
First you take the cartesian product....
foo: bat ipsum bar: cat lorem
me 5 X us 5
8,000,000 100,000
you 4 them 4
bat ipsum cat lorem
me 5 us 5
= me 5 them 4
you 4 us 5
you 4 them 4
50. A Join
select * from foo, bar where foo.ipsum = bar.lorem
First you take the cartesian product....
foo: bat ipsum bar: cat lorem
me 5 X us 5
8,000,000 100,000
you 4 them 4
bat ipsum cat lorem
me 5 us 5
= me 5 them 4
800,000,000,000
you 4 us 5
you 4 them 4
56. What SQL Gets You
• Speed
(when data is highly structured and small enough)
57. What SQL Gets You
• Speed
(when data is highly structured and small enough)
• Aggregation
58. What SQL Gets You
• Speed
(when data is highly structured and small enough)
• Aggregation
• Relational searching
59. What SQL Gets You
• Speed
(when data is highly structured and small enough)
• Aggregation
• Relational searching
• ACID - guaranteed full consistency
63. What SQL Gets You
• Speed
(when data is highly structured and small enough)
64. What SQL Gets You
• Speed
(when data is highly structured and small enough)
• Aggregation
65. What SQL Gets You
• Speed
(when data is highly structured and small enough)
• Aggregation
• Relational searching
66. What SQL Gets You
• Speed
(when data is highly structured and small enough)
• Aggregation
• Relational searching
• ACID - guaranteed full consistency
79. ACID & BASE
• Atomicity • Basically Available
• Consistency
• Isolation
• Durability
80. ACID & BASE
• Atomicity • Basically Available
• Consistency • Soft state
• Isolation
• Durability
81. ACID & BASE
• Atomicity • Basically Available
• Consistency • Soft state
• Isolation • Eventually consistent
• Durability
82. Photo by Marcus Vegas (http://www.flickr.com/photos/vegas/413159909)
83. Fully ACID Fully BASE
Photo by Marcus Vegas (http://www.flickr.com/photos/vegas/413159909)
84. Fully ACID Fully BASE
Redis
Photo by Marcus Vegas (http://www.flickr.com/photos/vegas/413159909)
85. Fully ACID Fully BASE
CouchDB Redis
Photo by Marcus Vegas (http://www.flickr.com/photos/vegas/413159909)
86. Fully ACID Fully BASE
CouchDB Redis Bigtable
Photo by Marcus Vegas (http://www.flickr.com/photos/vegas/413159909)
87. Questions to ask about data
• Where can I compromise aggregation?
• Where can I compromise where clauses?
• Where can I compromise consistency?
Where can I localize consistency?
A table is called a “relation” in this model, and it’s defined by a list of column definitions. Each column definition specifies a unique column name and the type of the values that are permitted for that column. The body of the table is a set of rows, which are called tuples in the model. Each row is a set of key-value pairs, or tuple, consisting of the name of the column and the value of the data. Each tuple has to be unique in the table.
They transform tables into other tables. Another word for this is “query.”