Introductie tot MongoDB

Introductie tot MongoDB in Python

Filip Schouwenaars

Machine Learning Researcher

Data is overal!

data overal.jpg

Introductie tot MongoDB in Python

Voorbeeld: student-cursusdata

student_id name course_code title
1 Amina CS101 Intro to Coding
1 Amina MATH201 Algebra Basics
2 Luca CS101 Intro to Coding
Introductie tot MongoDB in Python

Data opslaan

Studenten

student_id name
1 Amina
2 Luca
Introductie tot MongoDB in Python

Data opslaan

Studenten

student_id name
1 Amina
2 Luca

Cursussen

course_code title
CS101 Intro to Coding
MATH201 Algebra Basics
Introductie tot MongoDB in Python

Data opslaan

Studenten

student_id name
1 Amina
2 Luca

Inschrijvingen

student_id course_code
1 CS101
1 MATH201
2 CS101

Cursussen

course_code title
CS101 Intro to Coding
MATH201 Algebra Basics

Relationeel model

  • Gebruikt door relationele databases
  • Voorbeelden: MySQL, PostgreSQL
Introductie tot MongoDB in Python

Wanneer relationele databases tekortschieten

 

  • Geweldig voor gestructureerde, consistente data
  • Maar hoe zit het met complexe, variabele data?
  • Extra details vragen om meer tabellen
  • Wordt lastiger te beheren naarmate het groeit

schematisch

Introductie tot MongoDB in Python

Maak kennis met MongoDB

 

  • Documentgebaseerd, niet tabelgebaseerd
  • Flexibel: elk record kan anders zijn
  • Geen strikt schema nodig
  • Genest, gestructureerde data makkelijk opslaan

Introductie tot MongoDB in Python

BSON, een speciaal soort JSON

 

  • BSON = Binaire JSON
  • Lijkt erop, maar sneller en efficiënter
  • Extra datatypes zoals Date en Binary
  • MongoDB gebruikt BSON onder de motorkap

Introductie tot MongoDB in Python

Verbinden met MongoDB

from pymongo import MongoClient

# Create client (localhost) client = MongoClient()
# Create client (remote server) client2 = MongoClient("mongodb+srv://usr:[email protected]")
Introductie tot MongoDB in Python

Laten we oefenen!

Introductie tot MongoDB in Python

Preparing Video For Download...