Question: I want to fetch data from SQLite database for Blackberry. 

There is one table with four columns: `ID, FROM, TO, TIME` 

I want to fetch record on the basis of `FROM`, and `TO` values.

Where condition 1:

```
FROM = [from value] AND TO = [to value]

```

2nd condition is:

```
FROM = TO AND TO = FROM

```

It should return the last 20 records.

Answer: 
* `Action` lists all possible actions.
* `Issue` list all possible issues.
* `IssueAction` has all applicable issue-action combinations.
* `CallIssues` list all issues reported on a call.
* `ActionsTaken` has all actions taken regarding an issue of a call.

In general an action may be a series of actions ... ; hence the `ParentActionID` in actions table. This is nice for visual illustration, but you would probably want to use some alternative method for that hierarchy -- like nested sets, closure table or path enumeration.

---

![enter image description here](https://i.stack.imgur.com/r4RsT.png)
Is this roughly the structure? ![enter image description here](https://i.stack.imgur.com/VXjFE.gif)

Then the two queries

```
Select * 
from    Call C
join    Issue_Call IC
on  C.call_id = IC.Call_id
join    Issue I
on  I.Issue_id = IC.Issue_id
join    Issue_Action IA
on  IA.Issue_ID = I.Issue_ID
join    Action A
on  IA.Action_ID = A.Action_ID
Where    C.Call_ID = 1

Select  * 
from    Call C
join    Issue_Call IC
on  C.call_id = IC.Call_id
join    Issue I
on  I.Issue_id = IC.Issue_id
join    Issue_Action IA
on  IA.Issue_ID = I.Issue_ID
join    Action A
on  IA.Action_ID = A.Action_ID
Where    I.Issue_ID = 1

```

Would this work?