Main Menu
Lecture 1
Lecture 2
Lecture 3
Lecture 4
Lecture 6
Lecture 7
 

 

 

Relationships

Table is modelled as an entity

One or more columns in table are primary keys - the value stored in these columns uniquely identifies the row

Primary keys can be any data type - usually integers

Foreign keys - a column whose values correspond to values in the primary key of another table

When foreign key values of a row correspond to the primary ke values of a row in a different table we have a relationship between the rows

to-one relationship - one row corresponds to at most one row

to-many relationship - one row corresponds to many rows

To find the rows in another table related to the chosen row you must do a database join operation

Entity is represented as a class

Most variables of class contain simple data types

Some variables contain references to other EOs or to arrays of EOs

These variables represent to-one and to-many relationships

They correspond to foreign keys in the database tables

EOF performs the joins automatically to determine the references to objects to store in the variables

Reflective relationships

When the foreign key columns of a table contain values that appear in the primary key columns of the same table

The class will contain an instance variable that refers to objects (or an array of objects) of the same class