关于SQL(Technology Computer English)

Tired of not knowing what SQL is? Any serious application
developer is going to need to learn some SQL at
some point in their career. And once you start learning it,
you'll use it. A lot.
Once upon a time...
Back in the old days, the 1970s, computers were expensive
but crucial ways to process data. Banks, large companies,
and governments had the need to not only store but manipulate
huge stores of information. Of course IBM was the prime
source of all things computer at that time, and a research
group in San Jose came up with a new database paradigm based
on relational calculus. System R was a giant step forward
because it focused on the relationships between data instead of
efficient tape storage or pure sequential data dumps. Relational
databases may seem pass à in the era of object-oriented
programming, but at the time it was a giant leap forward.
Part of the development of System R was a nonprocedural,
roughly English-like language for structuring
database queries. This language was dubbed Structured English
Query Language, or SEQUEL. Other vendors saw the
power in relational databases as a tool, so Oracle and other
companies released their own relational databases that included
languages based on the same principles as SEQUEL. As more
relational database products were developed, it became clear
that a standard was necessary, so in 1986 the so-called SQL-
86 standard was adopted by the American National Standards
Institute (ANSI) and early the following year by the International
Standards Organization (ISO). Since 1986, three new
versions of the SQL standard have been developed. SQL-89,
SQL-92, and SQL-99 (also called SQL3) all add additional
functionality to the specification and tend to be driven by
developments in the database tool community.
The SQL standard is not a simple document - over 2000
pages of hardcore technical jargon, relational calculus, logic...
But SQL is probably one of the few 30-year-old standards
you're likely to run into in your daily programming life. Even
你是否一直苦于不知道SQL是什么呢?任何一个真正的应
用程序开发者在他的职业生涯中都会需要学习一定的SQL 知
识。并且,只要你开始学习它,你就会使用它,大量地使用它。
从前⋯⋯
让我们回到过去的日子,回到上个世纪70年代。那时,
计算机是一种昂贵但必不可少的数据处理工具。银行、大型
企业和政府都有这样的需要:不仅要存储大量的信息,而且
还要处理大量的信息。当然,在那个时候,IBM是所有与计
算机有关的东西的主要来源。IBM在圣何塞的一个研究组提
出了一种新的、建立在关系运算基础上的数据库范型。System
R 是一个巨大的进步,因为它集中关注数据之间的关
联,而不是如何在磁带上有效地存储连续的数据块。在面向
对象程序设计的时代里,关系型数据库看上去可能有些过
时,但在当时它的确是一个巨大的飞跃。
System R取得的最大成就之一,就是一种非过程的、类
似于英语的结构化数据库查询语言。这种语言被称为“结构
化英语查询语言”,或者SEQUEL。其他的厂商也看到了关
系型数据库作为一种工具的强大威力,因此Oracle和其他公
司也先后发布了自己的关系型数据库,其中也包含了各自的
查询语言,而这些语言都建立在与SEQUEL 相同的原则之
上。随着越来越多的关系型数据库产品被开发出来,对查询
语言标准的需要也越来越明显了。所以,在1986年,著名的
SQL-86标准被美国国家标准协会(ANSI)采纳,并且在稍
早时已被国际标准组织(ISO)采纳。1986 年之后,SQL 标
准先后发展了三个新的版本。SQL-89、SQL-92 和SQL-99
(也叫SQL3)都给SQL规范加入了新的功能,并且一直注意
着数据库工具社群的需要。
SQL标准决不是一份简单的文档——这份超过2000页的
文档中充斥着深奥的技术术语、关系运算、逻辑⋯⋯但是,
在所有有着超过30 多年历史的标准中,SQL 是少数几个在
你的日常编程工作中起着重要作用的之一。尽管现在的面向

 though object-oriented databases are currently far more sexy,
SQL plays a fundamental role in virtually any significant application
that reads, stores, or manipulates data. Long a client-server
workhorse, SQL has been leveraged by a number of web tools,
ranging from Perl and Java to PHP, ColdFusion, and ASP.
SQL in your daily life
If you've ever taken a good computer science course,
you've talked about all the fundamental programming concepts
-- algorithms, control constructs, and data structures, for
example. But once you've created those data structures for your
program, you need to store them somewhere. In some instances,
especially for simple data, a straightforward sequential text file
is fine. In other cases, you may implement a random-access
binary file for your data records. But when your data starts to
increase in size and complexity, and your application needs to
be robust and fast, you'll probably wander towards the world
of database tools. I know that I can't even write a good bubble
sort off the top of my head, let alone some seriously efficient
searching algorithm for more complex data. But if I abstract the
data functionality into a database, I can simply deal with the
interface to that database and rely on thousands of person-years
that have been spent optimizing relational database functionality.
As far as the programmer is concerned, that interface to the
world of high-powered data crunching is SQL.
Imagine writing an algorithm to search through a text
file of tab-delimited data to find a particular last name
(Ashenfelter) in the 3rd column of the file of authors.
You'd have to deal with all sorts of hard stuff like arrays,
comparison operators, recursion, and other things. I mean,
all you want to do is select the text "Ashenfelter" from the
column that holds the last name in the data file! Well, I can
rewrite that request in SQL while you write the algorithm
in the language of your choice (I'd vote for Perl).
SELECT Lastname FROM Authors WHERE Lastname='Ashenfelter';
I bet I beat you, and that my code is shorter. Note the
similarities between the SQL code in the example above and
the English request in the previous paragraph. Basically,
you've got a verb (SELECT), a subject the verb acts on,
a few modifiers, and a final semi-colon. I don't have to
know details of the algorithm, physical data storage methods,
or even the brand of the database I'm querying - SQL hides
all of that behind a simple, standard interface. That, in a
nutshell, is the beauty of a standard language.
对象数据库显得更加性感,但SQL仍然在几乎所有重要的应
用程序中扮演着基础的角色,负责着数据的读取、存储和处
理。作为客户端和服务器端之间的数据承载者,SQL被很多
web工具利用,使用它的工具从Perl、Java到PHP、ColdFusion
再到ASP。
日常生活中的SQL
如果你上过一个好的计算机科学课程,你一定知道所有
基本的程序设计概念——例如算法、控制结构和数据结构
等。但是,只要你在程序中创建了这些数据结构,你就需要
将它们保存在某个地方。有时(特别是对于简单的数据),
使用简单的顺序文本文件就足够了。但是,另一些时候,你
可能需要实现一个可随机存取的二进制文件来保存数据记
录。但是,当你的数据开始变得越来越大、越来越复杂,当
你的应用程序需要更坚固、更快,你就必须求助于数据库工
具。我知道,我甚至还不能凭空写出一个好的冒泡算法,更
不要说用于更复杂数据的高效搜索算法了。但是,如果我把
这些数据功能抽象到数据库中,我就可以只管处理数据库的
接口,并依靠别人的上千人年的劳动来获得优化的关系型数
据库功能。
想象一下:你要编写一个算法,用于在以tab 键分隔的
文本文件的第三列中搜索一个特定的姓氏(Ashenfelter)。你
必须操纵各种难用的原材料,例如数组、比较操作、递归等
等。但是,你真正想做的就只是在数据文件中存放姓氏的那
一列中选择“Ashenfelter”这些字而已!好吧,当你用你选
择的语言(我推荐你用Perl)编写搜索算法的时候,让我来
用SQL 重写这个请求吧:
SELECT Lastname FROM Authors WHERE Lastname='Ashenfelter';
我猜,我已经打败你了,而且我的代码也更短。请注意,
上面的SQL 代码和前面提到的英语请求非常相似。简单地
说,你会使用一个动词(SELECT)、动词作用的目标、一些
修饰词、以及一个最后的分号。我不必知道算法、数据物理
存储方法方面的细节,甚至连要查询的数据库品牌都不必知
道—— SQL 把所有这些隐藏在一个简单、标准的接口后面。
总而言之,SQL 是一种漂亮的标准语言。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值