Objects vs tables
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
name the four ways objects and tables do not fit together.
Planned topics
- This gap is called the object-relational impedance mismatch.
- Identity: Java has
==andequals; tables have a primary key. - Inheritance: objects have subclasses; tables have no such thing, so you choose a layout.
- Associations: objects hold references (and can point both ways); tables use foreign keys (one direction, many-to-many needs a join table).
- Granularity: one object may hold nested value objects (
Money), while a table row is flat.
Draft outline details
Demonstration
a drawing of Order with a List<OrderLine> next to the tables orders and order_line with a foreign key.
Check your understanding
Which mismatch is shown by a Money object stored in two columns?
Show answer
Granularity.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.