Consider the following `(1:N)` relationship:

`[entity: user] <------ rid key ------> [entity: rid]`.

consider the data in both tables as:

```
select * from user;
user-id        rid-key
a-basa         a
b-basa         b
a.a-basa       a.a   
a.b-basa       a.b
a.a.a-basa     a.a.a
a.a.b-basa     a.a.b
a.b.a-basa     a.b.a
a.b.b-basa     a.b.b
a.b.b.a-basa   a.b.b.a
a.b.b.b-basa   a.b.b.b

select * from rid;

rid-key    parent-rid    enabled
a            null        true
b            null        true
a.a          a           true 
a.b          a           false
a.a.a        a.a         true
a.b.a        a.b         true
a.b.b        a.b         true
a.b.b.a      a.b.b       true
......
n rows

```

I need to design a single query (not stored procedure) which will input a `user-id`, and the following facts are considered:

If an user is given access to a `rid`, then it can also access the `parent rid` of the `rid` given - the `rid` itself is enabled `(enabled = true).`

This should continue till we reach the `root rid`, ie. `parent rid` property is `null`.

In above example, the list of accessible rid for the user `'a.b.b.a-basa'` will be`:`

```
a.b.b.a
a.b.b
a.b

```

and for `a.a.a-basa`:

```
a.a.a
a.a
a

```

can we get this list using a single query? Any sql vendor is fine.