Add initial implementation for subresource learning.

SQL boilerplate ahoy!