Upload
gourav-kottawar
View
223
Download
0
Embed Size (px)
Citation preview
Overview of Database Concepts
Chapter Objectives
• Identify the purpose of a database management system (DBMS)
• Distinguish a field from a record and a column from a row
• Identify the basic components of an Entity-Relationship Model
• Define the three types of relationships that can exist between entities
Chapter Objectives
• Identify the problem associated with many-to-many relationships and the appropriate solutions
• Explain the purpose of normalization• Describe the role of a primary key • Identify partial dependency and transitive
dependency in the normalization process
Chapter Objectives
• Explain the purpose of a foreign key • Determine how to link data in different
tables through the use of a common field• Explain the purpose of a structured query
language (SQL)
Database Terminology
• Database – logical structure to store data
• Database Management System (DBMS) – software used to create and interact with the database
Database Components
• Character• Field• Record• File
Database Components - Character
• Basic unit of data• Can be a letter, number, or special symbol
Database Components - Field
• A group of related characters• Represents an attribute or characteristic of
an entity• Corresponds to a column in the physical
database
Database Components - Record
• A collection of fields for one specific entity• Corresponds to a row in the physical
database
Database Components - File
• A group of records about the same type of entity
Components Example
Review of Database Design
• Systems Development Life Cycle (SDLC)• Entity-Relationship Model (E-R Model)• Normalization
Systems Development Life Cycle (SDLC)
• Systems investigation – understanding the problem
• Systems analysis – understanding the solution
• Systems design – creating the logical and physical components
Systems Development Life Cycle (SDLC)
• Systems implementation – placing completed system into operation
• Systems maintenance and review – evaluating the implemented system
Entity-Relationship Model (E-R Model)
• Used to depict the relationship that exists among entities
E-R Model Symbols
Relationships
• The following relationships can be included in an E-R Model:– One-to-one– One-to-many– Many-to-many
One-to-one Relationship
• Each occurrence of data in one entity is represented by only one occurrence of data in the other entity
• Example: Each individual has just one Social Security Number (SSN) and each SSN is assigned to just one person
One-to-many Relationship
• Each occurrence of data in one entity can be represented by many occurrences of the data in the other entity
• Example: A class has only one instructor, but each instructor can teach many classes
Many-to-many Relationship
• Data can have multiple occurrences in both entities
• Example: A student can take many classes and each class is composed of many students
Example E-R Model
Normalization
• Determines required tables and columns for each table
• Multi-step process allows designer to take the raw data to be collected about an entity
• Used to reduce or control data redundancy
Attributes of Books• isbn : a value string used to identify any book.• Title: Book’s title• Publication Date: A value of DATE type.• Cost: Publisher’ price• Retail: Sale’s price.• Category: Computer, Fiction Science, etc.• Publisher: Publisher’ house.• Contact: Sale representative.
Representation of Books
Unnormalized Data
Contains repeating groups in the Author column in the BOOKS table
First-Normal Form (1NF)
• Primary key is identified. A Primary key is a field that serves to uniquely identify each record.
• Repeating groups are eliminated (each entry a separated record).
First-Normal Form (1NF)
ISBN and Author columns together create a composite primary key
Composite Primary Key
• More than one column is required to uniquely identify a row
• When a primary key consists of more or one field, another problem may occurs--- partial dependency - a column/ns is/are only dependent on a portion of the primary keyThe fields describing the book depend of the book itself not upon who wrote.
Second-Normal Form (2NF)
• Partial dependency must be eliminated– Break the composite primary key into
two parts, each part representing a separate table (for example, Author)
Second-Normal Form (2NF)
BOOKS table in 2NF
Third-Normal Form (3NF)
Publisher contact name has been removed
Summary of Normalization Steps
• 1NF: eliminate repeating groups, identify primary key
• 2NF: table is in 1NF and partial dependencies eliminated
• 3NF: table is in 2NF and transitive dependencies eliminated
Linking Tables
• Once tables are normalized, make certain tables are linked
• Tables are linked through a common field• A common field is usually a primary key in
one table and a foreign key in the other table
Graphical Representation for Books
Column Name ISBN Title Publication Date
Cost Retail Category PublId
Key Type PK FK1
Null/Unique
NN,U NN
FK RefTable
Publisher
FK Ref Columns PublId
Data type CHAR CHAR DATE NUMBER NUMBER CHAR NUMBER
Maximum Length
10 35 11 11 25 5
Sample Data 8843172113 DATABASE 11/AGO/2003 69.75 89.75 computers 1234
Lab # 1
• Find the graphical representations of tables considered in the Pet Shop.
Specialization
• Top-down design process; we designate subgroupings within an entity set that are distinctive from other entities in the set.
• These subgroupings become lower-level entity sets that have attributes or participate in relationships that do not apply to the higher-level entity set.
• Depicted by a triangle component labeled ISA (E.g. customer “is a” person).
• Attribute inheritance – a lower-level entity set inherits all the attributes and relationship participation of the higher-level entity set to which it is linked.
Generalization
• A bottom-up design process – combine a number of entity sets that share the same features into a higher-level entity set.
• Specialization and generalization are simple inversions of each other; they are represented in an E-R diagram in the same way.
• The terms specialization and generalization are used interchangeably.
UML
• UML: Unified Modeling Language• UML has many components to graphically
model different aspects of an entire software system
• UML Class Diagrams correspond to E-R Diagram, but several differences.
Structured Query Language (SQL)
• Data sublanguage • Used to:
– Create or modify tables– Add data to tables– Edit data in tables– Retrieve data from tables