You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For many-to-many relations, the creation of bridging tables is often necessary. In some cases, these relations may require some extra data. To use the wiki example:
// create filmval film = transaction {
StarWarsFilm.new {
name ="The Last Jedi"
sequelId =8
director ="Rian Johnson"
}
}
//create actorval actor = transaction {
Actor.new {
firstname ="Daisy"
lastname ="Ridley"
}
}
//add reference
transaction {
film.actors =SizedCollection(listOf(actor))
}
Suppose one were to add extra information to this relation, such as the role played, then the current solution would be to have a Role-like entity, referencing the film and actor, and containing the extra data. Now you have a problem referencing Actor using the via keyword. Wouldn't the following approach be preferable? Why is this not possible?
// The StarWarsFilmActors table now contains a role fieldobject StarWarsFilmActors : Table() {
val starWarsFilm = reference("starWarsFilm", StarWarsFilms).primaryKey(0)
val actor = reference("actor", Actors).primaryKey(1)
val roleName = varchar("50")
}
For many-to-many relations, the creation of bridging tables is often necessary. In some cases, these relations may require some extra data. To use the wiki example:
Suppose one were to add extra information to this relation, such as the role played, then the current solution would be to have a
Role
-like entity, referencing the film and actor, and containing the extra data. Now you have a problem referencingActor
using thevia
keyword. Wouldn't the following approach be preferable? Why is this not possible?The text was updated successfully, but these errors were encountered: