Sunday, 20 March 2011

data models


Data models:
Defin:
it is a set of concepts that can be used to describe the data such as data types and its length, relationships and consistency and constraints(conditions).
It provides the abstraction.
There are 3 types of data models:
1)record based data model
2)object based data model
3)physical data model.

1.   Record based data model:

These models are used in describing the data at logical and view level of abstraction.
It is in record format.
Each record contains the fields, and each field contains the fixed length of values.
Again this model is divided into 3 models:
1)   hierarchical data model
2)   network data model
3)   relational data model

1)   hierarchical data model:

data stores in the form of records, each record contains the fields and each field contains the fixed length.
Here each record is connected with links.
Features:

It uses tree structure to represent the relationship.
It contains only one parent record and this record doesn’t have any parent record.
This parent record have child record.

Advantages:

It is very efficient to maintain for one-to-many relationships.
It allows handle large amount of data and it provides the integrity.
It is simple and easy to design.

Disadvantages:

Although it is simple, it is difficult to implement the data. (i.e during the updation of the data) it leads to data inconsistency.

It can not handle many-to-many relationships.

2)   Network Data Model:

It is used to explain the data at view and logical level
It provides the many-to-many relationships
In this records are connected through pointers.
Here graphs can be formed but not trees.

Advantages:

It provides the many-to-many relationships.
Data can be accessed very simple.
Fast accessing of the data.
The storage space is reduced due to less data redundancy.

Disadvantages:
It is difficult to design and use properly
It is difficult to changes the database.
Not user friendly.


 
RELATIONAL MODEL
           The Relational data model is currently the most popular data model is DATA BASE MANAGEMENT system.
Ø      Why it is famous means the data is represented is the form of simple row and column format.
Ø      Each data field is considered as column.each record is considered as row of table.
Ø      The data model is developed by E.F.Codd in 1970 which is based on relation.
Ø      We don’t find any parent-child relation shis,we find the data in the form of row and column.tables of data values.
Ø      The tables are called relations.

ADVANTAGES
1.      Easy to use.
2.      Many –to-many relationships
3.      Flexibility
4.      Security
5.      Fast data access, less storage.
6.      Data redundancy is controlled.
7.      Data manipulation language.

DISADVANTAGES:

Needs powerful hardware.
                       























2.OBJECT-BASED LOGICAL MODELS

Ø      It describes the data at the conceptual and new level.
Ø      It allows data constraints explicitly.
Ø      Again these object-based logical models are 30 types.
1.      Entity relationship model
2.      Object oriented model
3.      Binary model
4.      Semantic data model
5.      Infological model
6.      Functional data model

1.Entity relationship model:
Ø      Entity is a thing or object in the real world
Ø      It consists collection of objects, called ENTITY and of relationships among these objects(thing)
Ø      Ex: if u consider customer in a company

1.      Costomer consists:     
2.      Cust_id
3.      Cust_name
4.      Cust_street
5.      Cust_city
Here customer is an entity and cus_id,cust_name,cust_street,cust_city are the attributes

Ø      If you want to make relation between more than one entity (object)then use the following symbols

Rectangles: which represent entity sets
Ellipses: which represent attributes
Diamonds: which represent relationships among entity sets
Lines: which link attributes to entity sets and sets and sets to relationships

Customer                           depositor                             account
Cust_id                                                                      account number
Cust_name                                                                  balance
Cust_street
Cust_city

The E-R diagram indicates that there are two entity sets: customer, account, with attributes as
The above diagram shows a relationship depositor between customer and account.



3.PHYSICAL DATA MODEL:

Ø      A physical data model is a representation of a data design
Ø      It describes the data at the lowest level
Ø      These concepts are mainly done by the computer specialists but not for the end users
Ø      Data is represented as record formats
Ø      Very few models are there
Ex: unifying model
       Frame memory


INSTANCES AND SCHEMAS:

Instances:

The collection of information stored in the database at a particular moment is called AN INSTANCE of the database
Instance is also known as ‘snap-shop’

Ex: in a class strength is 60, this is known as schema, because 60 will not be exceeded at all.
At a particular day strength may be decreased, that particular day strength is known as instance.

Types of schemas:

Physical schema:
                        It describes database design at the physical level.
Conceptual (or) logical schema: describes different news of the database.

Data independence:

The ability to modify a schema(database structure) in one level without affecting a schema definition in next higher level is called data independence.
 There are two levels of data independence:

(1.) physical data independence:
          To improve the performance of the DBMS, modification at the physical level are necessary. The ability to modify the physical schema without affecting the application programs to be rewritten is called physical data independence.

2) Logical data independence:

Whenever the logical structure of the database is altered (changes), modifications at the logical level are necessary. The ability to modify the logical schema without effecting application programs to be rewritten is called logical data independence.

Data models:
Defin:
it is a set of concepts that can be used to describe the data such as data types and its length, relationships and consistency and constraints(conditions).
It provides the abstraction.
There are 3 types of data models:
1)record based data model
2)object based data model
3)physical data model.

1.   Record based data model:

These models are used in describing the data at logical and view level of abstraction.
It is in record format.
Each record contains the fields, and each field contains the fixed length of values.
Again this model is divided into 3 models:
1)   hierarchical data model
2)   network data model
3)   relational data model

1)   hierarchical data model:

data stores in the form of records, each record contains the fields and each field contains the fixed length.
Here each record is connected with links.
Features:

It uses tree structure to represent the relationship.
It contains only one parent record and this record doesn’t have any parent record.
This parent record have child record.

Advantages:

It is very efficient to maintain for one-to-many relationships.
It allows handle large amount of data and it provides the integrity.
It is simple and easy to design.

Disadvantages:

Although it is simple, it is difficult to implement the data. (i.e during the updation of the data) it leads to data inconsistency.

It can not handle many-to-many relationships.

2)   Network Data Model:

It is used to explain the data at view and logical level
It provides the many-to-many relationships
In this records are connected through pointers.
Here graphs can be formed but not trees.

Advantages:

It provides the many-to-many relationships.
Data can be accessed very simple.
Fast accessing of the data.
The storage space is reduced due to less data redundancy.

Disadvantages:
It is difficult to design and use properly
It is difficult to changes the database.
Not user friendly.





1)Create a student table with attributes pino, name, marks ,avg.
2)insert the values into the tables at a time
Syntax: insert into <existing table> values(&attribute1, &attribute2,….);
Ex: insert into student values(‘&name’, &pino,&marks,&avg);
3) update <existing table> set attribute1=<value>,attribute2=<value> where (condition);
Ex: update student set marks=590,avg=60.25 where pino=345;
4)write a query to change the structure of student table by adding a new column.
Syntax:
Alter table <existing table > add attribute datatype(size);
Example: alter table student add address varchar(30);
5)write a query to modify the structure of student table by changing the size of address.
Syntax: alter table <existing table> modify attribute data type(size);
Example: alter table student modify address char2(40);

1)write a query to set some data for the name and avg in the records.
Syntax: update <exitsting table> set attribute1=<value>,attribute2=<value> where <condition>;
Example: update student name=’raj’, avg=76.89 where pino=56;

2)write a query to change the structure of student by adding a new column mobileno.
5) waq to select the names and marks of students whose marks are above 60;
Ex: select name, marks from student where marks>60;
6)write a query that sets the content data base from student in ascending order based on pinno.
Sysnax: select attribute(s) from <existing table > order by attribute;
Query(example): select * from student order by pino;




Database structure:
1)explain about database structure?
Database structure is divided into two parts:
1)   storage management
2)   query processor

1)   storage management:
storage management works as an interface between data stored in database and the application.

That is data is stored in disk as file system using operating system. The storage manager converts DML Statements into low level file systems.

i)TRANSACTION MANAGER:
 as the name specifies, it manages the transactions such that data remain in consistent state even after the transaction. It also provides for optimal concurrent transaction executions.

·       File management: file management allocated space for the data on disk and provides a data structure to define the information saved on disk that provides for easy access.
·       Buffer management: buffer management handles the transfer of data from disk onto the main memory and decides on what data to be kept in main memory.
·       Authorization management: this module allows only authorized users to access the data.
·       Integrity management: this module handles on the integrity constraints that are said on the data.  Storage management uses the following data structure i)data files ii)data dictionary iii)indices.
(II) QUERY PROCESSOR:
·       Interpreter Of DDL: DDL statements written by DBA to define the schema are interpreted and stored in the data dictionary.
·       Compiler of data manipulation language statements: as any other compiler, DML compiler converts the DML statements in low-level instructions. I also optimizes the query i.e., perform “query optimization”
·       Query evaluation DML compiler converts DML statements into low level instructions which are evaluated by query evaluation machine.








1)Create a student table with attributes pino, name, marks ,avg.
2)insert the values into the tables at a time
Syntax: insert into <existing table> values(&attribute1, &attribute2,….);
Ex: insert into student values(‘&name’, &pino,&marks,&avg);
3) update <existing table> set attribute1=<value>,attribute2=<value> where (condition);
Ex: update student set marks=590,avg=60.25 where pino=345;
4)write a query to change the structure of student table by adding a new column.
Syntax:
Alter table <existing table > add attribute datatype(size);
Example: alter table student add address varchar(30);
5)write a query to modify the structure of student table by changing the size of address.
Syntax: alter table <existing table> modify attribute data type(size);
Example: alter table student modify address char2(40);

1)write a query to set some data for the name and avg in the records.
Syntax: update <exitsting table> set attribute1=<value>,attribute2=<value> where <condition>;
Example: update student name=’raj’, avg=76.89 where pino=56;

2)write a query to change the structure of student by adding a new column mobileno.
5) waq to select the names and marks of students whose marks are above 60;
Ex: select name, marks from student where marks>60;
6)write a query that sets the content data base from student in ascending order based on pinno.
Sysnax: select attribute(s) from <existing table > order by attribute;
Query(example): select * from student order by pino;




Database structure:

Database structure is divided into two parts:
1)   storage management
2)   query processor

1)   storage management:
storage management works as an interface between data stored in database and the application.

That is data is stored in disk as file system using operating system. The storage manager converts DML Statements into low level file systems.

i)transaction manager:
 as the name specifies, it manages the transactions such that data remain in consistent state even after the transaction. It also provides for optimal concurrent transaction executions.

·       File management: file management allocated space for the data on disk and provides a data structure to define the information saved on disk that provides for easy access.
·       Buffer management: buffer management handles the transfer of data from disk onto the main memory and decides on what data to be kept in main memory.
·       Authorization management: this module allows only authorized users to access the data.
·       Integrity management: this module handles on the integrity constraints that are said on the data.  Storage management uses the following data structureL i)data files ii)data dictionary iii)indices.
(II) query processor:
·       INTERPRETER OF DATA DEFINITION LANGUAGE STATEMENTS: DDL statements writtey by DBA to define the schema are interpreted and stored in the data dictionary.
·       Compiler of data manipulation language statements: as any other compiler, DML compiler converts the DML statements in low-level instructions. I also optimizes the query i.e., perform “query optimization”
·       Query evaluationL DML compiler converts DML satemts into low level instructions which are evaluated by query evaluation machine.




GENERALIZATION,SPECIALAZATION AND AGGREGATION:

Generalization:

Ø     Generalization is a special case of specialization
Ø     Generalization is the result of taking the union of two or more different entity sets to form higher level entity set
Ø     That is combinding low-level entity sets and producing a highlevel entity set is known as generalization

Example:

In a bank there are two types of customers
1.     current account customers
2.     saving account customers

Ø     these two are represented by two entity sets
Ø     if we generalize there entity sets we can get an entity set customers of the bank.

 
REDUCE THE ER DIAGRAMS TO TABLES

A database that is represented as an ER diagrams an ER diagrams can be represented by a collection of tables. for each entity set and for each relationship set in the database, that is a unique table that is assigned the name of the corresponding entity set (or) relationship set. each table has multiple columns, each is unique name.

For example, consider the entity set names employee of the employee entity set has the attributes eno, ename, sal,

The table corresponding to the EMPLOYEE has three columns as under.

ENO       ENAME    SAL
Em-001   ravi            6000
cm-002   anji             7000
ec-001     gopi           8000
me-003    venki         9000
ee-002     babu rao      10000

if we consider,the entity set dept of the ER diagram

No comments:

Post a Comment