阶梯式搜索算法。 从N中选择一个,重复,重复,查看最终结果

I want to know how to think of search systems that require you make certain selections to see the end results. I am speaking about the select forms, where you proceed according to what you chose, and then you see your result.

One random example of what I'm talking is is described below. Imagine

Initial select  | Step 1         | Step 2                        | Step 3         | Step4    
---------------------------------------------------------------------------------------------------
A               | -- D or E or F | -- K or L or M or N           | -- RESULT      |
B               | -- D or H or I | -- O or P or L or Q or R      | -- RESULT      |
C               | -- D or I or J | -- Q or R or L or S or U or V | -- W or X or W | -- RESULT

Initial select being a select form in the beginning, and giving you more and more relevant select-s as you proceed, finally giving you an end result.

How are forms like these made? How should I organize data for this in SQL?

I can work with PHP, Ruby, JavaScript, SQL, NoSQL, HTML5/CSS. Please give me a an instruction, a link for a reading or something that will make me able to do such thing efficiently.

Update

Maybe you could tell me the name of such system so I can research myself. What should I call such search for Google to understand me?

You could define the options by way of self-referencing foreign key, e.g.:

create table decisions(
  id int unsigned not null auto_increment,
  parent_id int unsigned,
  primary key (id),
  constraint fk_decisions_parent_id foreign key (parent_id) references decisions (id)
    on delete cascade on update cascade
)engine=innodb;

To find the options based on a decision, you would then query as follows:

 select *
 from decisions
 where parent_id = [decision ID];

If no options are returned, then you have arrived at your "RESULT".