Rangkuman Konsep Basis Data
Basis Data
• A database-management system (DBMS) is
a collection of
interrelated data
and a set of
programs to
access those data
•
Database
: collection of
data
that contain information relevant to
an enterprise
•
DBMS
provide
a way
to store and
retrieve database
information that
is both
convenient
and
efficient
Database-System Applications
•
Enterprise Information
◦ Sales: For customer, product, and purchase information.
◦ Accounting: For payments, receipts, account balances, assets and other
accounting information.
◦ Human resources: For information about employees, salaries, payroll taxes,
and benefits, and for generation of paychecks.
◦ Manufacturing: For management of the supply chain and for tracking production
of items in factories, inventories of items in warehouses and stores,
and orders for items.
Database-System Applications
•
Banking
and
Finance
◦ Banking: For customer information, accounts, loans, and banking transactions.
◦ Credit card transactions: For purchases on credit cards and generation of
monthly statements.
◦ Finance: For storing information about holdings, sales, and purchases of
financial instruments such as stocks and bonds; also for storing real-time
market data to enable online trading by customers and automated trading
by the firm.
Database System vs File Processing System
•
Data
redundancy
& inconsistency
• different programmers create the files and application programs over a long period
• the
various
files
are
likely to have
different
structures and
the
programs may
be written in
several programming
languages.
•
Moreover, the
same information
may
be duplicated
in several places (files)
•
Difficulty in accessing
data
•
conventional file-processing environments do not allow
needed
data
to be retrieved in a convenient and efficient manner
Superkey
•
Formally, let R
denote the
set of
attributes
in the
schema
of relation r.
•
If we
say that
a subset K
of R
is a superkey
for
r
• we
are
restricting consideration
to instances of
relations r
in which
no two
distinct tuples
have
the same values
on all attributes
in K.
•
That
is, if t1
and
t2 are
in r and t1 != t2, then t1.K !=
t2.K.
Primary Key
• A candidate key
that is chosen by the database
designer
as the
principal
menas
of
identifying tuples
within
a relation
•
A key (whether
primary,
candidate, or super)
is a property
of the entire
relation, rather
than of the individual tuples
•
Any
two
individual tuples
in the
relation are
prohibited
from
having the same value on
the key
attributes
at the
same time.
•
The
designation
of a key represents
a constraint
in the
real-world
enterprise being
modeled
Candidate Key
• A superkey may contain extraneous attributes.
• Eg. the combination of ID and name is a superkey for the relation instructor.
• If K is a superkey, then so is any superset of K.
•
Candidate key : minimal
superkeys
Foreign Key
•
A relation,
say r1,
may include among
its
attributes
the primary key of another relation, say r2.
•
Called a foreign key
from
r1,
referencing r2
•
The
relation r1 is also called
the referencing relation of
the foreign
key dependency
•
r2 is called
the referenced
relation of
the foreign
key
•
Referential
integrity constraints
•
the
values appearing
in specified
attributes
of any tuple
in the
referencing
relation
also
appear in specified
attributes
of at least
one tuple
in the
referenced relation.
Joining two relations – Natural Join
•
Let r
and
s be
relations on schemas
R and S respectively.
Then, the “natural join” of relations R and S is a relation on schema R È S
obtained as follows:
• Consider each pair of tuples tr from r and ts from s.
• If tr and ts have the same value on each of the attributes in R Ç S, add a tuple t to the result, where
• t has the same
value
as tr on r
• t has the same value as ts on s
Symbol (Name)
Example of Use
o (Selection) |
c salary>=SSOOO (instructor) |
Return rows of the input relation that satisfy the predicate. |
|
TI (Projection) |
TI ID, salary (instructor) |
Output specified attributes from all rows of the input relation. Remove duplicate tuples from the output. |
|
~ (Natural Join) |
instructor l><I department |
Output pairs of rows from the two input relations that
have the same value on all attributes that have the same
name. |
|
x (Cartesian Product) |
instructor x department |
Output all pairs of rows from
the two input relations
(regardless of whether or not they have the same values
on common attributes) |
|
u (Union) |
Tinam/instructor) u Tinam/student) |
Output the union of
tuples from the two input relations. |
Komentar
Posting Komentar