Chapter Seven
Basic Data Storage
1
Outcome of this chapter
⚫Describes databases and DBMS concepts,
terminology, and architecture
⚫Describes the basic concepts necessary for a good
understanding of databases design and
implementation
⚫Describe the conceptual modeling techniques used in
database systems
⚫Describes the relational data model, its integrity
constraints and update operations, and the operations
of the relational algebra
2
Introduction to Database
⚫A database is an organized collection of data.
⚫It is the collection of schemas, tables, queries,
reports, views and other objects.
⚫Database is a well-arranged and self-defining
collection of data that is used to preserve data and
metadata (Data about Data) and maintain data
stability and integrity.
3
Database Functionalities
⚫Data Storage Management
⚫Data Transformation and Presentation
⚫Security
⚫Multi-user Access Control
⚫Backup and Recovery
⚫Data Integrity
⚫Database Access Language
⚫Database Communication Interface.
4
Applications of databases
⚫Banking: transactions
⚫Airlines: reservations, schedules
⚫Universities: registration, grades
⚫Sales: customers, products, purchases
⚫Online retailers: order tracking, customized
recommendations
⚫Manufacturing: production, inventory, orders, supply
chain
⚫Human resources: employee records, salaries, tax
deductions
5
Advantages & Disadvantages of DB
Advantages:
⚫High data quality, integrity, and consistency
⚫Reduced data redundancy and application maintenance
⚫Easy access and sharing
⚫Scalable
⚫Improved security
⚫Specialized and productive management tool
Major disadvantages:
⚫ Increased complexity
⚫Greater impact of failure
6
Relational Database
⚫A relational database (RDB) is a collective set of
multiple data sets organized by tables, records and
columns.
⚫RDBs also establish a well-defined relationship
between database tables.
⚫In simplest terms, a relational database is one that
presents information in tables with rows and columns
showing relation between them.
7
Database Management System
⚫All the database design and data manipulation tasks
are carried by a Database Management System
(DBMS).
⚫It is computer software designed for the purpose of
managing databases based on a variety of data
models.
8
Schema and Instance
Schema : logical structure of the database is called
Schema.
Instance : The actual content of the database at a
particular point in time is called an Instance.
9
Database table properties
⚫Unique table name.
⚫All values in a row describe
the one instance.
⚫All values in a column are of
the same kind.
⚫Each row is distinct.
⚫A cell of the table holds a
single value.
⚫Each column has a unique
name.
⚫There is no ordering in rows.
⚫NULL value can also be
stored in tables.
10
A simple Database Table
In a database, data are organized in
relations (tables) which may be
linked by some constraints.
Columns contain what
information is needed to be stored
and Rows contain each record.
For example, in a university
database, there can be tables to
store information about courses,
instructors, student, section etc.
Columns are called fields and each
row contains record which stores
value for each field. Here, ID,
name, dept_name and salary are
the fields to store and {2222,
Einstein, Physics, 95000} is a
record.
11
Data Model
⚫A detailed model that captures overall structure of
organizational data while being independent of any
implementation considerations.
⚫Data modeling involves examining the data objects in a
system and identifying the relationship between these
objects.
⚫There are different ways of model a database. They are:
⚫ Relational model
⚫ Entity-Relationship data model (mainly for database design)
⚫ Object-based data models (Object-oriented and Object-
relational)
⚫ Semi structured data model (XML)
12
Entity, Attributes and Relationships
⚫Entity: An entity is an object that exists and is
distinguishable from other objects. It is the primary task
to determine all the entities and their attributes while
modeling a database. Entities are denoted using rectangle.
Example: specific person, company, event, plant.
⚫Attribute: An entity is represented by a set of attributes
that is descriptive properties possessed by an entity.
Attributes are denoted using elliptical shape. Example:
instructor = (ID, name, street, city, salary), course=
(course_id, title, credits)
⚫Relationship: A relationship is an association among
several entities. Entity relationships are denoted using
rhombus shape. Example: students are enrolled in
courses. Instructor teaches courses. 13
Entities & their Attributes with
Relationship in a University Database
14
Primary key
⚫ A primary key is a
candidate key and a
single field that is most
appropriate to be the
main reference key for
the table.
⚫ The primary key must
contain unique values,
must never be null and
uniquely identify each
record in the table.
⚫ For example, in a
Students table, we can
see that, using only
{StudentID} it is
possible to identify each
record distinctly. So,
this is the primary key
for the table.
15
Foreign key
⚫ A foreign key is generally a
primary key from one table
that appears as a field in
another table to establish a
relation between the first and
second table.
⚫ For example, consider the
relationship between Students
and Courses. Student
information is stores in
Students table and course
information is stored in
Courses table. From these two
tables how to show that which
student have which courses?
This is done using a foreign key
field {courseId} in the Students
table, which will contain the
values of {courseId} field of
Courses table. 16
17
Question
⚫ What is database? Why do we use database? What are the advantage and
disadvantage of database?
⚫ What is DBMS? What is schema and instance? What are the properties of
database table? What is Field and Record?
⚫ What is a relational database? Find the tables necessary for a Library
Management System/ Hospital Management System.
⚫ What is a data model? What are entity, attribute and Relationship?
Discuss with example.
⚫ Find all the entities of an online bookshop management database. Find
out all the attributes for each entity.
⚫ Find all the entities of a Shopping Store management database. Find out
all the attributes for each entity.
⚫ What is Primary key? Describe with example.
⚫ What is Foreign Key? Why do we use Foreign Key in a database? Explain
with example.
⚫ For an online book shop database, identify the Primary Key and Foreign
Key in Customers and Orders table.
18
Thank You
19

Chapter 7 Basic Data Storage.pptx

  • 1.
  • 2.
    Outcome of thischapter ⚫Describes databases and DBMS concepts, terminology, and architecture ⚫Describes the basic concepts necessary for a good understanding of databases design and implementation ⚫Describe the conceptual modeling techniques used in database systems ⚫Describes the relational data model, its integrity constraints and update operations, and the operations of the relational algebra 2
  • 3.
    Introduction to Database ⚫Adatabase is an organized collection of data. ⚫It is the collection of schemas, tables, queries, reports, views and other objects. ⚫Database is a well-arranged and self-defining collection of data that is used to preserve data and metadata (Data about Data) and maintain data stability and integrity. 3
  • 4.
    Database Functionalities ⚫Data StorageManagement ⚫Data Transformation and Presentation ⚫Security ⚫Multi-user Access Control ⚫Backup and Recovery ⚫Data Integrity ⚫Database Access Language ⚫Database Communication Interface. 4
  • 5.
    Applications of databases ⚫Banking:transactions ⚫Airlines: reservations, schedules ⚫Universities: registration, grades ⚫Sales: customers, products, purchases ⚫Online retailers: order tracking, customized recommendations ⚫Manufacturing: production, inventory, orders, supply chain ⚫Human resources: employee records, salaries, tax deductions 5
  • 6.
    Advantages & Disadvantagesof DB Advantages: ⚫High data quality, integrity, and consistency ⚫Reduced data redundancy and application maintenance ⚫Easy access and sharing ⚫Scalable ⚫Improved security ⚫Specialized and productive management tool Major disadvantages: ⚫ Increased complexity ⚫Greater impact of failure 6
  • 7.
    Relational Database ⚫A relationaldatabase (RDB) is a collective set of multiple data sets organized by tables, records and columns. ⚫RDBs also establish a well-defined relationship between database tables. ⚫In simplest terms, a relational database is one that presents information in tables with rows and columns showing relation between them. 7
  • 8.
    Database Management System ⚫Allthe database design and data manipulation tasks are carried by a Database Management System (DBMS). ⚫It is computer software designed for the purpose of managing databases based on a variety of data models. 8
  • 9.
    Schema and Instance Schema: logical structure of the database is called Schema. Instance : The actual content of the database at a particular point in time is called an Instance. 9
  • 10.
    Database table properties ⚫Uniquetable name. ⚫All values in a row describe the one instance. ⚫All values in a column are of the same kind. ⚫Each row is distinct. ⚫A cell of the table holds a single value. ⚫Each column has a unique name. ⚫There is no ordering in rows. ⚫NULL value can also be stored in tables. 10
  • 11.
    A simple DatabaseTable In a database, data are organized in relations (tables) which may be linked by some constraints. Columns contain what information is needed to be stored and Rows contain each record. For example, in a university database, there can be tables to store information about courses, instructors, student, section etc. Columns are called fields and each row contains record which stores value for each field. Here, ID, name, dept_name and salary are the fields to store and {2222, Einstein, Physics, 95000} is a record. 11
  • 12.
    Data Model ⚫A detailedmodel that captures overall structure of organizational data while being independent of any implementation considerations. ⚫Data modeling involves examining the data objects in a system and identifying the relationship between these objects. ⚫There are different ways of model a database. They are: ⚫ Relational model ⚫ Entity-Relationship data model (mainly for database design) ⚫ Object-based data models (Object-oriented and Object- relational) ⚫ Semi structured data model (XML) 12
  • 13.
    Entity, Attributes andRelationships ⚫Entity: An entity is an object that exists and is distinguishable from other objects. It is the primary task to determine all the entities and their attributes while modeling a database. Entities are denoted using rectangle. Example: specific person, company, event, plant. ⚫Attribute: An entity is represented by a set of attributes that is descriptive properties possessed by an entity. Attributes are denoted using elliptical shape. Example: instructor = (ID, name, street, city, salary), course= (course_id, title, credits) ⚫Relationship: A relationship is an association among several entities. Entity relationships are denoted using rhombus shape. Example: students are enrolled in courses. Instructor teaches courses. 13
  • 14.
    Entities & theirAttributes with Relationship in a University Database 14
  • 15.
    Primary key ⚫ Aprimary key is a candidate key and a single field that is most appropriate to be the main reference key for the table. ⚫ The primary key must contain unique values, must never be null and uniquely identify each record in the table. ⚫ For example, in a Students table, we can see that, using only {StudentID} it is possible to identify each record distinctly. So, this is the primary key for the table. 15
  • 16.
    Foreign key ⚫ Aforeign key is generally a primary key from one table that appears as a field in another table to establish a relation between the first and second table. ⚫ For example, consider the relationship between Students and Courses. Student information is stores in Students table and course information is stored in Courses table. From these two tables how to show that which student have which courses? This is done using a foreign key field {courseId} in the Students table, which will contain the values of {courseId} field of Courses table. 16
  • 17.
  • 18.
    Question ⚫ What isdatabase? Why do we use database? What are the advantage and disadvantage of database? ⚫ What is DBMS? What is schema and instance? What are the properties of database table? What is Field and Record? ⚫ What is a relational database? Find the tables necessary for a Library Management System/ Hospital Management System. ⚫ What is a data model? What are entity, attribute and Relationship? Discuss with example. ⚫ Find all the entities of an online bookshop management database. Find out all the attributes for each entity. ⚫ Find all the entities of a Shopping Store management database. Find out all the attributes for each entity. ⚫ What is Primary key? Describe with example. ⚫ What is Foreign Key? Why do we use Foreign Key in a database? Explain with example. ⚫ For an online book shop database, identify the Primary Key and Foreign Key in Customers and Orders table. 18
  • 19.