我们应该为每个开发人员拥有单独的数据库实例吗?

发布于 2024-09-02 08:52:22 字数 328 浏览 4 评论 0原文

开发基于数据库的应用程序的最佳方法是什么?我们可以有两种方法。

  1. 所有开发人员的通用数据库。
  2. 为所有开发人员提供单独的数据库。

各自的优点和缺点是什么?哪一种方法更好?

编辑: 应该有不止一个开发人员来更新数据库,并且我们已经在每台开发人员计算机上安装了 SqlExpress 2005。

编辑:我们大多数人都建议使用一个通用数据库。但是,如果其中一位开发人员修改了代码和数据库架构。他尚未提交代码更改,但架构更改已进入公共数据库。它不会破坏其他开发人员的代码吗?

What is the best way for developing a database based application? We can have two approaches.

  1. One common database for all the developers.
  2. Separate database for all the developers.

What are the pros and cons of each? And which one is better way?

Edit: More then one developer is supposed to update the database and we already have SqlExpress 2005 on each developer machine.

Edit: Most of us are suggesting a common database. However if one of the dev has modified the code and database schema . He has not committed the code changes but the schema changes has gone to the common database. Will it not possibly break the other developers code.

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

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

发布评论

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

评论(12

筱果果 2024-09-09 08:52:22

两者 -

我喜欢在上线或进入“正式”测试环境之前对更改进行测试的单个数据库。这是您的开发人员的健全性检查;它与实时系统保持同步,并确保他们始终考虑彼此的更改。规则应该是,如果更改可能会破坏其他内容,则不应在此处进行更改。

当多个开发人员进行更新时,每个开发人员拥有一个数据库是非常有用的(甚至是必要的)。它为他们提供了他们想要的所有开发灵活性,而不会破坏其他开发人员的东西。

关键是要有一个将数据库更改从开发转移到实际系统的流程,并坚持您的流程。

Both -

I like a single database that changes are tested on before going live, or going to a 'formal' test environment. This is your developer's sanity check; it stays up to date with the live system and it makes sure they always consider each others changes. The rule should be that changes don't go on here if they might break something else.

A database per developer is great (even essential) when more than one developer is making updates. It allows them all the development flexibility they want without breaking things for other developers.

The key is to have a process for moving database changes from development through to your live system, and stick to your process.

悲歌长辞 2024-09-09 08:52:22

共享数据库

  • 更简单
  • 更少的“它可以在我的机器上运行”的情况。
  • 强制集成
  • 快速发现问题(快速失败)

独立数据库

  • 永远不会影响其他开发人员,但这也是一件坏事,在持续集成中

我们使用共享开发数据库,​​效果很好。我们的架构很少会发生向后不兼容的变化,但有时在我们上线之前会发生设计更改,我们只需要求其他开发人员进行更新即可。

我们确实有单独的开发应用程序(Web)服务器,但它们共享相同的数据库。我们的开发人员确实可以选择使用自己的数据库,因为他们知道如何设置它,并且有时会这样做,但只是暂时的。对我们来说,规范是共享数据库。

Shared database

  • Simpler
  • Less cases of "It works on my machine".
  • Forces integration
  • Issues are found quickly (fail fast)

Individual databases

  • Never affect other developers, but this is also a bad thing, in continuous integration

We use a shared development database and it works out nicely. Our schema rarely changes in a way that makes it backwards incompatible, but occasionally a design change will occur before we go live, and we simply ask the other developers to update.

We do have separate development application (web) servers, but they share the same database. Our developers do have the option to use their own database, as they know how to set this up, and will do that on occasion, but only temporarily. The norm, for us, is to share the database.

所谓喜欢 2024-09-09 08:52:22

我想我应该把这个扔掉,但为什么不让每个开发人员在他们的桌面上托管自己的 SQL Server Developer 实例,然后为每个其他环境(开发、QA 和产品)提供一个共享服务器呢?我认为即使是 Visual Studio Pro 附带的基本 MSDN(如果您选择它)也包含 SQL Server Developer 的许可证。

开发人员可以在自己的桌面上工作,而不会影响其他人,然后您可以让他们将代码移动到您认为合适的下一个共享环境(随意,每日/每周构建等)。

编辑:
我应该补充一点,桌面实例允许开发人员执行 DBA 在共享环境中经常限制的操作。这包括数据库创建、备份/恢复、分析器等。这些并不是必需的,但它们可以让开发人员变得更加高效,同时减少对 DBA 的要求。

共享环境对于测试来说是完全必要的——我不建议从桌面转向生产。但是,您可以通过允许开发人员以相对较小的成本对给定数据库环境进行 100% 的控制(包括与其他数据库环境的隔离)来添加更多内容。

Thought I'd throw this out there, but why not let every developer host their own instance of SQL Server Developer on their desktops and then have a shared server for each of the other environments (development, QA, and prod)? I think even the basic MSDN that comes with Visual Studio Pro (if you opt for it) includes a license for SQL Server Developer.

The developer can work on their desktop without impacting the others and then you can have them move the code to the next shared environment as you see fit (at will, with daily/weekly builds, etc.).

EDIT:
I should add that the desktop instance allows developers to do things that he DBAs often restrict on shared environments. This includes database creation, backup/restore, profiler, etc.. These things are not essential but they allow the developer to become so much more productive while reducing the demands they make against your DBAs.

The shared environment is completely necessary for testing - I would not recommend going from desktop to production. But you can add so much by allowing the developers to have 100% control over a given database environment (including isolation from others) with a relatively minor cost.

红颜悴 2024-09-09 08:52:22

取决于您的开发、测试和维护周期。还有开发团队(当然还有组织)的规模和位置。如果您支持多个版本的数据库,您可能需要更多环境。

在现实世界中,我发现以下方法相当令人满意:

  • 用于测试目的的单个中央数据库/应用程序,定期将各个开发人员的所有更改合并到
  • 本地副本中进行开发(因此您可以自由地删除和重新加载整个数据库)
  • 升级脚本维护架构、辅助和示例数据集的任何更改

这里有一些进一步的要点:

如果两个开发人员(两个团队)正在进行可能相互影响的更改,那么他们应该独立完成任务,并且然后集成/合并并测试。为此,最好有单独的开发环境(除非他们必须一起工作,在这种情况下,我认为他们是同一团队的一部分;他们仍然可以处理自己的数据库副本,并在必要时共享它)

如果他们所做的更改不会互相影响,那么他们就可以在主服务器上工作。或者在他们自己的数据库本地副本上。

因此,在一般情况下(当您支持系统的多个版本并无论如何维护升级脚本时),在本地副本上进行开发具有所有好处,并且没有风险。

如果您可以共享测试用例,那就太好了,因此能够轻松快速地转储/恢复数据库是一个很大的优势。

编辑:
上述所有内容都假设在整个系统的本地计算机上有一个副本用于测试目的是可行的(大小、性能、许可证等)。

Depends on your development, testing and maintenance cycles. Also on the size and location of the development team (and of course organization). If you support several versions of the database you might need even more environments.

In real world I found the following approach rather satisfying:

  • single central database/application for testing purposes, gets all the changes by various developers periodically merged into it
  • local copies for development (so you are free to drop and reload the whole database)
  • upgrade scripts are maintained for any changes to schema, auxiliary and sample data sets

Here are some further points:

If two developers (two teams) are working on changes that can affect each other then they should complete their tasks independently and then integrate/merge and test. For this it is much better to have separate development environments (unless they have to work together in which case I consider them to be a part of the same team; still they can work on their own copies of the database and share it if necessary)

If they work on the changes that do not influence each other they could work on the main server. Or on their own local copies of the database.

So, developing on the local copy has all the benefits with no risk in a general case (when you support multiple versions of the system and maintain upgrade scripts anyway).

Still it is great if you can share test cases so ability to dump/restore the database easily and quickly is a big plus.

EDIT:
All of the above assume that having a copy on the local machine of the whole system for testing purposes is feasible (size, performance, licenses, etc).

帅气称霸 2024-09-09 08:52:22

我会选择解决方案#1:为所有开发人员提供一个通用数据库。

优点

  1. 基础设施成本较低;
  2. 刷新开发数据库时只需要一次转储;
  3. 每个人都使用相同的数据进行开发,因此它紧密地代表了生产环境;

缺点

  1. 如果一名开发人员执行了错误的操作,可能会影响更多的开发人员。

至于解决方案#2:为每个开发人员提供一个独立的数据库;

优点

  1. 当开发需要隔离时,这对于新功能开发可能很有用;

缺点

  1. 对公司来说更昂贵(基础设施、许可证......);
  2. 急切的隔离开发环境导致的问题倍增(在开发者环境中工作,未集成);
  3. 生产环境中相同副本的 DBA 的转储倍增。

考虑到上述情况,我会根据您的公司规模建议:

  1. 一个用于开发的数据库;
  2. 一个用于测试集成的数据库;
  3. 一个用于验收测试的数据库;
  4. 一种用于新功能开发,可能需要集成测试。

如果您的公司不需要集成测试,那么就进行验收测试,这一步在投入生产之前至关重要。

I would opt for solution #1 : One common database for all the developers.

Pros

  1. Less expensive for the infrastructure;
  2. Only one dump is required when it's time to refresh the development database;
  3. Everyone develops with the same data, so it closely represents the production environment;

Cons

  1. If one developer performs a bad operation, this could impact a larger amount of developers.

As for solution #2 : One independant database for each of the developers;

Pros

  1. This could be useful for new features developments, when development requires isolation;

Cons

  1. More expensive for the company (infrastructure, licences...);
  2. Multiplication of problems caused by eager isolation development environment (works in devloper's environement, not integrated);
  3. Multiplication of dumps by the DBAs of the same copy from the production environment.

Considering the above, I would recommend, depending on your company size:

  1. One database for development;
  2. One database for testing the integration;
  3. One database for acceptance tests;
  4. One for new feature development that will perhaps require integration tests.

If your company doesn't require integration tests, then go with acceptance tests, this step is crucial before going to production.

终止放荡 2024-09-09 08:52:22

每个开发人员一个,加上一个持续集成和构建服务器来运行单元和集成测试。这让您两全其美。

一旦数据库更改量达到一定水平,让所有开发人员修改单个开发数据库很快就会降低生产力,因为它迫使开发人员在准备签入之前将更改部署到共享数据库,这意味着代码的其他部分线路可能会不必要地断裂。

One per developer plus a continuous integration and build server to run unit and integration tests. That gives you the best of both worlds.

Having all developers modify a single dev database quickly becomes less productive once the amount of database change reaches a certain level because it forces a developer to deploy changes to the shared database before he is ready to check-in, which means other parts of the code line may break unnecessarily.

荒人说梦 2024-09-09 08:52:22

简单的答案:

拥有一个开发数据库,​​如果开发人员想要自己的数据库,他们可以在自己的机器上运行自己的实例。请务必在共享上进行测试/发布。

Simple answer:

Have one development database, and if the developers want their own, they can just run their own instance on their own machines. Just be sure to test/publish on the shared.

青丝拂面 2024-09-09 08:52:22

我们两者都做:

我们在我所在的地方使用代码生成,并且我们的数据库也被生成。因此,我们在每个开发人员的盒子上都有一个生成数据库的实例。然后,我们使用生成的脚本将更改应用到中央测试数据库。如果进展顺利,我们将在发布期间将更改应用到生产数据库。

这种方法的好处是,当我们的“事实来源”签入源代码管理时,所有数据库更改都会在其他开发人员变基和重新生成时自动分发给他们。这对我们来说效果很好。

We do both:

We use code generation where I'm at and our database is generated as well. So we have an instance on each developer's box where the database is generated. Then we use the scripts that are generated to apply the changes to a central test database. If that goes well we apply the changes to the production database during a release.

What's nice with this approach is that when our "source of truth" is checked in to source control, all the database changes are automatically distributed to the other developers when they rebase and regenerate. It works well for us.

挖个坑埋了你 2024-09-09 08:52:22

最好的方法是测试/QA 服务器上有一个数据库,每个开发人员有一个数据库(可能在开发人员的本地计算机上)(因此,10 个开发人员使用 10 + 1 个数据库)。

与一般开发相同的方法:每个开发人员在本地计算机上都有自己的源代码副本。

此外,多数据库方法简化了版本控制系统中数据库模式的保存。我们将数据库创建脚本保存在 SVN 中。

我们正在使用此处描述的方法:
http://www.sqlaccessories.com/Howto/Version_Control.aspx

The best way is single database on Test/QA server and one database (probably on developer's local computer) for each developer (so, 10 developers work with 10 + 1 databases).

The same approach as for general development: each developer has own copy of source code on local machine.

Also, multiple-database approach simplifies the keeping database schema in version control systems. We are keeping database creation scripts in SVN.

We are using the approach, described here:
http://www.sqlaccessories.com/Howto/Version_Control.aspx

窗影残 2024-09-09 08:52:22

您可能还想查看重构数据库。除了讨论数据库更改之外,他还讨论了如何以降低风险的方式从开发到生产。

You might also want to look at Refactoring Databases. Aside from discussing database changes, he includes discussions on going from development to production in a way that reduces risk.

燕归巢 2024-09-09 08:52:22

到底为什么要为所有开发人员提供一个单独的数据库?
共用一个数据库,表结构一致,sql语句也一致。

Why on earth would you want a separate database for all developers?
Have one common database for all, that way the table structure is consistent and the sql statements are as well.

但可醉心 2024-09-09 08:52:22

开发人员拥有自己的数据库的最大问题是:

  • 首先不太可能是大小
    实际生产数据库的数据(如果
    你获取我们需要的所有数据库
    与这里合作,他们会占用
    几百GB的空间,我
    我的上没有可用的
    机),这会导致错误的代码
    写的永远不会工作
    大型数据库以提高性能
    原因。永远不应该针对比产品上的数据集小得多的数据集编写 SQL 代码。
  • 二、开发者使用自己的
    数据库创建问题时
    花费很长时间开发
    某事,然后才发现
    当它们与真实的数据库合并后
    它会影响其他东西。你
    当您找到这些东西时,速度会快得多
    共享环境。所以有
    最终减少浪费的开发
    时间。
  • 第三开发人员致力于相关
    需要了解有关变化的事情
    你正在做的,这会影响他们
    改变。

当你知道你会影响别人时,我认为你会更加小心你所做的事情,这在我的书中是一个优点。

现在共享数据库服务器应该有我们所说的临时数据库,人们可以在其中创建和测试表更改,因此如果他们正在做一些可能需要删除并重新创建表的事情(这应该是一种罕见的情况!),他们可以首先通过将表复制到临时数据库并在那里运行其流程来测试该流程,然后在确定其有效时更改为真实数据库。或者,我们经常在测试特定更改之前将备份表复制到临时数据库,以便在旧数据出现问题时可以轻松地重新创建旧数据。

我认为使用单独的数据库没有任何优势。

The biggest problems with developers having their own databases are:

  • First it is unlikely to be the size
    of the real production database (if
    you take all the databases we need to
    work with here, they would take up
    several hundred gigabytes of space, I
    don't have that available on my
    machine), this causes bad code to be
    written that will never work on a
    large database for performance
    reasons. SQL code should never be written against a data set significantly smaller than the one on prod.
  • Second, developers who use their own
    database create problems when they
    spend a long time developing
    something and then find out only
    after they merge with a real datbase
    that it affects something else. You
    find this stuff much faster when you
    share the environment. So there is
    inthe end less wasted development
    time.
  • Third developers working on related
    things need to know about the changes
    you are making, it will affect their
    change.

When you know you are going to affect others, I think you tend to be more careful what you do which isa plus in my book.

Now the shared database server should have what we call a scratch database, a place where people can create and test table changes, so if they are doing something that might need to drop and recreate a table (which should be a rare case!), they can test the process first by copying the table to the scratch database and running their process there and then changin to the real database when they are sure it works. Or we often copy a backup table to the scratch database before testing a particular change, so we can easily recreate the old data if it goes bad.

I see no advantages at all to using individual databases.

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