Large, Interconnected Data Belongs to a Database

本文讨论了如何在关系型数据库中高效地存储、管理和操作大规模、持久且相互关联的数据元素。现代关系型数据库管理系统(RDBMS)易于获取、成本低廉,并能轻松扩展以满足需求。通过SQL查询,可以方便地从数据库中提取信息,进行复杂的数据更改,甚至在不修改代码的情况下处理一次性修改。此外,关系型数据库还提供了处理数据之间关系的强大能力,确保一致性并创建高效链接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Large, Interconnected Data Belongs to a Database

Diomidis Spinellis

iF YOUR APPLiCATiON is going to handle a large, persistent, interconnected set of data elements, don’t hesitate to store it in a relational database. In the past, RDBMSs used to be expensive, scarce, complex, and unwieldy beasts. This is no longer the case. Nowadays, RDBMS systems are easy to find—it is likely that the system you’re using already has one or two installed. Some very capable RDBMSs, like MySQL and PostgreSQL, are available as open source software, so cost of purchase is no longer an issue. Even better, so-called embedded database systems can be linked as libraries directly into your appli- cation, requiring almost no setup or management—two notable open source ones are SQLite and HSQLDB. These systems are extremely efficient.
If your application’s data is larger than the system’s RAM, an indexed RDBMS table will perform orders of magnitude faster than your library’s map collec- tion type, which will thrash virtual memory pages. Modern database offer- ings can easily grow with your needs. With proper care, you can scale up an embedded database to a larger database system when required. Later on, you can switch from a free, open source offering to a better-supported or more powerful proprietary system.
Once you get the hang of SQL, writing database-centric applications is a joy. After you’ve stored your properly normalized data in the database, it’s easy to extract facts efficiently with a readable SQL query; there’s no need to write any complex code. Similarly, a single SQL command can perform complex data changes. For one-off modifications—say, a change in the way you organize your persistent data—you don’t even need to write code: just fire up the database’s direct SQL interface. This same interface also allows you to experiment with queries, sidestepping a regular programming language’s compile–edit cycle.
96 97 Things Every Programmer Should Know

Another advantage of basing your code around an RDBMS involves the han- dling of relationships between your data elements. You can describe consis- tency constraints on your data in a declarative way, avoiding the risk of the dangling pointers you get if you forget to update your data in an edge case. For example, you can specify that if a user is deleted, then the messages sent by that user should be removed as well.
You can also create efficient links between the entities stored in the database any time you want, simply by creating an index. There is no need to perform expensive and extensive refactorings of class fields. In addition, coding around a database allows multiple applications to access your data in a safe way. This makes it easy to upgrade your application for concurrent use and also to code each part of your application using the most appropriate language and platform. For instance, you could write the XML backend of a web-based application in Java, some auditing scripts in Ruby, and a visualization interface in Processing.*
Finally, keep in mind that the RDBMS will sweat hard to optimize your SQL commands, allowing you to concentrate on your application’s functional- ity rather than on algorithmic tuning. Advanced database systems will even take advantage of multicore processors behind your back. And, as technology improves, so will your application’s performance.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值