/avatar.jpg

CS186-L15: DB Design: Entity-Relationship Models

Overview how to design a database instead of DBMS! 🤔 this class mainly focuses on the conceptual design Data Models and Relational Levels of Abstraction def in Data model abstractions example Data Independence Entity-Relationship Model (ERM) Def Entity: a real-world object that can be described and identified by a set of attributes Entity Set: a collection of similar entities all entities in an entity set have the same attributes each entity set has a key each attribute has a domain Relationship: a connection between two entity sets Key and Participation Constraints Key Constraints Participation Constraints Weak Entity Alternative Notation and Terminology decoder graph 😅 math notation 😅 Binary vs Ternary Relationships 上面的更加紧密并且可以记录qty

CS186-L10: Iterators & Joins

Intro relational operator: tuples(in other way, relations) in, tuples out 1 2 3 4 5 6 7 abstract class Iterator { // set up the children and the dataflow graph void setup(List<Iterator> inputs); void init(args); // state tuple next(); // returns the next tuple void close(); } presudo code select on the fly 🤔 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 init() { child.

CS186-L11: Query Opt: Plan Space

Intro ??? I am here right now 😄 省流:拿进来sql,转换成relational algebra,然后树形图展示,考虑不同的实现方式,然后给出优化方案。 考虑不同的实现方式 plan space: how many plans? cost estimation search strategy algebra equivalences selections, projections and Cartesian products 在数据库查询的关系代数中,projections(投影) 是一种操作,它用于从一个关系中选择特定的属性列。我们来看一下投影的性质以及如何理解它。投影(Projections)的性质表明了它们可以被 级联(cascade) 使用。这意味着多个投影操作可以逐步应用于关系 R 上,每一步选择一个或多个属性列: [ \pi_{a_1}(R) \equiv \pi_{a_1}(…(\pi_{a_1, …, a_{n-1}}(R))…) ] 级联(Cascade) 级联的含义是指多个投影操作可以按顺序应用。在级联的情况下,我们可以将多个投影操作结合起来,依次减少关系的属性。 例如,假设我们有一个关系 R,它有属性集合 {a_1, a_2, a_3, a_4}。如果我们应用 (\pi_{a_1, a_2}(R)),我们得到的结果是仅有 a_1 和 a_2 属性的关系。 接着,我们可以在这个结果上再次应用 (\pi_{a_1}(R)),最终得到只有 a_1 属性的关系。 这种级联性质可以被理解为将多个投影操作合并成一个操作。 joins 结合律?交换律? 结合律一般不成立,交换律是成立的(由前面的Cartesian product可知)。有一个理解点:叉积 $\times$ 的范围变大了 Some Heuristics selections selection is cheap, while join is expensive 😋