Hierarchy of Data: Database File

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 40

Hierarchy of Data

Database

File

Record

Field

Byte

Bit
File Organization - Hierarchy of
Data
• Bit
– Smallest amount of data a computer can
read
– Bits are read as the Binary digits 1 and
0
• Translated into ON or OFF - YES or NO
– Eight bits make one Byte.
File Organization - Hierarchy of
Data
• Byte
– Eight bits make up one Byte.
– A byte makes up a character
• Letters or Numbers like 1 or A
– Several characters make up a word
• Persons name, address, age.
File Organization - Hierarchy
of Data
• Field
– Words made up of characters
(bytes) produce what is known as a
field.
– Represents a piece of data
• Name, address, account number
File Organization - Hierarchy
of Data
• Record
– Collection of related fields
• Clients Contact Information
– Name, Address, Phone, E-mail,
Company
File Organization - Hierarchy
of Data
• File
– Collection of related records.
• A collection of records or documents
dealing with one organization, person,
area or subject.
– Manual (paper) files
– Computer files
Database
– A collection of related data with an
implicit meaning. A collection of similar
records with relationships between the
records.
– Properties of database
• Changes to real world related to database is
reflected in database .
• Is a logically coherent collection of data with some
inherent meaning .
• A database is built , designed and populated with
data for a specific purpose.
Traditional File Environment
Problems with Traditional File
systems
• Data redundancy – same piece of data
found in several places.
• Data inconsistency – various copies of
data no longer agree.
• Difficulty in accessing data
• Data Integrity – constraints to be
satisfied
• Data isolation – data in several application
data files is hard to access and integrate.
• Security – may be difficult to limit access to
various data items in applications.
Database : The Modern Approach
The database management system provides access to
the data

Database Management System (DBMS)


Advantages of Database
approach
• Improved strategic use of corporate data
• Reduced data redundancy
• Improved data integrity
• Easier modification and updating
• Data and program Independence
• Better access to data and information
• Standardization of data access
• A framework for program development
• Better overall protection of data
• Shared data and information resources
Database management system
• It is a general-purpose software system
that facilitates the process of defining ,
constructing , manipulating and sharing
databases among various users and
applications .
DBMS
===============
Design tools
Table Creation
Form Creation
Query Creation
Report Creation Application
Procedural
Database language
Programs
compiler (4GL)
=============
Run time
Database contains:
Form processor
User’s Data Query processor
User
Metadata Report Writer Interface
Indexes Language Run time Applications
Application Metadata
Database Components
 Data Models
– It defines the way data are conceptually
structured. E.g hierarchical Database
Components, network, relational etc

 Database Languages Data


Definition Language
Data Manipulation Language
Data Control Language
 Data Dictionary
Hierarchical DB
Components
DBMS

Organizes data in a tree-like


structure

Supports one-to-many parent-child


relationships
Network DBMS DB Components

• Depicts data logically as many-to-many


relationships
Relational DBMS
• Represents data as two-dimensional
tables called relations

• Relates data across tables based on


common data element

• Examples: DB2, Oracle, MS SQL Server


DB Components
Relational Data Model
Relational Model Hierarchical Model

common in PC
environment because it is
simple to understand.
provides high flexibility Gives best processing
and ease of use. speeds, but poor query
provides slower search flexibility.
and access times; a
problem in high-volume
business settings.

Network Model
Gives pretty good processing speeds
and pretty good query flexibility, but
is very complex.
Some of the more popular relational
database management systems include:

– Microsoft Access
– Filemaker
– Microsoft SQL Server
– MySQL
– Oracle
DBMS Basics
Database Components:
A Database consists of

••• ••••• •• ••• •• ••• ••• •• ••••


Tables, which contain ••• ••••• •• ••• •• ••• ••• •• ••••
••• ••••• •• ••• •• ••• ••• •• ••••
••• ••••• •• ••• •• ••• ••• •• ••••

Records, which contain


Hernandez, Juan 123456789 72 2.42
Jones, Mary 234567890 102 3.87

Fields, which may consist


of a variety of data types
Notice that there should always be a Key (Unique) Field
Database creation
• To create a database, designers must develop a
conceptual design and a physical design.

• The conceptual design of a database is an


abstract model of the database from the user or
business perspective.

• The physical design shows how the database


is actually arranged on direct access storage
devices.
How a database is structured
• Tables store your data in rows and columns. All
databases contain one or more tables.
• Queries retrieve and process your data. They
can combine data from different tables, update
your data, and perform calculations on your
data.
• Forms control data entry and data views. They
provide visual cues that make data easier to
work with.
• Reports summarize and print your data. They
turn the data in your tables and queries into
documents for communicating ideas.
Tables, the building blocks of
databases
Data types:
• Every field in a table will have a particular
data type. Therefore, the data in each field
will have a data type.

• Data types are characteristics of data .


Text fields
• Use for text or combinations of text and
numbers, such as addresses, or for
numbers that do not require calculations,
such as phone numbers, part numbers,
or postal codes.
• (CHAR—for fixed length , VARCHAR---
for varying length)
• Memo
– Use for lengthy text and numbers, such as
notes or descriptions.
• Numeric fields
• Use for data to be included in
mathematical calculations, except
calculations involving money (use
Currency type).
• Few of the numeric data type values are:
• INTEGER
• FLOAT(P)
• DECIMAL(P,S)
– Date and time field
• Stores date/time entries
– Null values
• It refers to a field in a database table in which no data has
been entered .
– Currency
• Use for currency values and to prevent rounding off during
calculations.
– AutoNumber
• Use for unique sequential (incrementing by 1) or random
numbers that are automatically inserted when a record is
added.
– Boolean values
• Use for data that can be only one of two possible values,
such as Yes/No, True/False, On/Off.
Basic Concepts
• Relational database stores its data in 2-D tables.

• Entity: Person, place, thing, event about which information is


maintained

• Attribute: Description or characteristic of a particular entity


Basic Concepts
• A table is a two-dimensional structure made up of
rows (tuples, records) and columns (attributes,
fields)

Table Characteristics
• each row is unique and stores data about one entity
• each column has a unique attribute name
• all entries in a column have the same data type
• each cell contains atomic data: no lists or sub-tables
• row and column order is unimportant .
Basic Concepts
• A primary key is an attribute or a collection of
attributes whose value(s) uniquely identify each row
in a relation. A table can only have one primary
key . Eg:

StudentID Activity Fee


100 Skiing 200
150 Swimming 50
175 Squash 50
200 Swimming 50
the only possible primary key in the above table is StudentID
Basic Concepts
• Sometimes the primary key can be made up of several
fields .
• such a multi-attribute primary key is called a composite
key or concatenated key : E.g.:

LicensePl State Make Model Year


ate
LVR120 NJ Honda Accord 2003
BCX50P NJ Buick Regal 1998
LVR120 CT Toyota Corolla 2002
908HYY MA Ford Windstar 2001
UHP33X NJ Nissan Altima 2006
•, (LicensePlate, State) is a possible primary key (a candidate key)
A foreign key is an attribute or a collection of attributes
whose value are intended to match the primary key of
some related record (usually in a different table)

galId haloId mStar magB X …

112 6625 0.215 -17.9 7.6 …

113 6625 0.038 -15.6 7.4 …

154 6626 0.173 -17.1 7.65 … haloId fofId Np X vMax …

221 7883 1.20 -20.7 35.1 … 6625 123 100 7.6 165 …

223 7883 0.225 -19.7 35.0 … 6626 123 65 7.9 130 …

225 7883 0.04 -17.5 34.9 … 7883 456 452 35.1 200 …
7884 456 255 35.2 190 …
278 7884 1.54 -19.4 35.2 …
9885 789 30 67.0 110 …
… … … … … …
… … … … … …
Galaxy
SubHalo
Types of relationships:

– One-to-one: a student has one schedule; a


schedule belongs to one student

– One-to-many: a course has one professor; a


professor has one or more courses

– Many-to-many: a student has one or more


courses; a course has one or more students
Show the type of relationship b/n
the entities .
• A student can have many courses.
• A course can have many students.
• A course can have only 1 professor.
• A professor can have many courses.
• A student can have only 1 parking permit.
• A parking permit can have only one
student .
Entity-Relationship Modeling
Normalization of Relational
Databases

• Normalization is a method for analyzing


and reducing a relational database to its
most parsimonious or streamlined form for
• minimum redundancy,
• Maximum data integrity
• Best processing performance.
normalization
• has several goals:
Normalization has several goals:

• Eliminate redundancy caused by fields repeated


within a file or record, attributes that do not
directly describe the entity, and fields that can be
derived from other fields.

• Avoid update anomalies (i.e., errors from


inserting, deleting, and modifying records).

• Represent accurately the item being modeled.

• Simplify maintenance and information retrieval.

You might also like