Database Notes
Database Notes
History:
2. Duplication of data
3. Data dependence
What is a Database?
Data Information
Recorded facts & figures Knowledge derived from data
….With SQL
DBMS Disadvantages
Complexity
• Failure to understand DBMS functionalities can lead to bad
database design decisions
Size
• DBMS can occupy megabytes of disk space and requires
substantial amount of memory
Cost of DBMS
• Cost varies from hundreds to millions
Performance
• DBMS cater for many applications, thus some applications
may not run as fast as they used to
DBMS Advantages
Types of Databases
Database Design
1. Hardware
2. Software
1. Data
2. Procedure
- Instructions & rules that govern the design & the use of
database
- These may consist of instructions on how to:
● Log on to the DBMS.
● Use a particular DBMS facility or application
program.
● Start and stop the DBMS.
● Make backup copies of the database.
● Handle hardware or software failures
3. People
Database Security
- Ensures that only authorized users can perform
authorized activities at authorized times
DBMS Security
Application Security
- Introduced in 1970
- Created by E.F Codd
➢An IBM engineer
➢The model used mathematics known as ‘relational algebra’
➢Now the standard model for commercial DBMS products
Entity
- Customers
- Products
- Sales
- Transactions
Relation
Employee
To Key Or Not to KEY?
Keys
Primary Surrogate
Foreign
- A foreign key is the primary key
of one relation that is placed in
another relation to form a link
between the relations.
- A foreign key can be a single
column or a composite key.
- The term refers to the fact that
key values are foreign to the
relation in which they appear as
foreign key values.
CHAPTER 4: ERD
Features:
• Includes all entities and relationships among them.
• All attributes for each entity are specified.
• The primary key for each entity is specified.
• Foreign keys (keys identifying the relationship between
different entities) are specified.
• Normalization occurs at this level.
The steps for designing the logical data model are as follows:
• Specify primary keys for all entities.
• Find the relationships between different entities.
• Find all attributes for each entity.
• Resolve many-to-many relationships.
• Normalization.
Features:
• Specification all tables and columns.
• Foreign keys are used to identify relationships between tables.
• De-normalization may occur based on user requirements.
• Physical considerations may cause the physical data model to
be quite different from the logical data model.
Versions:
– Original E-R model—by Peter Chen (1976)
– Extended E-R model—later extensions to the Chen model
included subtypes
– Now referred to as the extended E-R model, which is used in
this book when using the term E-R mode
ENTITIES
Something that can be readily
identified and that users want to
track:
– Entity class—a collection of
entities of a given type
– Entity instance—the occurrence of
a particular entity
• There are usually many instances
of an entity in an entity class.
Attributes
describe an entity’s characteristics.
• All entity instances of a given
entity class have the same
attributes, but vary in the values of
those attributes.
• They were originally shown in data
models as ellipses.
• Data modeling products today
commonly show attributes in
rectangular form.
Identifiers
Parent-Child Entities
• In a one-to-many relationship:
– The entity on the one side of the relationship is called the
parent entity or just the parent.
– The entity on the many side of the relationship is called the
child entity or just the child.
• The relationships we have been discussing are known as
HAS-A relationships:
– Each entity instance has a relationship with another entity
instance.
• An EMPLOYEE has one or more COMPUTERs.
• A COMPUTER has one assigned EMPLOYEE.
Minimum Cardinality
Indicating it:
Reading it:
4 Types of
Minimum
Cardinality
Data Modeling Notation: IE Crow’s Foot 1:N
Example 2
Strong vs. Weak Entities
• For each 1:* binary relationship, the entity on the ‘one side’ of
the relationship is designated as the parent entity and the
entity on the ‘many side’ is designated as the child entity.
• To represent this relationship, post a copy of the primary key
attribute(s) of parent entity into the relation representing the
child entity,to act as a foreign key.
Comparison Operators
❑= equals
❑<> is not equal to (ISO standard) ! =
is not equal to (allowed in some
dialects)
❑< is less than < = is less than or
equal to
❑> is greater than > = is greater than
or equal to
Subqueries
DATABASE UPDATE
UPDATING DATA
Normal Form
The relation is in
1NF if every tuple
in that relation
has only atomic
values for each
attribute
How to improve this situation?
Big Data