Lecture Notes 1(Data Modeling)
-
Upload
herchel-mae-sarmiento-apuyan -
Category
Documents
-
view
84 -
download
3
Transcript of Lecture Notes 1(Data Modeling)
Lecture Notes 1
Data Modeling
1ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT
• Database: A collection of related data.
• Data: Known facts that can be recorded and have an implicit meaning.– An integrated collection of more-or-less permanent data.
• Mini-world: Some part of the real world about which data is stored in a database. For example, student grades and transcripts at a university.grades and transcripts at a university.
• Database Management System (DBMS): A software package/ system to facilitate the creation and maintenance of a computerized database.
• Database System: The DBMS software together with the data itself. Sometimes, the applications are also included.
ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT 2
Evolution of Database System
ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT 3
Ways of storing data
• Files – ancient times (1960)
• Databases
– Hierarchical (1970)
ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT 4
– Hierarchical (1970)
– Network (1970)
– Relational (1980)
– Object (1990)
File terms
– Record
• data items related to a single logical entity (e.g.
a student’s information) or row in a table
– Field
ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT 5
– Field
• a place for a data item in a record (first name
field in a student record) or a column in a table
– File
• a sequence of records of the same type (the
table)
File structures
ID Last First Grade
fieldA file: “STUDENT”
ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT 6
3 Smith Jane A
1 Wood Bob C
2 Kent Chuck B
4 Boone Dan B
ID Last First Grade
record
File organization
• Serial
– new records appended
• Sequential
ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT 7
• Sequential
– records ordered in file, usually according to a
numeric key
File structures
• Serial
– list of entries in
which the order of
entry into the list
3 Smith Jane A
1 Wood Bob C
ID Last First Grade
ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT 8
entry into the list
determines the
order of the list
1 Wood Bob C
2 Kent Chuck B
4 Boone Dan B
File structures
• Sequential
– list of entries
ordered in some 1 Wood Bob C
ID Last First Grade
ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT 9
ordered in some
way (e.g.
numerically or
alphabetically)
1 Wood Bob C
2 Kent Chuck B
3 Smith Jane A
4 Boone Dan B
Problems with files
– Redundancy
• number of files grows with applications, and data is duplicated
– Inconsistency
• data is updated in one application’s files, but not in
ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT 10
application’s files, but not in another’s
– Maintenance problems
• changes to data structures mean changes to many programs
– Difficulty combining data
• business needs may mean users want data from different applications
Data Modeling
• It is essential to building a good database.
• refers to the process where by data is
structured and organized.
• Once data is structured, it is usually then • Once data is structured, it is usually then
implemented into what is called a database
management system. The main idea behind
these systems to manage vast amounts of
both structured and unstructured data.
ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT 11
– Unstructured data include documents, word processing, e-mail messages, pictures, and digital video and audio files.
– Structured data, what is needed to make a data model (via a data model theory), is found in management systems like relational databases.
• Data Model• Data Model
– representations of different entity classes that a company wants to possess information about, containing the specifics behind that information, and the relationship among the differing entities and attributes.
ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT 12
– Both the blueprint and the foundation
– A representation of reality, a way to graphically
plot your data requirements
– A visual model of what your database can look like
when you get it implemented.
– the hardest and most important activity in the – the hardest and most important activity in the
RDBMS world. If you get the data model wrong,
your application might not do what users need, it
might be unreliable, it might fill up the database
with garbage.
ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT 13
Phases of Data Modeling
1. Conceptual Design Phase– Describes the concept of the database
– Graphically represents the data and information needs of the business
– Represents what the database can do and will do, – Represents what the database can do and will do, but not how it does it
– Will not show processes or activities related to the data
– Database designer uses an entity relationship diagram
– Vendor neutral and technology independent
ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT 14
Phases of Data Modeling
2. Logical Design Phase
– You begin to convert or map the conceptual ERD to a more complete set of entities that begin to resemble tables.
– You also test to make sure the tables you – You also test to make sure the tables you designed are in third normal form or better, and you make decisions on record modification behavior
– Should also be technology and vendor independent
ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT 15
Phases of Data Modeling
3. Physical Design Phase
– The logical model is converted to a specific
product platform
– Technology dependent– Technology dependent
– Sometimes designers combine the physical
design phase with the physical implementation
phase, the result brings a test database with a
set of tables representing the database entities
ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT 16
Common Data Models
• Hierarchical
• Network
• Relational
• Object• Object
ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT 17
Hierarchical database model
18ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT
Hierarchical data model
ClassParent-child relationship (one-to-one or
Student
Grade
Instructor
ID
(one-to-one or one-to-many) among data
Department
19ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT
Hierarchical data model
• Advantages
– easy to search
– add new branches easily
• Disadvantages
– must establish the types of search prior to
development of the hierarchical structure
20ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT
Network data model
21ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT
Network data model
ClassOne-to-one, one-to-many, many-to-one, or
Student
Grade
Instructor
ID
many-to-one, or many-to-many relationships possible
Department
22ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT
Network data model
• Advantages
– flexible, fast, efficient
• Disadvantages
– Complex– Complex
– restructuring can be difficult because of
changing all the pointers
23ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT
Relational database model
• Stores both
– Data about real
world objects world objects
(entities) in tables
– Relationships
between the
tables
24ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT
Relational database
• Fields (columns) in the table store attributes. – Each attribute has a specific
domain.
• Tuples (or records or rows) in the table store
• Tuples (or records or rows) in the table store information. – Each tuple is a unique
instance of an object.
• Tables are composed of a set of tuples. – A table is also called a
relation.
25ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT
Terms
• Table
– A collection of relevant data relating to one type of real world objects.
• Column
– A specific place for one type of data relating to one type of real world objects. type of real world objects.
• Domain
– Set of all possible values for a specific column.
• Row
– Collection of data describing one real world object.
• Primary Key
– Columns, which are part of the row and uniquely identify any one row.
26ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT
Records
• Each record represents a logical entity (e.g. a
student)
• Each field represents an attribute of the logical
entityentity
1 Wood Bob C IST357
2 Kent Chuck B IST115
3 Smith Jane A IST357
4 Boone Dan B IST357
StudID Last First Grade Section
Student
27ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT
Keys
• Each table has a primary key, one field (or a combination
of fields) that has a unique value for each and every
record in the table
Student
StudID is the primary
key in this table (two
students may share
either a last or first
name)
1 Wood Bob C IST357
2 Kent Chuck B IST115
3 Smith Jane A IST357
4 Boone Dan B IST357
StudID Last First Grade Section
Student
28ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT
Relating tables
• Tables can be related (joined) together based on their keys
• The idea is to decompose into separate tables with no redundancy and to provide a capability to reassemble with no information loss
1 Wood Bob C IST357
2 Kent Chuck B IST115
3 Smith Jane A IST357
4 Boone Dan B IST357
StudID Last First Grade Section
Student
IST357 48 Jones
IST115 120 Brower
IST20 120 Fountain
Class
Section #Stud Instructor
29ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT
Relating tables
Student
Class
Primary key Primary keyForeign key
1 Wood Bob C IST357
2 Kent Chuck B IST115
3 Smith Jane A IST357
4 Boone Dan B IST357
StudID Last First Grade Section
IST357 48 Jones
IST115 120 Brower
IST20 120 Mennis
Class
Section #Stud Instructor
30ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT
Relating tables
1 Wood Bob C IST357
2 Kent Chuck B IST115
StudID Last First Grade Section
Student
IST20 120 Brower
IST115 120 Jones
Class
Section #Stud Instructor
3 Smith Jane A IST357
4 Boone Dan B IST357
IST115 120 Jones
IST357 48 Jones
Jones 332
Brower 517
Instructor
Name Office
31ADBMS Lecture Notes 1: Prepared by Engr. Cherryl D. Cordova, MSIT