O'Reilly logo

Lift Application Development Cookbook by Gilberto T. Garcia Jr.

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating many-to-many relationships

So far, we have learned how to map a table using Record and Squeryl; we've also learned how to create a one-to-many relationship. We will now learn how to create a many-to-many relationship using Record and Squeryl.

Getting ready

You can use any of the projects that we have created in this chapter, or you can start a new one; do whatever fits you best.

Create the following tables:

create table courses (
  id serial primary key,
  name varchar(100)
);

create table students (
  id serial primary key,
  name varchar(100)
);

create table courses_students (
  id serial primary key,
  course bigint,
  student bigint
);

How to do it...

  1. Create a class called Student in the model package, as follows:
    package code.model import net.liftweb.record.{MetaRecord, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required