Sunday, 15 January 2012

Relational algebra equivalent of SQL "in" -



Relational algebra equivalent of SQL "in" -

what equivalent relational algebra of look in sql? i'm trying translate sql query:

select rol, nota notas rol in ( select rol estudiantes id = 1)

if talking inner subquery below

select rol estudiantes id = 1

equivalent relational algebra below

∏rol(σ id = 1 (estudiantes))

σ id = 1 (estudiantes) select rows status id = 1 out of projecting subset of column namely rol.

edit:

if want simulate in operator can go equi join on both notas , estudiantes table on column named rol.

select rol, nota notas rol in ( select rol estudiantes id = 1 )

point note: explicitly qualify rol column since both relation has same name.

nota (equi join) estudiantes = project notas.rol,nota (notas equijoin notas.rol = estudiantes.rol select id = 1(estudiantes))

ps: somehow, not able print symbols (project,select,equi bring together etc). ended writing them text.

sql relational-algebra

No comments:

Post a Comment