Data Models, Schemas & Instances
Data Models, Schemas & Instances
Data Model
A collection of concepts that can be used to describe the structure of a database Data model is a collection of conceptual(logical) tools for describing data, relationship etc. provides the necessary means to achieve data abstraction By structure of a database, we mean the data types, relationships, and constraints that should hold for the data
8/31/2012
8/31/2012
CONTINUED
Physical data models defines record structure, file structure etc. Logical data models use concepts such as entities, attributes & relationships Entity represents a real world object or a concept Ex: employee, student, project Attribute - represents some property of interest that further describes an entity Ex: Employee's name or salary.
8/31/2012
8/31/2012
8/31/2012
Dept_Name
Dept_Number
Dept_Location
Employee
Salary Dept_Number Mgr_Ssn
Works in
Department
8/31/2012
RELATIONAL MODEL
Uses a collection of tables to represent both data and the relationships among those data Each table has multiple columns, and each column has a unique name In the formal relational model terminology, a row is called a tuple, a column header is called an attribute, and the table is called a relation In Relational model data is organized in the form of tables .
8/31/2012
It uses a collection of tables to represent both data and the relationships among those data. The advantage of this model is that it offers flexibility. This is the most popular method
Custname johnson smith hayes turler jones lincy smith johnson Social security 1 2 3 4 5 6 2 1 Custstreet xxx yyy aaa bbb ccc ddd yyy xxx Cust-city A/c no: yyy xxx bbb aaa ddd ccc xxx yyy
8/31/2012
Here balance is not given in the first table. We have to represent the relationship b/w account no: and balance is shown in the next table
Social security 1 Custstreet xxx Cust-city yyy A/c no: A-101
Cust-name johnson
smith
hayes turler jones lincy smith johnson
2
3 4 5 6 2 1
yyy
aaa bbb ccc ddd yyy xxx
8/31/2012
xxx
bbb aaa ddd ccc xxx yyy
A-215
A-102 A-201 A-217 A-222 A-201 A-201
10
A-102
A-201 A-217 A-222
100
100 120 200
8/31/2012
11
Network model
Here data is organized as a collection of records and the relationships among data are represented by links. It looks like an arbitrary graph. The collection of records connected to one another by means of links, where link is an association between 2 records. The operations on the n/w model are find, insert, delete, modify etc.
8/31/2012
12
-------------
A-217
A-222
120
200
8/31/2012
13
Hierarchical model
Here data is represented by collection of records and relationships among data by links It is similar to network model The only difference is that it takes the structure of a tree
8/31/2012
14
root
johnson
1 ---
smith 2 ---
hayes
---
turler
4 ---
jones
---
lincy
6 ---
A-101 500
A-215
200
A-102
100
A-217
A-201
100
A-201
100
A-201
100
8/31/2012
15
DATABASE SCHEMA
The description of a database is called the database schema It is the complete structure of database. Subschema is a part of the database pertaining to the users need. To create a schema , the syntax is : CREATE SCHEMA schemaname [AUTHORIZATION username] [schema element[]]
Where schemaname is the name of the schema that is to be created. Authorization class is used for all created objects that can be later owned by the user.
8/31/2012 Database Management System 16
Dept_Number
8/31/2012
17
INSTANCES
The data in the database at a particular moment in time is called a database state or snapshot It is also called the current set of occurrences or instances in the database
8/31/2012
18
Ssn
101 102 103 104 105
Emp_Name Age
Mathew David Mary John Catherine 32 27 23 26 23
Salary
50000 37000 20000 30000 22000
Mgr_Ssn
NULL 101 102 101 104
Dept_Number
1 1 2 2 2
19
8/31/2012
DATABASE LANGUAGES
Data Definition Language (DDL) to specify the database schema Data Manipulation Language (DML) - to express database queries and updates DDL and DML are not two separate languages. Instead they simply form parts of a single database language, such as the widely used SQL (Structured Query Language)
8/31/2012
20