Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 13

ORDBMS with ORACLE Lecture-2

Dr. Akhtar Ali Jalbani Assistant Professor ITC, SAU Tandojam

Exercise-01
Identify entities and attributes to store data for the CDs catalogue and also the relationships among entities. Identify entities and attributes to store data for the employees of the university and also the relationships among entities.

Data Models
Data model is a way of storing and retrieving data. There are three different models: Hierarchical, Network and Relational.
Hierarchical : data is stored in the form of tree. The data is represented by parent child relationship. Each tree contains a single root record and one or more subordinate records. This model supports only one-tomany relationship between entities.
For example: Each batch is root and students of the batch will be subordinates. Network

Network: data is stored along with the pointers, which specify the relationship between entities.
This model is complex and difficult to understand how the data is stored and the way data is manipulated. It is capable of supporting many-to-many relationship between entities, which hierarchical model does not support.

Relational: This stores data in the form of tables.


Table is the collection of rows and columns.

Relational Database Management System (RDBMS)


A DBMS that is based on the relational model is called RDBMS. Designed by E.F. Codd Relational model is based on theory of sets and relations of mathematics. Data is stored in the tables. A table is two dimensional array containing rows and columns.
Row: contains data related to entity Column: contains data related to single attribute of the entity for example student name.

Advantages of Relational Model


Simplicity Easy to understand Easy to manipulate Provides dynamic relationship between entities using values of the columns.

Table Name STUDENTS ROLLNO 2k7-IT-01 2k7-IT-02 2K7-IT-03 Name ABC DEF GHI Phone 03331256 12333 366666 Table / Relation Tuple /Row Column name

Attribute / Column

Tuple / Row: A single row in the table is called as tuple. Each row represents the data of a single entity. Attribute / Column: A column stores an attribute of the entity. For example, if details of students are stored then student name is an attribute; course is another attribute and so on. Column Name: Each column in the table is given a name. This name is used to refer to value in the column. Table Name: Each table is given a name. This is used to refer to the table. The name depicts the content of the table.

KEYS in DATABASE
Primary Key: a set of columns used to uniquely identify rows of a table.
For example: Roll No

Composite Primary Key: In some tables a single column cannot be used to uniquely identify entities (rows). In that case we have to use two or more columns to uniquely identify rows of the table. When a primary key contains two or more columns it is called as composite primary key.

PAYMENTS ROLLNO 2K7-IT-01 2k7-IT-02 2K7-IT-01 DateOfPayment 12-05-2011 13-05-2011 14-05-2011 Amount 1000 2000 1500 Remarks Regular fess Regular fees fine

Composite Key

Foreign Key: key on the many side of the relationship. In relational model, we often store data in different tables and put them together to get complete information. For example, in PAYMENTS table we have only ROLLNO of the student. To get remaining information about the student we have to use STUDETNS table. Roll number in PAYMENTS table can be used to obtain remaining information about the student. The relationship between entities student and payment is one-tomany. One student may make payment for many times. As we already have ROLLNO column in PAYMENTS table, it is possible to join with STUDENTS table and get information about parent entity (student). Roll number column of PAYMENTS table is called as foreign key as it is used to join PAYMENTS table with STUDENTS table. So foreign key is the key on the many side of the relationship.

STUDENTS ROLLNO 2k7-IT-01 2k7-IT-02 2K7-IT-03 Name ABC DEF GHI Phone 03331256 12333 366666

PAYMENTS
ROLLNO Foreign Key 2K7-IT-01 2k7-IT-02 2K7-IT-01 DateOfPayment 12-05-2011 13-05-2011 14-05-2011 Amount 1000 2000 1500 Remarks Regular fess Regular fees fine

Integrity Rules
Data integrity is to be maintained at any cost. If data loses integrity it becomes garbage. So every effort is to be made to ensure data integrity is maintained. The following are the main integrity rules that are to be followed.
Domain integrity Entity integrity Referential integrity

You might also like