An algebra for nested relations