csc 369 distributed computing
play

CSC 369: Distributed Computing Alex Dekhtyar April 20 Day 7: - PowerPoint PPT Presentation

CSC 369: Distributed Computing Alex Dekhtyar April 20 Day 7: MongoDB Aggregation Pipeline, Part II Housekeeping: plan for the week April 20 Grading: Lecture: joins Lab 1: not certain Lab: practice Lab 2: end of the week


  1. CSC 369: Distributed Computing Alex Dekhtyar April 20 Day 7: MongoDB Aggregation Pipeline, Part II

  2. Housekeeping: plan for the week April 20 Grading: ● Lecture: joins Lab 1: not certain ● Lab: practice Lab 2: end of the week ● Assignment: Lab 3 (Lab 3-2 by Tuesday) April 22 ● Lecture: catch-all on MongoDB, Mongo Python connectivity ● Lab: practice April 27 (Monday) ● Assignment: Lab 3 ● MongoDB test April 24 ● Flip lecture/lab ● Lecture: MongoDB quiz (?) ● Lab: practice ● Assignment: Lab 3 and Lab 4 (build a MongoDB-supported application)

  3. Recap of Last Week

  4. Data Manipulation operations Given a condition - keep only objects that satisfy it Filtering Modify the contents of its object based solely on Projection what’s in the object itself Transformation Break collection into groups, each representing objects with same values of some keys Grouping Compute an aggregate value over a set of objects Aggregation Combine objects from two different collections based on matches in values of some keys Join Return objects in a specific order Sort

  5. Data Manipulation Operations Opposite of grouping - build an object for each Ungrouping element of an array Unwinding Return a specific number of documents Limit Return documents after skipping a specified Skip number Return a random sample of documents Sample

  6. $operation Filtering $match Unwinding $unwind Projection $project $limit Limit Aggregation Skip $skip $group Grouping Sample $sample $sort Sort $lookup Join

  7. $operation $redact Filtering $match Projection $project $set $unset $addFields $replaceRoot Aggregation $bucket $group Grouping $bucketAuto $sort $sortByCount Sort $lookup $graphLookup Join

  8. $operation $redact Filtering $match Projection $project $set $unset $addFields $replaceRoot Aggregation $bucket $group Grouping $bucketAuto $sort $sortByCount Sort $lookup $graphLookup Join

  9. $operation $lookup Join $facet Faceted Filter $out $merge Output Control

  10. Joins Combine information from multiple data sources In Relational Algebra: cartesian product followed by selection

  11. Joins (Relational Algebra Example) Orders Products Order Product Price Product Name Rating 1234 1001 $4.99 1001 Hand Sanitizer 4.5 1234 2031 $20.00 1100 Gloves 4 3403 2031 $20.00 2031 Masks 3 3311 1100 $12.00 4011 Teddy Bear 5

  12. Joins (Relational Algebra Example) Orders Products Order Product Price Product Name Rating 1234 1001 $4.99 1001 Hand Sanitizer 4.5 1234 2031 $20.00 1100 Gloves 4 3403 2031 $20.00 2031 Masks 3 3311 1100 $12.00 4011 Teddy Bear 5 What product was purchased? “1001” is NOT a good answer

  13. Joins (Relational Algebra Example) Orders Products Order Product Price Product Name Rating 1234 1001 $4.99 1001 Hand Sanitizer 4.5 1234 2031 $20.00 1100 Gloves 4 3403 2031 $20.00 2031 Masks 3 3311 1100 $12.00 4011 Teddy Bear 5

  14. Joins (Relational Algebra Example) Orders Products Order Product Price Product Name Rating 1234 1001 $4.99 1001 Hand Sanitizer 4.5 1234 2031 $20.00 1100 Gloves 4 3403 2031 $20.00 2031 Masks 3 3311 1100 $12.00 4011 Teddy Bear 5

  15. Joins (Relational Algebra Example) Orders Products Order Product Price Product Name Rating 1234 1001 $4.99 1001 Hand Sanitizer 4.5 1234 2031 $20.00 1100 Gloves 4 3403 2031 $20.00 2031 Masks 3 3311 1100 $12.00 4011 Teddy Bear 5 Order Product Price Name Rating 1234 1001 $4.99 Hand Sainitizer 4.5 1234 2031 $20.00 Masks 3 3403 2031 $20.00 Masks 3 ... ... ... ... ...

  16. Joins (Relational Algebra Example) Orders Products Order Product Price Product Name Rating 1234 1001 $4.99 1001 Hand Sanitizer 4.5 1234 2031 $20.00 1100 Gloves 4 3403 2031 $20.00 2031 Masks 3 3311 1100 $12.00 4011 Teddy Bear 5 Order O.Product Price P.Product Name Rating 1234 1001 $4.99 1001 Hand Sanitizer 4.5 1234 1001 $4.99 1100 Gloves 4 1234 1001 $4.99 2031 Masks 3 1234 1001 $4.99 4011 Teddy Bear 5 1234 2031 $20.00 1001 Hand Sanitizer 4.5

  17. Joins (Relational Algebra Example) Orders Products Order Product Price Product Name Rating 1234 1001 $4.99 1001 Hand Sanitizer 4.5 1234 2031 $20.00 1100 Gloves 4 3403 2031 $20.00 2031 Masks 3 3311 1100 $12.00 4011 Teddy Bear 5 Order O.Product Price P.Product Name Rating 1234 1001 $4.99 1001 Hand Sanitizer 4.5 1234 1001 $4.99 1100 Gloves 4 1234 1001 $4.99 2031 Masks 3 1234 1001 $4.99 4011 Teddy Bear 5 1234 2031 $20.00 1001 Hand Sanitizer 4.5

  18. Joins (Relational Algebra Example) Orders Products Order Product Price Product Name Rating 1234 1001 $4.99 1001 Hand Sanitizer 4.5 1234 2031 $20.00 1100 Gloves 4 3403 2031 $20.00 2031 Masks 3 3311 1100 $12.00 4011 Teddy Bear 5 Order O.Product Price P.Product Name Rating 1234 1001 $4.99 1001 Hand Sanitizer 4.5 1234 1001 $4.99 1100 Gloves 4 1234 1001 $4.99 2031 Masks 3 1234 1001 $4.99 4011 Teddy Bear 5 1234 2031 $20.00 1001 Hand Sanitizer 4.5

  19. Joins (Relational Algebra Example) Orders Products Cartesian product Order Product Price Product Name Rating 1234 1001 $4.99 1001 Hand Sanitizer 4.5 Selection 1234 2031 $20.00 1100 Gloves 4 3403 2031 $20.00 2031 Masks 3 3311 1100 $12.00 4011 Teddy Bear 5 Order O.Product Price P.Product Name Rating 1234 1001 $4.99 1001 Hand Sanitizer 4.5 1234 1001 $4.99 1100 Gloves 4 1234 1001 $4.99 2031 Masks 3 1234 1001 $4.99 4011 Teddy Bear 5 1234 2031 $20.00 1001 Hand Sanitizer 4.5

  20. Joins (Relational Algebra Example) Orders Products Cartesian product Order Product Price Product Name Rating 1234 1001 $4.99 1001 Hand Sanitizer 4.5 Selection 1234 2031 $20.00 1100 Gloves 4 3403 2031 $20.00 2031 Masks 3 3311 1100 $12.00 4011 Teddy Bear 5 Order O.Product Price P.Product Name Rating 1234 1001 $4.99 1001 Hand Sanitizer 4.5 1234 1001 $4.99 1100 Gloves 4 1234 1001 $4.99 2031 Masks 3 1234 1001 $4.99 4011 Teddy Bear 5 1234 2031 $20.00 1001 Hand Sanitizer 4.5

  21. Joins (Relational Algebra Example) Orders Products Cartesian product Order Product Price Product Name Rating 1234 1001 $4.99 1001 Hand Sanitizer 4.5 Selection 1234 2031 $20.00 1100 Gloves 4 Projection 3403 2031 $20.00 2031 Masks 3 3311 1100 $12.00 4011 Teddy Bear 5 Order O.Product Price Name Rating 1234 1001 $4.99 Hand Sanitizer 4.5 1234 1001 $4.99 Gloves 4 ... ... ... ... ... 1234 1001 $4.99 Teddy Bear 5 1234 2031 $20.00 Hand Sanitizer 4.5

  22. Inner Joins vs Outer Joins Orders Products Order Product Price Product Name Rating 1234 1001 $4.99 1001 Hand Sanitizer 4.5 1234 2031 $20.00 1100 Gloves 4 3403 2031 $20.00 2031 Masks 3 3311 1100 $12.00 4011 Teddy Bear 5 Order Product Price Name Rating 1234 1001 $4.99 Hand Sanitizer 4.5 1234 2031 $20.00 Masks 3 For each product ordered report the name of the product and the rating. 3403 2031 $20.00 Masks 3 ... ... ... ... ...

  23. Inner Joins vs Outer Joins Orders Products For each product, report the details of all orders. Order Product Price Product Name Rating 1234 1001 $4.99 1001 Hand Sanitizer 4.5 1234 2031 $20.00 1100 Gloves 4 3403 2031 $20.00 2031 Masks 3 3311 1100 $12.00 4011 Teddy Bear 5 Order Price Product Name Rating 1234 $4.99 1001 Hand Sanitizer 4.5 3311 $12.00 1100 Gloves 4 1234 $20.00 2031 Masks 3 3403 $20.00 2031 Masks 3

  24. Inner Joins vs Outer Joins Orders Products For each product, report the details of all orders. Order Product Price Product Name Rating 1234 1001 $4.99 1001 Hand Sanitizer 4.5 1234 2031 $20.00 1100 Gloves 4 3403 2031 $20.00 2031 Masks 3 3311 1100 $12.00 4011 Teddy Bear 5 Order Price Product Name Rating 1234 $4.99 1001 Hand Sanitizer 4.5 3311 $12.00 1100 Gloves 4 1234 $20.00 2031 Masks 3 3403 $20.00 2031 Masks 3

  25. Inner Joins vs Outer Joins Orders Products For each product, report the details of all orders. Order Product Price Product Name Rating Keep all products in output 1234 1001 $4.99 1001 Hand Sanitizer 4.5 1234 2031 $20.00 1100 Gloves 4 Right outer join 3403 2031 $20.00 2031 Masks 3 3311 1100 $12.00 4011 Teddy Bear 5 Order Price Product Name Rating 1234 $4.99 1001 Hand Sanitizer 4.5 3311 $12.00 1100 Gloves 4 1234 $20.00 2031 Masks 3 3403 $20.00 2031 Masks 3 NULL NULL 4011 Teddy Bear 5

  26. Joins in MongoDB {$lookup: { from: <collection>, localField: <field>, foreignField: <field>, as: <arrayField> } }

  27. Joins in MongoDB {$lookup: { from: <collection>, localField: <field>, foreignField: <field>, as: <arrayField> } } Left outer join

  28. Joins in MongoDB Left outer join {$lookup: { from: <collection>, localField: <field>, foreignField: <field>, as: <arrayField> } } Join condition: localField == collection.foreignField

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend