In type systems, is there a name for SQL's way of cutting and combining record types into new types?
-
30-10-2019 - |
Question
I'd like to have this feature in my application programming language (which these days, is Scala), but when I went to learn more about it on the internets, I realized I don't know the name of it. I'm talking about the ability to do this (in Scala-ish pseudocode):
// Define some types that correspond to table rows in relational DB
class User
val id: Int
val name: String
val email: String
val created: DateTime
class Comment
val id: Int
val text: String
val userId: Int
val created: DateTime
// Call a select/join query function
val list = select c.id, c.text, u.name
from comments c join user u on c.userId = u.id ...
And then list
gets a type of something like List[R]
where R
is an unnamed record type with properties id
, text
, name
, or maybe c.id
,c.text
,u.name
.
Some languages, like Scala, support you writing that select function so it returns a tuple type (Int, String, String)
, but not a type with named fields.
Is there a name for that?
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with cs.stackexchange