# SQL and Business Logic

DevFeed: [SQL and Business Logic](<https://devfeed.tech/articles/sql-and-business-logic-34560.md>)

Original publisher: [Read original article](<https://tapoueh.org/blog/2017/06/sql-and-business-logic/>)

Author: Dimitri Fontaine PostgreSQL Major Contributor; Author

Published: 2017-06-19T11:30:19Z

Content type: article

Language: en

Sources: [Dimitri Fontaine](<https://devfeed.tech/sources/dimitri-fontaine.md>)

Topics: [business logic](<https://devfeed.tech/topics/business-logic.md>), [SQL](<https://devfeed.tech/topics/sql.md>), [Databases](<https://devfeed.tech/topics/databases.md>), [implementation](<https://devfeed.tech/topics/implementation.md>), [User Stories](<https://devfeed.tech/topics/user-stories.md>), [Code](<https://devfeed.tech/topics/code.md>), [Object-relational mapping](<https://devfeed.tech/topics/orm.md>)

Tags: [business-logic](<https://devfeed.tech/tags/business-logic.md>), [code](<https://devfeed.tech/tags/code.md>), [database](<https://devfeed.tech/tags/database.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [orm](<https://devfeed.tech/tags/orm.md>), [sql](<https://devfeed.tech/tags/sql.md>), [user-stories](<https://devfeed.tech/tags/user-stories.md>)

## AI overview

This article examines how SQL and relational database design can encode business logic. It argues that database schemas and SQL queries help enforce shared validity and consistency rules across applications, and illustrates the point with a query based on a Chinook database user story.

## Source excerpt

Business logic is supposed to be the part of the application where you deal with customer or user facing decisions and computations. It is often argued that this part should be well separated from the rest of the technical infrastructure of your code. Of course, SQL and relational database design is meant to support your business cases (or user stories), so then we can ask ourselves if SQL should be part of your business logic implementation. Or actually, how much of your business logic should be SQL?