title: Describing optional fields in Slick
body: <p>The Slick DSL allows two ways to create optional fields in tables.</p>
  
  <p>For this case class:</p>
  
  <pre><code>case class User(id: Option[Long] = None, fname: String, lname: String)
  </code></pre>
  
  <p>You can create a table mapping in one of the following ways:</p>
  
  <pre><code>object Users extends Table[User]("USERS") {
      def id = column[Int]("id", O.PrimaryKey, O.AutoInc)
      def fname = column[String]("FNAME")
      def lname = column[String]("LNAME")
      def * = id.? ~ fname ~ lname &lt;&gt; (User, User.unapply _)
    }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>  object Users extends Table[User]("USERS") {
      def id = column[Option[Long]]("id", O.PrimaryKey, O.AutoInc)
      def fname = column[String]("FNAME")
      def lname = column[String]("LNAME")
      def * = id ~ fname ~ lname &lt;&gt; (User, User.unapply _)
    }
  }
  </code></pre>
  
  <p>What is the difference between the two? Is the one the <em>old way</em> and the other the <em>new way</em>, or do they serve different purposes?</p>
  
  <p>I prefer the second choice where you define the identity as optional as part of the id definition because it's more consistent.</p>