Академический Документы
Профессиональный Документы
Культура Документы
You may also find interest in reading 'A Relational Model of Data for Large Shared
Data Banks' by E.F. Codd himself (the founder/co-founder of the relational theory):
A Relational Model of Data for Large Shared Data Banks
Notations in graphic examples.
Throughout this eBook, we will be using logical models; Entity Relationship
diagrams, as well as physical models; what is called Server diagrams in Oracle
Designer. We will also exemplify the different constructions with SELECT
statements where appropriate. First, a few words about notation in the logical
model:
Fig. 2:
In this figure, a # in front of an attribute means the attribute is (part of) the
primary key. Likewise is the horizontal bar over the crow-foot in the drawing of the
relationship between departments and accounts a sign that the primary key from
departments is also a part of the primary key in the accounts entity. How smart
that is, is a totally different issue: (ACCOUNTS is breaking 2nd Normal Form:
Name is dependent on ACCOUNT_NO alone, not DEPT_ID).
A * in front of an attribute signs that this attribute is mandatory (always must
have a value filled in), while an o in front of an attribute tells that it is optional to
give the attribute a value. Likewise with the physical model:
Fig. 3:
Notice the difference between the two graphics: in the physical model in Fig.3, the
relationship in Fig. 2 is incorporated in the accounts table. The relationship in Fig.
3 now indicates that there exists an unconditional constraint between the two
tables: You are not allowed to enter a value into DEPT_ID in accounts if it doesn't
exist in the departments table. The horizontal line above the crow-bar does not
necessarily indicate participation in the primary key of that table: only the # tells
you if a column is a part of the primary key.
By the way, Fig. numbers do not start at Fig. 1, because this is just an excerpt
from the eBook. you can check it out here: Primary and Foreign Keys.
We have also used the plural form on entity names as well as table names. The
normal is singular form for entities, and plural for tables. We have done this
exception for reading purposes only.
Details on uniqueness
A primary key is, as stated earlier in post 1, a column, or a collection of columns,
that together give us the ability to uniquely read one single row from a table, no
matter how many rows that exists in that table. In the logical world this is just
theory, but in the physical, we get into a lot of trouble if we are unable to do that.
Consider a simple example:
You want to give a 10% pay raise to your top DBA, John Wilson.
You do that by writing:
UPDATE EMPLOYEES
SET SALARY = SALARY * 1.1
WHERE NAME = 'John Wilson';
If you have two employees with that name, they both get a pay raise. Not exactly
what you intended...