Database design for database-agnostic applications

后端 未结 17 1750
隐瞒了意图╮
隐瞒了意图╮ 2021-02-02 14:15

What do I have to consider in database design for a new application which should be able to support the most common relational database systems (SQL Server, MyS

17条回答
  •  一整个雨季
    2021-02-02 14:44

    Rule 1: Don't use database specific features

    Rule 2: Don't use stored procedures.

    Rule 3: If you break Rule 1, then break rule 2 as well.

    There have been a lot of comments about not using stored procedures. This is because the syntax/semantics are very different and so porting them is difficult. You do not want heaps of code that you have rewrite and retest.

    If you decide that you do need to use database specific features then you should hide those details behind a stored procedure. Calling the stored procedures of different database is all fairly similar. Inside the procedure, which is written in PL/SQL you can use any Oracle constructs that you find useful. Then you need to write an equivalent for the other target databases. This way, the parts that are database specific are in that database only.

提交回复
热议问题