不管我们喜欢与否,我们开发人员中的许多人(如果不是大多数的话)都经常使用数据库,或者有一天可能不得不使用数据库。考虑到大量的误用和滥用,以及每天出现的大量与数据库相关的问题,公平地说,有一些概念是开发人员应该知道的——即使他们今天不设计或使用数据库。

关于数据库,开发人员和其他软件专业人员应该知道的一个重要概念是什么?


当前回答

我会说有很强的SQL基础技能。到目前为止,我见过许多对数据库了解不多的开发人员,但总是询问如何制定一个相当简单的查询的技巧。查询并不总是那么容易和简单。在查询规范化良好的数据库时,必须使用多个连接(内部连接、左连接等)。

其他回答

好问题。以下是一些想法,排名不分先后:

Normalization, to at least the second normal form, is essential. Referential integrity is also essential, with proper cascading delete and update considerations. Good and proper use of check constraints. Let the database do as much work as possible. Don't scatter business logic in both the database and middle tier code. Pick one or the other, preferably in middle tier code. Decide on a consistent approach for primary keys and clustered keys. Don't over index. Choose your indexes wisely. Consistent table and column naming. Pick a standard and stick to it. Limit the number of columns in the database that will accept null values. Don't get carried away with triggers. They have their use but can complicate things in a hurry. Be careful with UDFs. They are great but can cause performance problems when you're not aware how often they might get called in a query. Get Celko's book on database design. The man is arrogant but knows his stuff.

我会说有很强的SQL基础技能。到目前为止,我见过许多对数据库了解不多的开发人员,但总是询问如何制定一个相当简单的查询的技巧。查询并不总是那么容易和简单。在查询规范化良好的数据库时,必须使用多个连接(内部连接、左连接等)。

RDBMS兼容性

查看是否需要在多个RDBMS中运行应用程序。如有,可能需要:

避免RDBMS SQL扩展 消除触发器和存储过程 遵循严格的SQL标准 转换字段数据类型 更改事务隔离级别

否则,这些问题应该分开处理,并开发应用程序的不同版本(或配置)。

我希望每个人,包括dba和开发人员/设计人员/架构师,都能更好地理解如何正确地对业务领域建模,以及如何将业务领域模型映射/转换为规范化的数据库逻辑模型、优化的物理模型和适当的面向对象类模型(每种模型由于各种原因(可能)不同),并理解何时、为什么以及它们(或应该)如何彼此不同。

对于一些项目,面向对象模型更好。

对于其他项目,关系模型更好。