An Introduction to Class::DBI - Table Relationships 29

Multi Table Relationships

Many to Many

  • In our schema, a Person has many Films, and a Film has many Persons

  • The Credits table joins the Film and Person tables

        CREATE TABLE person (              CREATE TABLE credit (
            id    INTEGER PRIMARY KEY,         id         INTEGER PRIMARY KEY,
            name  VARCHAR(255),                type       VARCHAR(255),
            birthdate INTEGER                  person_id  INTEGER,
        );                                     film_id    INTEGER
        CREATE TABLE film (
            id    INTEGER PRIMARY KEY,
            title VARCHAR(255),
            year  INTEGER


YAPC::Canada << Previous | Index | Next >>
Copyright © 2003 Michael Graham