You are hereDynamic RestrictionsDynamic restrictions have to deal with state transitions of data. We can distinguish insert and update restrictions. Insert restrictions type invoiceline = invoice, article, number, amount. init invoiceline its amount = number * article its price. Another solution for the same consistency problem applies both a dynamic and a static constraint and can be applied if we redefine invoice line by adding invoice line its article_price: type invoiceline = invoice, article, article_price, number. init invoiceline its article_price = article its price. assert invoiceline its amount = number * article_price. If it frequently occurs that the number of articles per invoice line is one then the following default command can fasten data insertions by assuming 1 as the number of articles: init default invoiceline its number = 1. It is also possible to specify conditional restrictions. For example, we could apply a price reduction percentage (of course we first have to add the attribute invoiceline its reduction to the model): init invoiceline its reduction = if number else if number else 20. After extending the definition of invoiceline with the attribute reduced_price, a DBMS can calculate this reduced price at insertion time, using: init invoiceline its reduced_price = (100 ââ¬â reduction) * article its price / 100. init invoiceline its amount = number * reduced price. Another possibility is to apply reductions to distinct articles instead of the previous one related to the number of sold articles: init invoiceline its reduction = case article of Update restrictions
type student = name, address, town, birth_date, faculty. check practical its phase = case of Delete restrictions For further examples we refer to the books of Johan ter Bekke.
|
Recent comments