Object Relational Mapping
Object Relational Mapping (ORM) allows software developers to work with the contents of a database in their programs using object oriented methods vs writing SQL. Django provides an ORM that allows you easily work with a database using application models. You should take the time to understand the principles behind ORM and then learn to use the ORM effectively in your own projects by creating models to match your use cases as well as using the ORM functionality to store and retrieve data in your application.
Goals/Objectives/Outcomes
- Understand the principles behind Object Relational Mapping and how they are applied in Django
- Understand how to create models using fields, relationships and meta options and model methods
- Understand how to make One-to-Many and Many-to-Many relationships and how to work with related objects
- Understand how to use model inheritance and abstract base classes
- Understand how to make queries using the database-abstraction API to create, retrieve, update and delete objects
- Understand the basics of how QuerySets are evaluated
- Understand how to use Aggregation Functions
- Understand how to use the GeoDjango spatial ORM
- Understand how to use Class Managers
- Understand how to fall back to raw SQL if necessary
- Understand how database transactions work in Django
Reference Material
- https://en.wikipedia.org/wiki/Object-relational_mapping
- https://docs.djangoproject.com/en/1.8/topics/db/
- http://www.effectivedjango.com/orm.html
- http://www.djangobook.com/en/2.0/chapter05.html
- http://tutorial.djangogirls.org/en/django_orm/index.html
- http://www.dabapps.com/blog/higher-level-query-api-django-orm/
Measures of Success
- Participant can articulate the basic concepts behind ORM and how they are used in django
- Participant has created a set of models to match their use case using relationships
- Participant has demonstrated the use of the Django apis for working with objects from a database
- Participant has demonstrated the use of the GeoDjango spatial ORM with a model containing Geometry fields
- Participant has demonstrated the use or knowledge of aggregation functions and class managers