应对模式演变的策略?

发布于 2024-07-09 01:18:07 字数 1449 浏览 9 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

时光清浅 2024-07-16 01:18:08

您可能想看看重构数据库:进化数据库设计这本书。

You might want to checkout this book on Refactoring Databases: Evolutionary Database Design.

别闹i 2024-07-16 01:18:08

我建议使用连续(或至少每晚)构建策略。
每次签入时重建数据库,或至少每天一次。
另外,每天运行一次单元测试来测试每一位代码,无论是在存储过程、触发器还是数据访问层中。

编写存储过程的成本很高,但这会立即识别中断。
一旦知道断点在哪里,就可以修复它。

我很想听听其他人将此策略应用于数据库更改的经验。

I suggest using a continuous (or at least nightly) build strategy.
Rebuild the database on every checkin, or at least once per day.
Also once per day, run unit tests to exercise each bit of code, be it in a stored procedur, a trigger or a data access layer.

There is a great cost to writing stored procs, but this will identify breaks immediately.
Once you know where the break is, you can fix it.

I'd be interested to hear other people's experiences with this strategy applied to database changes.

↘紸啶 2024-07-16 01:18:08

我们使用 Enterprise Architect 进行数据库定义。 我们包括存储过程、触发器以及 UML 中定义的所有表定义。 该程序的三个出色功能是:

  1. 从 ODBC 连接导入 UML 图。
  2. 立即为整个数据库生成 SQL 脚本 (DDL)
  3. 生成数据库的自定义模板文档。

在我作为开发人员 10 多年的时间里,从来没有任何其他工具给我留下过如此深刻的印象。 EA 一次性支持 Oracle、MySQL、SQL Server(多个版本)、PostGreSQL、Interbase、DB2 和 Access。 每当我遇到问题时,他们的论坛都会及时回答我的问题。 强烈推荐!!

当数据库发生更改时,我们在 EA 中进行生成 SQL,并将其签入我们的版本控制 (svn)。 我们使用 Hudson 进行构建,当它看到您修改了签入的sql。

We use Enterprise Architect for our DB definitions. We include stored procedures, triggers, and all table definitions defined in UML. The three brilliant features of the program are:

  1. Import UML Diagrams from an ODBC Connection.
  2. Generate SQL Scripts (DDL) for the entire DB at once
  3. Generate Custom Templated Documentation of your DB.

I've never been more impressed with any other tool in my 10+ years as a developer. EA supports Oracle, MySQL, SQL Server (multiple versions), PostGreSQL, Interbase, DB2, and Access in one fell swoop. Any time I've had problems, their forums have answered my problems promptly. Highly recommended!!

When DB changes come in, we make then in EA, generate the SQL, and check it into our version control (svn). We use Hudson for building, and it auto-builds the database from scripts when it sees you've modified the checked-in sql.

恋竹姑娘 2024-07-16 01:18:08

我的建议是摆脱存储过程,转而使用内联 SQL,可能在文本/xml 文件中维护。 我发现 SPrc 更烦人,而且维护起来更耗时。 生成查询计划后(第一次执行查询),您会注意到性能差异可以忽略不计。 另外,您将能够对整个数据库脚本进行版本控制......

My advice would be to get rid of stored procedures and instead use inline SQL, maybe maintained in text/xml files. I find SProcs are far more annoying and time consuming to maintain. Once the query plan is generated (first time the query is executed) you'll notice negligible difference in performance. Plus you'll be able to version control your entire DB scripts...

棒棒糖 2024-07-16 01:18:08

以下是我的建议:

  1. 尝试摆脱最少使用的功能。 质疑不一直使用的功能。 应用程序中的每个功能都有多个与之相关的成本级别(维护、支持、回归测试、代码复杂性等)。
  2. 远离存储过程,除非绝对没有办法在代码中以可扩展的方式高效地完成它。
  3. 逐步引入 ORM 解决方案(使用重构从 JDBC 迁移到 ORM),以减少 CRUD 操作中的代码量和代码复杂性
  4. 在修复错误时构建功能、集成和单元测试,并将这些测试合并到持续集成中系统。 尽可能自动化回归测试,以便在签入时立即发现问题。
  5. 一般来说,每当您修复错误时,请利用该机会进行重构以解耦实现/代码模块。

如果您对数据库迁移问题有疑问,这可能会有所帮助:http:// /shashivelur.com/blog/2008/07/hibernate-db-migration/

Here are my suggestions:

  1. Try to get rid of the least used functionality. Question the features that are not used all the time. Each feature in an application has several levels of costs associated with it (maintaining, support, regression testing, code complexity, etc.).
  2. Stay away from Stored procedures, unless there is absolutely no way to do it efficiently and in a scalable manner in the code.
  3. Introduce an ORM solution gradually (using refactoring to move from JDBC to ORM) to reduce the amount of code and code complexity in CRUD operations
  4. Build functional, integration and unit tests as and when you fix a bug and incorporate those tests in to the Continuous integration system. Automate your regression testing as much as possible to identify problems as soon as it is introduced by a check-in.
  5. In general, whenever you fix a bug, use that opportunity to refactor to decouple the implementations/code modules.

If you have have questions about Database migration problems, this might help: http://shashivelur.com/blog/2008/07/hibernate-db-migration/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文