Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examine function-derived attributes #247

Open
agentm opened this issue Jul 23, 2019 · 3 comments
Open

examine function-derived attributes #247

agentm opened this issue Jul 23, 2019 · 3 comments

Comments

@agentm
Copy link
Owner

agentm commented Jul 23, 2019

I wonder if SQL-style views could be superseded by function-based attributes. I imagine the function signature would look something like this:

f :: RelationTuple -> Atom

where the tuple is the current tuple context to be used for deriving new attributes. This could also be used with grouping for

This would allow derived columns to be conveniently attached to relations without incurring a storage cost.

I need to investigate if such a feature would break any of the laws involving data independence or constraints.

@YuMingLiao
Copy link
Contributor

it seems to me that function-derived attributes can be safely referred to in a relational expression.

However, if it is allowed in insert and upsert, it implies that the attribute can be function-derived OR user-defined and then make unexpected result. So the function-derived attribute name needs to be disallowed in insert/update/upsert and the value needs to be derived automatically when insert/update/upsert.

As to constraints, the constraints on the left (RelationTuple) seems only shrink the deriving function's input set.

And the constraint on the right (Atom) may conflict with the deriving function's output set. It needs to be reflected on the insert/update/upsert error.

@agentm
Copy link
Owner Author

agentm commented May 21, 2020

Interesting points. Does this imply that the function-derived column should be of a different type despite generating standard values?

@YuMingLiao
Copy link
Contributor

On second thought...

Tuple function is like atom function. It can be used in relational expression to extend an column.

And we want data independence.

So maybe we can define a macro like someView = s : { viewAttribute :=f #s }

It doesn't take space. It just need to be a valid expression.

Then it can be used later in something like showexpr someView.

And it's not allowed to insert/update/upsert macros by nature because it's not a relvar.

And if the column value needs to be constrained, it can be done by giving the right function.

So the column need not to be of different type. It just need to be defined in macros in order to avoid change.

When the function-derived column is defined in a relvar assignment, it implies that the tuple function is used for initialization. Values may be changed by the user. And the user doesn't care about the consistency that the tuple function brings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants