























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
























What is a Database?
The portion of the real world relevant to the database is sometimes referred to as the universe of discourse or as the database miniworld. Whatever it is called, it must be well understood by the designers of the database.
What Does a DBMS Do?
**- allow concurrency
Who Interacts with a DBMS?
**- systems analysts
Relational Database Model
- a database that treats all of its data as a
**- a kind of set
Basic Set Concepts
Basic Set Concepts
As this ellipsis indicates, sets can be infinite in size. However, sets that are actually represented in a database must be finite.
Basic Set Concepts
Relation: Subset of a Cartesian Product
A relation, therefore, must always be representable as a subset of some Cartesian product.
A Cartesian product pairs every member of the first set with every member of the second set.
A relation pairs some members of the first set with some members of the second set.
Relation: Set of Ordered Tuples
By adding sets, relations can be extended to include ordered triples, ordered quadruples or, in general, any ordered n-tuple, as below. A relation with n participating sets is said to be of degree n or to possess arity n.
A binary relation is a set of ordered doubles, with one element a member of the first set and one element a member of the second set. Generally, we could represent a set of ordered doubles as below. S 1 is the first set and S 2 the second.
Relations as a Database
The business data file resembles a relation in a number of ways. The tabular file itself corresponds to a relation. Each column, or attribute, in the file corresponds to a particular set and all of the values from a particular column come from the same domain, or set. Each row, or record, in the file corresponds to a tuple
Smith Smith Jones Harris
Robert Judy Greg Lloyd
1154 Elm Street 1154 Elm Street 765 Cedar Lane 2323 Maple Dr
Glendale Glendale Towson Towson
MD MD MD MD
21200 21200 21232 21232
L. F. G. K.
Ziegler Fred K. 7272 Cherry Ln. Baltimore MD 21208
Name-L Name-F MI address city state zip
If such a file is to be genuinely interchangeable with a relation, certain contraints must be met:
Relations as a Database
P- P- P- P-
P-
123-45- 001-32- 444-44- 555-12-
888-88-
Smith Pedersen Wilson Grant
MacPherson
123 Main Street 1700 Cedar Barn Way 1321 North South St 808 Farragut Avenue
1617 Pennsylvania Ave
10 MAY 44 31 MAR 59 7 AUG 90 1 DEC 66
11 APR 60
patient # SS # Last Name address birth date
An essential attribute of a relation is that every tuple must be unique. This means that the values present in some individual attribute (or set of attributes) must always provide enough information to allow a unique identification of every tuple in the relation. In a relational database, these identifying values are known as key values or just as the key.
Sometimes more than one key could be defined for given table. For example, in the table below (which represents, perhaps, a patient record file), several columns might serve as a key. Either patient number (assigned by the hospital) or social security number (brought with the patient) are possibilities. In addition, one might argue that the combination of last name, address, and birth date could collectively serve as a key.
Any attribute or set of attributes that might possibly serve as a key is known as a candidate key. Keys that involve only one attribute are known as simple keys. Keys that involve more than one attribute are composite keys.
In designing a database, one of the candidate keys for each relation must be chosen to be the primary key for that table. Choosing primary keys is a crucial task in database design. If keys need to be redesignated, the entire system may have to be redone. Primary keys can never be null and should never be changed. Sometimes none of the candidate keys for a relation are likely to remain stable over time. Then, an arbitrary identifier might be created to serve as a primary key. Such arbitrary keys are also known as surrogate keys.
Yet another relation could be used to show what faculty were members of what departments. Notice that faculty member 999-99-9999 is a member of more than one department and that, even on this short list, the department of zoology has two members given.
- • • other fields SS Number çç Faculty Relation
Member-of Relation èè SS Number Dept Code
Departments Relation èè Dept Code other fields • • •
Relations of this sort, that combine identifiers from two other relations, provide the “glue” that holds a relational database together.
Relations as a Database
Whenever the values in an attribute column in one table “point to” primary keys in another (or the same) table, the attribute column is said to be a foreign key. Columns containing foreign keys are subject to an integrity constraint : any value present as a foreign key must also be present as a primary key.
999-99- 888-88- 7777-77- 666-66-
999-99-
ZOL PSD CPS ZOL
BSP
Relational Database Operators
**- Cartesian product
**- select
**- outer join