Hey Guys,
Iam John and a newbie..

Iam building a database to store the business rules in the database. For example the following expression
Expression=(a=5 or b>6) and (c<7 or d=0)
will be stored in the database as follows:


Rule
-----------------------------------------
RuleId |LHSCode | Operator | RHSValue
------------------------------------------
R1 a = 5
R2 b > 6
R3 c < 7
R4 d = 0
------------------------------------------


Rule Group
--------------------------------------
RuleGroupId | RuleGroupDescrip
--------------------------------------
G1 R1 or R2
G2 R3 or R4
G3 (R1 or R2) and (R3 or R4)
----------------------------------------

Rule Group Relation_1
--------------------------------------------------------------
RuleGrRelId |RuleGroupId|RuleId|RuleJoinOperator|RuleSeqNo
--------------------------------------------------------------
1 G1 R1 or 1
2 G1 R2 - 2
3 G2 R3 or 1
4 G2 R4 - 2
--------------------------------------------------------------


Rule Group Relation_2

--------------------------------------------------------------
GrRelId |RuleGroupId|GroupJoinOperator|RuleSeqNo
--------------------------------------------------------------
1 G1 and 1
2 G2 - 2
--------------------------------------------------------------

The problem is have expressions with more than 5 or 6 rules in which i have 2 build more tables.Is there any better way to do this?Any Better database design?
Any suggestion would be greatly appreciated...

Regards
John

Recommended Answers

All 2 Replies

The situation you describe is very similar to one of the classic database design conundrums: the Product Assembly Hierarchy, colloquially known as a "parts explosion".

Think of a car. A car has a chassis, an engine, a body, an interior, etc. The body is made up of frame, doors, hood, trunk lid. Doors are made up of door frame, door cover, door handle, inside panel, lock mechanism, mirror assembly... and so on and so on, until you get to the smallest parts, that can't be taken apart.

Look at this web site (http://www.databaseanswers.org/data_models/hierarchies/index.htm) to give you an idea of how this kind of "ordered hierarchy" works, then apply it to your situation. I think you will find it a good fit.

Thanks u very much...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.