CSE031.Lecture - 05.introduction To Database - Fall 2019
CSE031.Lecture - 05.introduction To Database - Fall 2019
• Data consists of numbers, text, graphics, images, sound and video segments
that have meaning to user’s environment.
4
Core concepts and definitions (cont.)
Data vs Information
Core concepts and definitions (cont.)
Data ->Information -> Knowledge
Background and History
• Manual filing systems.
• Duplication of data.
• Because data were isolated, common data like customer name and
address ended up being stored in each application.
• This leads to problems with data integrity (how much the data are
“correct”) as data might be updated in one application but not another.
• Example: In a University environment, student data is stored in the
Students affairs file system and in the Library file System. A student
changes his mobile number, and one system gets updated but the other
doesn’t. Which system has the correct Mobile no?
Background and History (cont.)
• Limitations of Computerized File- based systems (cont.):
• Program-Data dependence.
• The structure and data storage are defined in each application’s code.
• changing anything about the data storage, for example, increasing the size
of the name field…requires changing all code that used any part of the file.
• Activity Analysis
• What activities make up the business
• Design
• Logical database design to avoid data redundancy & ensure data
integrity
• Detailed system specification
• Implementation
• Create the database system
• Maintenance
• Troubleshoot, update the database
14
Data Modeling – How the programmer sees the data
15
Evolution of Data Models
• Timeline
Hierarchical
Network Object-oriented
Relational Web-based
Entity-Relationship
• Disadvantages
• Tables
• flexible logical structure for data representation
• a series of row/column intersections
• related by sharing common entity characteristic(s)
20
STUDENT
Example: a relation STUDENT with attributes S_id, Name, Phone and age
Relational Data Model - Terminology
• Relation Schema: A relation schema is name of the relation with its attributes.
e.g.; STUDENT (S_id, Name, Phone and Age) is the relation schema for relation
(table) STUDENT.
• Primary Key: every table (relation) in the database should have one set of
attributes which defines a row uniquely. This set of attributes is called primary
key. e.g.; S_id is the primary key of STUDENT table. A primary key is not allowed
to be NULL (empty).
Relational Data Model – Terminology (cont.)
• Field: A field is a combination of one or more related
characters or bytes and is the smallest unit of data a user
accesses. The field should contain a single value. It cannot
contain a list or multiple values
Basic properties of a field Other properties of a field
Name caption
Size Input mask
Data type Format
Default value
Required
Validation rule
Relational Data Model – Terminology (cont.)
• Data type of a field: specifies the kind of data a field can contain.
Common data types includes
• Text
• Numeric
• Date
• Currency
• Memo
• Yes/No (also called Boolean)
• Hyperlink
• Object (also called BLOB for
binary large object)
Relational Data Model – Terminology (cont.)
• Table (relation or file): is a collection of related records.
❑ Each record in the file contains the same fields.
❑ Each record in the table is UNIQUE. This is guaranteed
by the constraint on primary keys.
❑ The order of the records in a table is not significant.
STUDENT Department
Department_code Department_name
S_id Name Phone Age D_code
COMPUTER
CS
1 John 01055123451 18 CS SCIENCE
INFORMATION
IT
TECHNOLOGY
2 Mary 01152431543 18 CS
ELECTRONICS AND
ECE COMMUNICATION
3 Tom 01256253131 20 CV
ENGINEERING
4 Bill 18 ECE CV CIVIL ENGINEERING
26
Relational Database: Association among Tables (M:N)
• To represent Many: Many relationships, e.g. a student can take many courses and a
course contains many students, a third table is TAKES is needed . Table TAKES has 5
fields : S_id, C_id, Year, Semester, Grade. S_id and C-ID are foreign keys that refer to
tables STUDENT and COURSE respectively.
• Disadvantages
• Substantial hardware and system software overhead
• Ease-of-use allows careless use of RDBMS
29