Defining tables

Report a typo

Choose the right ways to define the following table.

books table with int id field and four other fields

1:

object Book : Table() {
    val id: Column<Int> = integer("id").autoIncrement()
    val name: Column<String> = varchar("name", 50)
    val author: Column<String> = varchar("author", 50)
    val publicationYear: Column<Int> = integer("publication_year")
    val soldNumber: Column<Int> = integer("sold_number")

    override val primaryKey = PrimaryKey(id)
}

2:

object Book : Table() {
    val name: Column<String> = varchar("name", 50)
    val author: Column<String> = varchar("author", 50)
    val publicationYear: Column<Int> = integer("publication_year")
    val soldNumber: Column<Int> = integer("sold_number")
}

3:

object Book : IntIdTable() {
    val name: Column<String> = varchar("name", 50)
    val author: Column<String> = varchar("author", 50)
    val soldNumber: Column<Int> = integer("sold_number")
}

4:

object Book : IntIdTable() {
    val name: Column<String> = varchar("name", 50)
    val author: Column<String> = varchar("author", 50)
    val publicationYear: Column<Int> = integer("publication_year")
    val soldNumber: Column<Int> = integer("sold_number")
}
Select one or more options from the list
___

Create a free account to access the full topic