it-e-34 Structure of the Relational Database

The relational model is the basis for any relational database management system (RDBMS).
[1]A relational model has three core components: a collection of objects or relations, operators
that act on the objects or relations, and data integrity methods. In other words, it has a place to
store the data, a way to create and retrieve the data, and a way to make sure that the data is
logically consistent.
A relational database uses relations, or two-dimensional tables, to store the information
needed to support a business. Let's go over the basic components of a traditional relational
database system and look at how a relational database is designed. Once you have a solid
understanding of what rows, columns, tables, and relationships are, you'll be well on your way to
leveraging the power of a relational database.

A table in a relational database, alternatively known as a relation, is a two-dimensional
structure used to hold related information. A database consists of one or more related tables.
NoteDon't confuse a relation with relationships. A relation is essentially a table, and a
relationship is a way to correlate, join, or associate two tables.
A row in a table is a collection or instance of one thing, such as one employee or one line
item on an invoice. [2]A column contains all the information of a single type, and the piece of data
at the intersection of a row and a column, a field, is the smallest piece of information that can be
retrieved with the database's query language. For example, a table with information about
employees might have a column called LAST_NAME that contains all of the employees' last
names. Data is retrieved from a table by filtering on both the row and the column.

The examples throughout this article will focus on the hypothetical work of Scott Smith,
database developer and entrepreneur. He just started a new widget company and wants to
implement a few of the basic business functions using the relational database to manage his

Human Resources (HR) department.

A two-dimensional structure used to hold related information, also known as a

Most of Scott's employees were hired away from one of his previous employers, some
of whom have over 20 years of experience in the field. As a hiring incentive, Scott has agreed to
keep the new employees' original hire date in the new database.

A group of one or more data elements in a database table that describes a person,
place, or thing.

The component of a database table that contains all of the data of the same name
and type across all rows.
You'll learn about database design in the following sections, but let's assume for the moment
that the majority of the database design is completed and some tables need to be implemented.
Scott creates the EMP table to hold the basic employee information, and it looks something like


7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7902 FORD ANALYST 7566 03-DEC-81 3000 20


Notice that some fields in the Commission (COMM) and Manager (MGR) columns do not
contain a value; they are blank. A relational database can enforce the rule that fields in a column
may or may not be empty. [3]In this case, it makes sense for an employee who is not in the Sales
department to have a blank Commission field. It also makes sense for the president of the
company to have a blank Manager field, since that employee doesn't report to anyone.


The smallest piece of information that can be retrieved by the database query
language. A field is found at the intersection of a row and a column in a database table.
On the other hand, none of the fields in the Employee Number (EMPNO) column are blank.
The company always wants to assign an employee number to an employee, and that number must
be different for each employee. One of the features of a relational database is that it can ensure
that a value is entered into this column and that it is unique. The EMPNO column, in this case, is
the primary key of the table.
Primary Key

A column (or columns) in a table that makes the row in the table
distinguishable from every other row in the same table.
Notice the different datatypes that are stored in the EMP table: numeric values, character or

alphabetic values, and date values.
As you might suspect, the DEPTNO column contains the department number for the
employee. But how do you know what department name is associated with what number?
Scott created the DEPT table to hold the descriptions for the department codes in the EMP
The DEPTNO column in the EMP table contains the same values as the DEPTNO column
in the DEPT table. In this case, the DEPTNO column in the EMP table is considered a foreign
key to the same column in the DEPT table.
A foreign key enforces the concept of referential integrity in a relational database. [4]The
concept of referential integrity not only prevents an invalid department number from being
inserted into the EMP table, but it also prevents a row in the DEPT table from being deleted if
there are employees still assigned to that department.
Foreign Key

A column (or columns) in a table that draws its values from a primary or
unique key column in another table. A foreign key assists in ensuring the data integrity of a table.
Referential Integrity

A method employed by a relational database system that enforces
one-to-many relationships between tables.

Before Scott created the actual tables in the database, he went through a design process known
as data modeling. In this process, the developer conceptualizes and documents all the tables for the
database. One of the common methods for modeling a database is called ERA, which stands for
entities, relationships, and attributes. The database designer uses an application that can maintain
entities, their attributes, and their relationships. In general, an entity corresponds to a table in the
database, and the attributes of the entity correspond to columns of the table.
Data ModelingA process of defining the entities, attributes, and relationships between the
entities in preparation for creating the physical database.
The data-modeling process involves defining the entities, defining the relationships between
those entities, and then defining the attributes for each of the entities. Once a cycle is complete, it
is repeated as many times as necessary to ensure that the designer is capturing what is important
enough to go into the database. Let's take a closer look at each step in the data-modeling process.


First, the designer identifies all of the entities within the scope of the database application.
The entities are the persons, places, or things that are important to the organization and need to be
tracked in the database. Entities will most likely translate neatly to database tables. For example,
for the first version of Scott's widget company database, he identifies four entities: employees,
departments, salary grades, and bonuses. These will become the EMP, DEPT, SALGRADE, and
BONUS tables.

Once the entities are defined, the designer can proceed with defining how each of the
entities is related. Often, the designer will pair each entity with every other entity and ask, "Is
there a relationship between these two entities?" Some relationships are obvious; some are not.
In the widget company database, there is most likely a relationship between EMP and DEPT,
but depending on the business rules, it is unlikely that the DEPT and SALGRADE entities are
related. If the business rules were to restrict certain salary grades to certain departments, there
would most likely be a new entity that defines the relationship between salary grades and
departments. This entity would be known as an associative or intersection table and would
contain the valid combinations of salary grades and departments.
Associative Table

A database table that stores the valid combinations of rows from two
other tables and usually enforces a business rule. An associative table resolves a many-to-many
In general, there are three types of relationships in a relational database:

The most common type of relationship is one-to-many. This means that
for each occurrence in a given entity, the parent entity, there may be one or more
occurrences in a second entity, the child entity, to which it is related. For example, in the
widget company database, the DEPT entity is a parent entity, and for each department,
there could be one or more employees associated with that department. The relationship
between DEPT and EMP is one-to-many.

In a one-to-one relationship, a row in a table is related to only one or none
of the rows in a second table. This relationship type is often used for subtyping. For
example, an EMPLOYEE table may hold the information common to all employees,
while the FULLTIME, PARTTIME, and CONTRACTOR tables hold information unique
to full-time employees, part-time employees, and contractors, respectively. These entities
would be considered subtypes of an EMPLOYEE and maintain a one-to-one relationship
with the EMPLOYEE table. These relationships are not as common as one-to-many
relationships, because if one entity has an occurrence for a corresponding row in another
entity, in most cases, the attributes from both entities should be in a single entity.

In a many-to-many relationship, one row of a table may be related to
many rows of another table, and vice versa. Usually, when this relationship is

implemented in the database, a third entity is defined as an intersection table to contain
the associations between the two entities in the relationship. For example, in a database
used for school class enrollment, the STUDENT table has a many-to-many relationship
with the CLASS table—one student may take one or more classes, and a given class may
have one or more students. The intersection table STUDENT_CLASS would contain the
combinations of STUDENT and CLASS to track which students are in which classes.

Once the designer has defined the entity relationships, the next step is to assign the attributes
to each entity. This is physically implemented using columns, as shown here for the SALGRADE
table as derived from the salary grade entity.

After the entities, relationships, and attributes have been defined,
the designer may iterate the data modeling many more times. When
reviewing relationships, new entities may be discovered. For example,
when discussing the widget inventory table and its relationship to a
customer order, the need for a shipping restrictions table may arise.
Once the design process is complete, the physical database
tables may be created. [5]Logical database design sessions should not
involve physical implementation issues, but once the design has gone through an iteration or two,
it's the DBA's job to bring the designers "down to earth." As a result, the design may need to be
revisited to balance the ideal database implementation versus the realities of budgets and schedules.

1, leverage  ['li:vəridʒ, 'le-]
n. 手段,影响力;杠杆作用;杠杆效率

2, correlate  ['kɔ:rə,leit]
vi. 关联
vt. 使有相互关系;互相有关系
n. 相关物;相关联的人
adj. 关联的
3, essentially  [i'senʃəli]
adv. 本质上;本来
4, hypothetical  [,haipəu'θetikəl]
adj. 假设的;爱猜想的
5, entrepreneur  [,ɔntrəprə'nə:]
n. 企业家
6, incentive  [in'sentiv]
a. 刺激的,鼓励的
n. 刺激,鼓励,动机
7, integrity  [in'teɡrəti]
n. 完整;正直;诚实;廉正
8, associative 
a. 联合的(相关的,协会的)

Continue reading it-e-34 Structure of the Relational Database






Snap1 Snap2

2: 图片浏览



3: 图片浏览滚动



4: tab页 idTabs

Continue reading jquery实用插件











Continue reading hibernate连接一个数据库服务器中多个数据库


今天偶然看到PostgreSQL的教科书文章 ,老早就听说过它了,这次觉得还比较强大啊,看这几篇文章:





Continue reading 初识PostgreSQL

it-e-33 PostgreSQL

PostgreSQL is an object-relational database management system (ORDBMS) based on
POSTGRES, Version 4.2, developed at the University of California at Berkeley Computer
Science Department. POSTGRES pioneered many concepts that only became available in some
commercial database systems much later.
Features PostgreSQL is an open-source descendant of this original Berkeley code. It
supports SQL92 and SQL99 and offers many modern features:
complex queries
foreign keys
transactional integrity
multiversion concurrency control
Additionally, PostgreSQL can be extended by the user in many ways, for exampleby
adding new

data types
aggregate functions
index methods
procedural languages
And because of the liberal license, PostgreSQL can be used, modified, and distributed by
everyone free of charge for any purpose, be it private, commercial, or academic.

Advantages PostgreSQL offers many advantages for your company or business over other
database systems.
1) Immunity to over-deployment
Over-deployment is what some proprietary database vendors regard as their #1 licence
compliance problem. With PostgreSQL, no-one can sue you for breaking licensing agreements,
as there is no associated licensing cost for the software.
This has several additional advantages:
More profitable business models with wide-scale deployment.
No possibility of being audited for license compliance at any stage.
Flexibility to do concept research and trial deployments without needing to include
additional licensing costs.
2) Better support than the proprietary vendors
In addition to our strong support offerings, we have a vibrant community of PostgreSQL
professionals and enthusiasts that your staff can draw upon and contribute to.
3) Significant saving on staffing costs
Our software has been designed and created to have much lower maintenance and tuning
requirements than the leading proprietary databases, yet still retain all of the features, stability,
and performance.
In addition to this our training programs are generally regarded as being far more cost
effective, manageable, and practical in the real world than that of the leading proprietary database
4) Legendary reliability and stability
Unlike many proprietary databases, it is extremely common for companies to report that
PostgreSQL has never, ever crashed for them in several years of high activity operation. Not
even once. It just works.
5) Extensible
The source code is available to all at no charge. If your staff have a need to customise or
extend PostgreSQL in any way then they are able to do so with a minimum of effort, and with no
attached costs. This is complemented by the community of PostgreSQL professionals and
enthusiasts around the globe that also actively extend PostgreSQL on a daily basis.
6) Cross platform
PostgreSQL is available for almost every brand of Unix (34 platforms with the latest stable
release), and Windows compatibility is available via the Cygwin framework. Native Windows
compatibility is also available with version 8.0 and above.
7) Designed for high volume environments
We use a multiple row data storage strategy called MVCC to make PostgreSQL extremely
responsive in high volume environments. The leading proprietary database vendor uses this
technology as well, for the same reasons.
8) GUI database design and administration tools

Several high quality GUI tools exist to both administer the database (pgAdmin, pgAccess)
and do database design (Tora, Data Architect).


1, teller  ['telə]
n. (美)出纳员;讲述者;讲故事者;计票员

2, reservation  [,rezə'veiʃən]
n. 预约,预订;保留
3, at will 
4, pioneer  [,paiə'niə]
n. 先锋;拓荒者
vt. 开辟;倡导;提倡
vi. 作先驱

5, proprietary  [prə'praiətəri]
a. 专利的(所有的)
n. 所有权(所有人)

6, globe  [gləub]
n. 地球,地球仪,球体

7, volume  ['vɔlju:m; (US) -jəm]
n. 体积,容量,音量
n. 卷,册

Continue reading it-e-33 PostgreSQL

mongoDB 笔记


java driver下载:





mongod --port 13668 --logpath D:/mongodb-win32-i386-1.8.1/log/mongo.log --logappend --dbpath D:/mongodb-win32-i386-1.8.1/data --directoryperdb --serviceName MongoDb_181 –install

注意建议不要使用参数 --bind_ip ,这样的话只能通过127.0.0.1来连接,使用局域网ip和localhost则不能连上


mongod --serviceName MongoDb_181  --remove

如果不需要作为服务,去掉上面的命令中的—install 和 --serviceName  参数即可


mongod  --port 13668 --logpath D:/mongodb-win32-i386-1.8.1/log/mongo.log --logappend --dbpath D:/mongodb-win32-i386-1.8.1/data –directoryperdb


--logpath 参数必须是个文件,不能是文件夹

--dbpath 所指向的文件夹必须已经存在,否则安装成功却启动不了,总是重复启动--失败


更多命令参数见    --help










对应的客户端命令则是mongo --port 13668



use 命令可切换到指定数据库,不存在的话就会创建一个,但不是马上创建,而是在插入数据时创建。






使用java 见

它的依赖很简单,只要添加驱动依赖包就可以say hello world!了:

>public class HelloWorls { public HelloWorls() { } public static void main(String[] args) { try { Mongo m = new Mongo( "192.168.666.666" , 13668 );

Continue reading mongoDB 笔记

it-e-32 Introduction to DBMS

A database management system (DBMS) is an important type of programming system, used
today on the biggest and the smallest computers. [1]As for other major forms of system software,
such as compilers and operating systems, a well-understood set of principles for database
management systems has developed over the years, and these concepts are useful both for
understanding how to use these systems effectively and for designing and implementing DBMS's.
DBMS is a collection of programs that enables you to store, modify, and extract information
from a database. There are many different types of DBMS's, ranging from small systems that run
on personal computers to huge systems that run on mainframes. The following are the location of
database between application programs and end-users.

There are two qualities that distinguish database management systems from other sorts of
programming systems.
1) The ability to manage persistent data, and
2) The ability to access large amounts of data efficiently.

Point 1) merely states that there is a database which exists permanently; the contents of this
database is the data that a DBMS accesses and manages.

Point 2) distinguishes a DBMS from a
file system, which also manages persistent data. A DBMS's capabilities are needed most when
the amount of data is very large, because for small amounts of data, simple access techniques,
such as linear scans of the data, are usually adequate.
[2]While we regard the above two properties of a DBMS as fundamental, there are a number
of other capabilities that are almost universally found in commercial DBMS's. These are:
Support for at least one data model, or mathematical abstraction through which the user can
view the data.

Support for certain high-level languages that allow the user to define the structure of data,
access data, and manipulate data.
Transaction management, the capability to provide correct, concurrent access to the database
by many users at once.
Access control, the ability to limit access to data by unauthorized users, and the ability to
check the validity of data.
Resiliency, the ability to recover from system failures without losing data.
Data Models Each DBMS provides at least one abstract model of data that allows the user
to see information not as raw bits, but in more understandable terms. In fact, it is usually possible
to see data at several levels of abstraction. At a relatively low level, a DBMS commonly allows
us to visualize data as composed of files.
Efficient File Access The ability to store a file is not remarkable: the file system associated
with any operating system does that. The capability of a DBMS is seen when we access the data of
a file. For example, suppose we wish to find the manager of employee "Clark Kent". If the
company has thousands of employees, It is very expensive to search the entire file to find the one
with NAME="Clark Kent". A DBMS helps us to set up "index files," or "indices," that allow us to
access the record for "Clark Kent" in essentially one stroke no matter how large the file is. Likewise,
insertion of new records or deletion of old ones can be accomplished in time that is small and
essentially constant, independent of the file’s length. Another thing a DBMS helps us do is navigate
among files, that is, to combine values in two or more files to obtain the information we want.
Query Languages To make access to files easier, a DBMS provides a query language, or
data manipulation language, to express operations on files. Query languages differ in the level of
detail they require of the user, with systems based on the relational data model generally
requiring less detail than languages based on other models.

Transaction Management

Another important capability of a DBMS is the ability to
manage simultaneously large numbers of transactions, which are procedures operating on the
database. Some databases are so large that they can only be useful if they are operated upon
simultaneously by many computers: often these computers are dispersed around the country or
the world. The database systems used by banks, accessed almost instantaneously by hundreds or
thousands of automated teller machines (ATM), as well as by an equal or greater number of
employees in the bank branches, is typical of this sort of database. An airline reservation system
is another good example.
Sometimes, two accesses do not interfere with each other. For example, any number of
transactions can be reading your bank balance at the same time, without any inconsistency. [3]But
if you are in the bank depositing your salary check at the exact instant your spouse is extracting
money from an automatic teller, the result of the two transactions occurring simultaneously and
without coordination is unpredictable. Thus, transactions that modify a data item must “lock out”
other transactions trying to read or write that item at the same time. A DBMS must therefore
provide some form of concurrency control to prevent uncoordinated access to the same data item

by more than one transaction.
Even more complex problems occur when the database is distributed over many different
computer systems, perhaps with duplication of data to allow both faster local access and to
protect against the destruction of data if one computer crashes.
Security of Data A DBMS must not only protect against loss of data when crashes occur,
as we just mentioned, but it must prevent unauthorized access. For example, only users with a
certain clearance should have access to the salary field of an employee file, and the DBMS must
be able associate with the various users their privileges to see files, fields within files, or other
subsets of the data in the database. Thus a DBMS must maintain a table telling for each user
known to it, what access privileges the user has for each object. For example, one user may be
allowed to read a file, but not to insert or delete data; another may not be allowed to see the file at
all, while a third may be allowed to read or modify the file at will.

DBMS Types
Designers developed three different types of database structures: hierarchical, network, and
relational. Hierarchical and network were first developed but relational has become dominant.
While the relational design is dominant, the older databases have not been dropped. Companies
that installed a hierarchical system such as IMS in the 1970s will be using and maintaining these
databases for years to come even though new development is being done on relational systems.
These older systems are often referred to as legacy systems.

1, teller  ['telə]
n. (美)出纳员;讲述者;讲故事者;计票员

2, reservation  [,rezə'veiʃən]
n. 预约,预订;保留
3, at will 

Continue reading it-e-32 Introduction to DBMS


  • 一个业务用例描述的是业务过程——而不是软件系统过程。
  • 一个业务用例为涉众创造价值。这些涉众要么是业务参与者要么是业务工作者。
  • 一个业务用例可以超越组织的边界。有些构架师对于这一点有非常严密的态度。许多业务用例确实超越来组织的边界,但是有些业务用例仅仅关注于一个组织。


  • 1.业务用例就是要完成的业务,系统用例是系统要做的事情,两者的域不同。
  • 2.业务建模主要描述了该项目涉及的所有业务,需求模型主要是描述为了满足业务需求系统要做什么,因此,需求模型与业务模型相比,它描述的只是业务模型的一个子集。
  • 3.比方说我们设计一个自动提款机系统,它可以满足用户的取款、改密、查询等需求,那么这些需求就是业务用例;但是用户又分为借记卡用户和信用卡用户,那么根据业务规则,不同的卡用户的取款、改密、查询的过程是不一样的,所以系统为了满足这种业务需求会包含到两个子用例里实现,这种子用例就是系统用例。也就是说系统用例就是系统为了满足这种业务需求要做什么。






Continue reading 业务用例与系统用例的区别

it-e-31 Steganography and Honeytokens

Steganography is a method of embedding electronic messages into a media file (for example, an image or audio file) by altering nonessential lines of code; the changes are imperceptible. The message remains undetected until unencrypted. Honeytokens is any kind of tantalizing false data, including phony patient records at a hospital, lists of invalid social security numbersor even simply a word processing file named "HR-salaries," that's stored in a restricted part of the network. If anyone tries to access the files the security team is alerted to the trespassing before the intruder can do any real damage.

1, imperceptible  [,impə'septəbl]
a. 不能感知的,不知不觉的,微细的

2, steganography  [,stegə'nɔgrəfi]
n. 速记式加密
3, tantalizing  ['tæntəlaiziŋ]
a. 诱人的
4, phony  ['fəuni]
a. 假的,伪造的
5, trespassing 
n. 擅自进入
v. 侵入;犯罪(trespass的ing形式)
6, intruder  [in'tru:də]
n. 侵入者,干扰者,妨碍者

Continue reading it-e-31 Steganography and Honeytokens


Total views.

© 2013 - 2020. All rights reserved.

Powered by Hydejack v6.6.1