CH 7 Database Concepts 1
CH 7 Database Concepts 1
DATABASE CONCEPTS
PREPARED BY:
1
ASHOK KUMAR SHARMA, PGT CS
JNV SHIMOGA, KARNATAKA
DATABASE
2
FILE SYSTEM
10
COMMONLY USED TERMINOLOGIES
IN RELATIONAL DATA MODEL
The Relational Model was developed by E. F.
Codd of the IBM in 1970 and is the most widely
used Database Model.
? Relation / Table
A Relation/Table is a tabular structure arranged
in rows and columns. It has the following
properties:
▪ All items in a column are homogeneous i.e.
they are of the same data type
▪ Each column is assigned a unique name and
has an atomic(indivisible) value.
11
COMMONLY USED TERMINOLOGIES IN
RELATIONAL DATA MODEL
12
COMMONLY USED TERMINOLOGIES
IN RELATIONAL DATA MODEL
? Domain
It is a set of values from which an attribute can take a
value in each row. Usually, a data type is used to
specify domain for an attribute.
? Tuple / Entity / Record
Each row of data in a relation (table) is called a tuple.
? Attribute / Field
The columns of a relation are the attributes which
are also referred as fields.
? Degree
The number of attributes in a relation is called the
Degree of the relation
? Cardinality
The number of tuples in a relation is called the
Degree of the relation 13
DATABASE TABLE/RELATION
STUDENT Table/Relation
Name
Columns / Attributes
Relation
Table /
ROLL NAME CLASS
01 VIJETHA 12
02 SINDHU 11
Rows /
Tuples
03 GAUTHAMI 12
16
KEYS IN A RELATIONAL DATABASE
? Candidate Key
▪ A table can have one or more attributes that
takes distinct values. Any of these attributes
can be used to uniquely identify the tuples in
the relation. Such attributes are called
candidate keys.
▪ A Primary Key is one of the candidate keys.
▪ A table may have more than one candidate
keys but definitely has one and only one
primary key.
17
KEYS IN A RELATIONAL DATABASE
? Candidate Key
Candidate Keys
STUDENT
Stud_ID Roll_No Name Stream Email_ID
200601 01 Nikitha Science [email protected]
200607 03 Srinidhi Commerce [email protected]
200647 18 Sahana Science [email protected]
21
KEYS IN A RELATIONAL DATABASE
▪ In some cases, foreign key can take NULL
value if it is not the part of primary key of the
foreign table.
▪ The table containing the foreign key is called
the child table, and the table containing the
candidate key is called the referenced or
parent table.
22
KEYS IN A RELATIONAL DATABASE
ORDERS
ORDER_ID ORDER_NO CUST_ID
1 1255 3 Child
2 1690 3 Table
3 1810 2
4 2210 1
CUSTOMER
CUST_ID NAME ADDRESS
Parent
1 HECTOR MADRID
Table
2 MITCHELLE LONDON
3 AUGUSTA COLARADO
▪ From the above given tables we can observe that the CUST_ID
column of ORDERS table is deriving its value from CUST_ID of
CUSTOMER table. So we can say that the CUST_ID of
ORDERS table is a foreign key whose value is dependent upon
the Primary key column CUST_ID of table CUSTOMER. 23
REFERENTIAL INTEGRITY
? The property of a relational database which
ensures that no entry in a foreign key column
of a table can be made unless it matches a
primary key value in the corresponding column
of the related table is called referential
integrity.
? It also ensures that the user don’t accidentally
delete or change the related data.
? Referential integrity can be applied when:
▪ The master table’s column is a Primary Key or
has a unique index.
▪ The related fields have the same data type. 24
26