How to add rules to the dmn table programatically and how to make rows in dmn table expire after certain amount of time

How to add rules to the dmn table programatically and how to make rows in dmn table expire after certain amount of time?