Questions tagged [rules-and-constraints]
40 questions
54
votes
7 answers
What happened to database constraints?
When I review database models for RDBMS, I'm usually surprised to find little to no constraints (aside PK/FK). For instance, percentage is often stored in a column of type int (while tinyint would be more appropriate) and there is no CHECK…

Arseni Mourzenko
- 134,780
- 31
- 343
- 513
26
votes
4 answers
Calendar/Planning algorithm
I'm facing a problem I'm not sure how to approach. I have to generate a calendar for employees, each of them having specific work constraints (some personal, some common)
What I'm working with :
I have Doctors
Each doctor has to work 5…

Gil Sand
- 2,173
- 3
- 18
- 22
22
votes
4 answers
The relation between Business Rules Engines and Constraint Programming languages
If one looks at (perhaps older) manuals of Drools or some other rule engines,
one of the illustrations of their added value is solving puzzles such
as the Miss Manners puzzle (listed in the Drools Documentation). Now, such puzzles are naturally…

John Donn
- 424
- 4
- 12
21
votes
6 answers
Is scientific code a different enough realm to ignore common coding standards?
Lately I've been trying to wrap my mind about the following fact.
On one hand, there is a host of coding guidelines and standards for what is considered to be "healthy", "clean", "well-written" and so on code. See the "Clean Code" that appears to be…

iksemyonov
- 453
- 3
- 16
17
votes
6 answers
Representing business rules with exceptions
I know it is expensive but (IMO) I believe it is a very good practice. I'm talking about rules like say, you can't save an Invoice if you are not a sales person... so in that case throwing an exception saying 'your are not authorized' or…

sebagomez
- 432
- 4
- 11
16
votes
4 answers
Conceptually, how does one make a rules/constraints (not graphics/physics) engine for a game
I want to make a simple game similar to the choose-your-own-adventure books. The player is presented with a narrative text and gets to choose his action from a list of possibilities. This, in turn, leads to a new narrative text, ad infinitum. The…

kaqqao
- 363
- 2
- 9
14
votes
6 answers
Forbid calls to arbitrary functions/classes in external code
I've experienced cases where it would be valuable to restrict access to the API of external libraries and frameworks to prevent negative consequences in the system.
For example, in a SharePoint application it might seem natural to call…

Alex
- 402
- 4
- 11
8
votes
6 answers
Highly scalable and dynamic "rule-based" applications?
For a large enterprise app, everyone knows that being able to adjust to change is one of the most important aspects of design. I use a rule-based approach a lot of the time to deal with changing business logic, with each rule being stored in a DB.…

Morgan Herlocker
- 12,722
- 8
- 47
- 78
6
votes
2 answers
Specifying a bi-directional unique constraint on a join table in Postgres
Problem description
I have a situation where I want to enforce that a relationship can only be defined once and I want to solve it on database (Postgres) level.
The following situation I consider invalid, because the relationship is defined twice.
…

Dynom
- 169
- 3
6
votes
4 answers
Representing a rule in a ruleset
How to represent rules for a rule engine as objects?
A rule would be
if (booleanExpression(input)) then a chain of generic actions" else next rule
...where the generic actions might be e.g. passing the input to a different chain of rules,…

SF.
- 5,078
- 2
- 24
- 36
5
votes
2 answers
Preferred approach to a matching process
I am currently in the process of putting together a matching algorithm. The matching process is as follows:
Query data is used to perform a "lookup" on a set of reference data in order to determine an applicable id which is then later used in a…

Ian
- 159
- 1
5
votes
2 answers
How to program for constraints/rules
First the background, during interviews in the past, many times I have been asked to design some or other variation of card game as programming puzzle, and I have tried to design it in OO way, but I have never been satisfied with my solutions.…

Gaurav
- 3,729
- 2
- 25
- 43
4
votes
3 answers
C#/VB struct – how to avoid case with zero default values, which is considered invalid for given structure?
How to implement some constrained .NET struct/structure (let's say LimitedString), where its state with default values (set by CLR to technical defaults, i.e. nulls, zeros, etc.) should be prohibited due to some design constraint?
For example in…

miroxlav
- 672
- 4
- 17
4
votes
2 answers
Database constraints for a recursive folders structure
In an application, I have a recursive folder structure (like folders in OS X or Windows file system).
Each folder can contain three kind of things:
Other folders (hence the recursive structure)
Employees
Tasks
Here are the simplified models for…

Jivan
- 315
- 1
- 8
4
votes
1 answer
Fixing bad data in a database - redo or incremental
I have pseudo-ownership of a fairly old db (original data from 30 years ago; current design is >15 years old). In my opinion, the schema is pretty broken, and one of the implications of this is that there are a lot of inconsistencies/issues with the…

james.haggerty
- 173
- 2