1;</pre>
<div class="slide">
- <h1>relationships</h1>
+ <h1>Relationships</h1>
</div>
<div class="slide">
- <h1>multiple authors</h1>
+ <h1>Multiple Authors</h1>
</div>
<div class="slide">
<h1>a few relationships</h1>
+ (really need picture here)
(authors -- author_link_to_book -- books)
</div>
<div class="slide">
- <h1>a few relationships</h1>
- !
- </div>
-
- <div class="slide">
- <h1>new join table</h1>
+ <h1>Join Table</h1>
<pre>CREATE TABLE author_and_books(
- id int(8) primary key auto_increment,
- book int(8),
- author int(8),
- foreign key (book) references books(id),
- foreign key (author) references authors(id)
+ book_id int(8),
+ author_id int(8),
+ foreign key (book_id) references books(id),
+ foreign key (author_id) references authors(id)
) engine = InnoDB DEFAULT CHARSET=utf8;
-ALTER TABLE `books` DROP `author`</pre>
- </div>
-
- <div class="slide">
- <h1>new join table</h1>
-<pre>CREATE TABLE author_and_books(
- id int(8) primary key auto_increment,
- book int(8),
- author int(8),
- <strong>foreign key (book) references books(id),
- foreign key (author) references authors(id)</strong>
-) engine = InnoDB DEFAULT CHARSET=utf8;
-
-ALTER TABLE `books` DROP `author`</pre>
+ALTER TABLE `books` DROP `author`;</pre>
</div>
<div class="slide">
<div class="slide">
<h1>has_many</h1>
-<pre>package Foo::Schema::<strong>Result::Books</strong>;
+<pre>package Foo::Schema::<strong>Result::Book</strong>;
-__PACKAGE__->has_many( author_and_books => "Foo::Schema::Result::AuthorAndBooks",
- { "foreign.book" => "self.id" },
+__PACKAGE__->has_many( author_and_books =>
+ 'Foo::Schema::Result::Author_Book', 'book_id'
);
-
-<strong># This is auto generated by Schema::Loader</strong></pre>
- </div>
-
- <div class="slide">
- <h1>has_many</h1>
-<pre>package Foo::Schema::<strong>Result::Books</strong>;
-
-__PACKAGE__->has_many(
-author_and_books => <strong># name of accessor</strong>
-"Foo::Schema::Result::AuthorAndBooks", <strong># related class</strong>
- { "foreign.book" => "self.id" } <strong># Relationship (magic often works if not
- # specified, but avoid!)</strong>
-);
-</pre>
</div>
<div class="slide">
<div class="slide">
<h1>belongs_to</h1>
-<pre>package Foo::Schema::<strong>Result::AuthorAndBooks</strong>;
+<pre>package Foo::Schema::<strong>Result::Author_Book</strong>;
__PACKAGE__->belongs_to(
- book => <strong># Accessor name</strong>
- "Foo::Schema::Result::Books", <strong># Related class</strong>
- { id => "book" } <strong># relationship</strong>
+ book =>
+ 'Foo::Schema::Result::Book', 'book_id'
);
</pre>
</div>
</div>
<div class="slide">
- <h1>with no coding...</h1>
- </div>
-
- <div class="slide">
<h1>many_to_many</h1>
</div>
use base 'DBIx::Class::Core';
__PACKAGE__->many_to_many(
- authors => "author_and_books", 'author'
+ authors => 'author_and_books', 'author'
);
1;
-
-<strong> # This is <em>NOT</em> auto generated by Schema::Loader </strong></pre>
+</pre>
</div>
<div class="slide">
);
1;
-
-<strong># This is <em>NOT</em> auto generated by Schema::Loader</strong></pre>
+</pre>
</div>
<div class="slide">