By Stéphane Faroult, Peter Robson
Book Price: $44.99 USD
£31.99 GBP
PDF Price: $31.99
Joseph de Maistre (1754-1821)
Lettre du 27 Juillet 1812
à Monsieur le Comte de FrontC'est le premier pas qui, dans toutes les guerres, décèle le génie.It is the first step that reveals genius in all wars.
order_completed). You should aim for
increasing the density of your data--order_completed may be useful information to
know, but then perhaps other information would be nice to store too:
when was it completed? Who completed it? So that means that instead of
having a single "Y/N" column, we can have a completion_date column, and perhaps a completed_by column, both of which will tell
us more (although we may not necessarily want to see a null value as
long as the order isn't completed; a solution may be to use a distinct
table to track the various stages of every order from creation to
completion). As before, examine the dependencies in the context of your
business requirements, and only include those additional columns where
the successful operation of the business requires it.status attribute. For instance, if you have
four attributes that can be either true or false, you can assign a
numerical value between 0 and 15 to each of the possible combinations
and define the "status" as being represented by this value. But
beware—this technique may offend the basic rule of atomicity, so if you
must use this approach, do so with considerable caution.employee table contains all
information that is common to every employee, regardless of their
status. However, an attribute tells the status of each employee. It has
as many distinct values as there are distinct employee types, for
example "P" (for permanent employee), and "C" (for contract employee).
This table uses an employee number as the primary key.permanent and contract represent subtypes of the table
employee, for example. Each permanent
or contract employee inherits certain characteristics from the employee table, in addition to possessing
unique characteristics, as defined in their own tables.employee is the union of the primary
keys of the various subtype tables, and the intersection of the primary
keys of all subtype tables is by construction empty, because each
employee belongs to just one, in this case, of the two categories. The
primary keys of subtype tables are also foreign keys, referencing the
primary key of configuration(parameter_name,
parameter_value), but rather use a generic table configuration(parameter_id, parameter_name,
parameter_type) and have as many subtypes as we have parameter
types. If we use, for instance, configuration_numeric(parameter_id,
parameter_value), where parameter_value is a numeric column, any
mistyping of the letter "O" instead of zero will be detected by the DBMS
when the configuration is changed, instead of resulting in a runtime
error when the parameter is used.entity_id,
attribute_id, attribute_value. In this "design," everything
is stored as a character string into attribute_value. The design certainly avoids
the risk of having null values. However, the proponents of this type of
design usually store the mandatory attributes in attribute_value as well. Their mantra, by the
way, is usually that this design approach makes it easy to add new
attributes whenever they are needed. Without commenting on the quality
of a design that makes it necessary to anticipate the necessarily
haphazard addition of attributes, let's just remark that it's all very
nice to store data, but usually, somehow, one day you will have to
retrieve and process that same data (if data retrieval is not being
planned, there is something seriously wrong somewhere). Adding a column
to a table really pales into insignificance when compared to writing a
program to do something useful with the new bits of information that you
are given to manage (as enthusiasts that praise the flexibility of the
Extensible Markup Language [XML] are bound to understand).article_id. An obvious way to do so
is to store the following items:(article_id, effective_from_date, price)
effective_from_date is
the date when the new price takes effect, and the primary key of the
historical table is (article_id,
effective_from_date).effective_from_date, and it will be retrieved
by running a query looking like: select a.article_name, h.price
from articles a,
price_history h
where a.article_name = some_name
and h.article_id = a.article_id
and h.effective_from_date =
(select max(b.effective_from_date)
from price_history b
where b.article_id = h.article_id)Général Antoine-Henri de Jomini (1779-1869)
Précis de l'Art de la GuerreIl existe un petit nombre de principes fondamentaux de la guerre, dont on ne saurait s'écarter sans danger, et dont l'application au contraire a été presque en tous temps couronnée par le succès.There exist a small number of fundamental principles of war, which it is dangerous to ignore: indeed, following these principles has almost invariably led to success.
/* CUSTOMER REGISTRATION */ select blah ...
dbms_application_info
package allows you to register a program using a 48-character module
name, a 32-character action name, and a 64-character client information
field. The content of those fields is left to your discretion. In an
Oracle environment, you can use this package to keep track not only of
which application is running, but also what that application is doing at
any given time. This is because you can easily query the information
that your application passes to the package through the Oracle V$
dynamic views that show what is currently happening in memory. Open the file
Until the end of file is reached
Read a row
Connect to the server specified by the row
Insert the data
Disconnect
Close the fileinsert statement. I mentioned in
passing to the customer the existence of direct-loading techniques
that are even faster.Test | Results |
|---|---|
Connect/disconnect for each line in
turn |
from
clause with a union operator would
allow the aggregation of all the various sources. A single truncate table, which is a very fast
way of emptying a table of all rows (without the protection of rollback recovery,
remember!).update or delete operations against a database —and assuming one is not operating against the entire
table contents—one has to define precisely the set of rows in that table
that will be affected by the process. This defines the
granularity of the impending process, which may be described as
coarse if a large number of rows will be affected
or as fine if only few rows will be
involved.rollback, and second, take a very long time to
rollback if any attempted change should fail. Many people would argue
that where very considerable changes are to be made, regular commit statements should be scattered
throughout the data manipulation language (DML) code. However, regular
commit statements may not help when
resuming a file upload that has failed. From a strictly practical
standpoint, it is often much easier, simpler, and faster to resume a
process from the start rather than try to locate where and when the
failure occurred and then to skip over what has already been
committed.count(*) for no purpose other than to
implement an existence test. This usually happens as a result of a
specification such as: If there are rows meeting a certain condition
Then do something to them select count(*)
into counter
from table_name
where <certain_condition>
if (counter > 0) thencount(*) is totally unnecessary and
superfluous, as in the above example. If an action is required to
operate on a number of rows, just do it. If no row is affected, so what?
No harm is done. Moreover, if the process to be applied to those
hypothetical rows is complex, the very first operation will tell you how
many of them were affected, either in a system variable (@@ROWCOUNT with Transact-SQL, SQL%ROWCOUNT with PL/SQL, and so forth), in a
special field of the SQL Communication Area (SQLCA) when using embedded SQL, or through special APIs such as
mysql_affected_rows( ) in PHP. The
number of processed rows is also sometimes directly returned by the
function, which interacts with the database, such