DATABASE CONCEPTS
Database
or
DBMS ( Database Mangement system)
• It is a collection of multiple tables.
• OR
• collection of logically related data.
• OR
• It is computerized record keeping information
system.
Examples of DBMS software are
Dbase, Foxpro, Oracle, MS SQL
Server, MS Access, Paradox, DB2,
FileMaker and MySQL etc.
DATABASE
is a collection of Data is organized into
organized rows, columns i.e. in
DATA/INFORMATION the tables form
It works like a
container which
contains the various
object like Tables,
Queries, Reports
Different types of Databases
• RDBMS-(Relational Database management system).
e.g. MS Access, MySQL, Microsoft SQL Server, IBM DB2
• ORDBMS-Object Relational Database management
system. e.g. Oracle
WHY DO WE NEED DATABASE?
OR
ADVANTAGES OF DATABASE
reduces
Redundancy facilitate Sharing
of Data
(duplication)
maintains
Provides Integrity
Security
( rules /condition)
RELATIONAL DATABASE
It is a collective set of multiple data sets
organized by tables, records and columns
It establishes a well-defined
relationship between database tables
It uses Structured Query Language (SQL),
SQL- is a standard user application that provides
an easy programming interface for database
interaction.
RELATIONAL DATABASE TERMS
Relation Domain Tuple/Record
Attribute/field/column Degree Cardinality
Relation - Relation is a collection of rows and columns
. It is also called Table.
Relation : Student
Rollno Admno Name Stream Phone
1 12/345 Teena Science 234567879
2 14/564 Sheena Commerce 344553322
3 10/345 Heena Science 23455632
4 11/456 Meena Science 345522356
5 13/432 Leena Humanities 456720980
6 3/567 Reena Commerce 456322578
Attribute/field/column
A column in a relation is called an attribute.
It is also termed as field or column.
Relation : Student
Rollno Admno Name Stream Phone
1 12/345 Teena Science 234567879
2 14/564 Sheena Commerce 344553322
3 10/345 Heena Science 23455632
4 11/456 Meena Science 345522356
5 13/432 Leena Humanities 456720980
6 3/567 Reena Commerce 456322578
Degree
No of columns/attributes in a relation
Degree is 5
Relation : Student
Rollno Admno Name Stream Phone
1 12/345 Teena Science 234567879
2 14/564 Sheena Commerce 344553322
3 10/345 Heena Science 23455632
4 11/456 Meena Science 345522356
5 13/432 Leena Humanities 456720980
6 3/567 Reena Commerce 456322578
Tuple/Record
- A row in a relation is called a tuple.
OR
– Collection of fields in a relation
Relation : Student
Rollno Admno Name Stream Phone
1 12/345 Teena Science 234567879
2 14/564 Sheena Commerce 344553322
3 10/345 Heena Science 23455632
4 11/456 Meena Science 345522356
5 13/432 Leena Humanities 456720980
6 3/567 Reena Commerce 456322578
Cardinality
- No of rows/record/tuples in a relation
Cardinality is 6
Relation : Student
Rollno Admno Name Stream Phone
1 12/345 Teena Science 234567879
2 14/564 Sheena Commerce 344553322
3 10/345 Heena Science 23455632
4 11/456 Meena Science 345522356
5 13/432 Leena Humanities 456720980
6 3/567 Reena Commerce 456322578
Domain
It is pool of values from which the value
is derived for a column.
Relation : Student
Rollno Admno Name Stream Phone
1 12/345 Teena Science 234567879
2 14/564 Sheena Commerce 344553322
3 10/345 Heena Science 23455632
4 11/456 Meena Science 345522356
5 13/432 Leena Humanities 456720980
6 3/567 Reena Commerce 456322578
Science
Commerce
Humanities
RELATIONAL DATABASE TERMS
KEYS IN A DATABASE
it is used for identifying unique rows from
table & establishes relationship among
tables on need.
KEYS IN A DATABASE
Primary Key Candidate Key
Alternate Key-
Foreign Key
Primary Key
Primary key is a key that can uniquely identifies the
records/tuples in a relation.
This key can never be duplicated and NULL.
Relation : Student
Rollno Admno Name Stream Phone
Rollno can be
primary key 1 12/345 Teena Science 234567879
2 14/564 Sheena Commerce 344553322
3 10/345 Heena Science 23455632
4 11/456 Meena Science 345522356
5 13/432 Leena Humanities 456720980
6 3/567 Reena Commerce 456322578
Candidate Key -
which can serve as a primary key but not
primary key. it is also called alternate key
Relation : Student
Rollno Admno Name Stream Phone
admno can be
candidate key 1 12/345 Teena Science 234567879
2 14/564 Sheena Commerce 344553322
3 10/345 Heena Science 23455632
4 11/456 Meena Science 345522356
5 13/432 Leena Humanities 456720980
6 3/567 Reena Commerce 456322578
Alternate Key-
Out of all candidate keys, only one gets selected
as primary key, remaining keys are known as
alternate or candidate key
Relation : Student
admno can be Rollno Admno Name Stream Phone
alternate key/ 1 12/345 Teena Science 234567879
candidate key
2 14/564 Sheena Commerce 344553322
3 10/345 Heena Science 23455632
4 11/456 Meena Science 345522356
5 13/432 Leena Humanities 456720980
6 3/567 Reena Commerce 456322578
Foreign Key-
Foreign Key is a key that is defined as a primary key
in some other relation.
Relation : Student
Rollno Admno Name
Relation : Test
Stream Phone Tno
12/345 Science
Tno Tname dateofexam
1 Teena 234567879 T1
14/564 Commerce
T1 UT1 2/4/2020
2 Sheena 344553322 T1
10/345 Science
T2 HY 3/9/2020
3 Heena 23455632 T2
11/456 Science
T3 UT2 5/11/2020
4 Meena 345522356 T2
13/432 Humanities
T4 Annual 9/1/2021
5 Leena 456720980 T3
6 3/567 Reena Commerce 456322578 T2
FOREIGN KEY
Observe the following table and answer the question
TABLE: VISITOR
VisitorID VisitorName ContactNumber
V001 ANAND 9898989898
V002 AMIT 9797979797
V003 SHYAM 9696969696
V004 MOHAN 9595959595
1. Write the name of most appropriate columns which can be
considered as Candidate keys?
2. Out of selected candidate keys, which one will be the best to choose
as Primary Key?
3. What is the degree and cardinality of the table?
Modern Public School is maintaining fees records of students.
The database administrator Aman decided that-
• Name of the database -School
• Name of the table – Fees
The attributes of Fees are as follows:
• Rollno - numeric
• Name – character of size 20
• Class - character of size 20
• Fees – Numeric
• Qtr – Numeric
(i) Identify the attribute best suitable to be declared as a primary
key
(ii) Write the degree of the table.
(iii) Define attribute and cardinality.
Write SQL Commands for the following queries based on the relations PRODUCT and
CLIENT given below.
• Table: Product
P_ID ProductName Manufacturer Price ExpiryDate
TP01 Talcum Powder LAK 40 2011-06-26
FW05 Face Wash ABC 45 2010-12-01
BS01 Bath Soap ABC 55 2010-09-10
SH06 Shampoo XYZ 120 2012-04-09
FW12 Face Wash XYZ 95 2010-08-15
• Table: Client
C_ID ClientName City P_ID
1 Cosmetic Shop Delhi FW05
6 Total Health Mumbai BS01
12 Live Life Delhi SH06
15 Pretty One Delhi FW05
(i) Identify the attribute best suitable to be declared as a primary key from
the product table
(ii) Identify the foreign key and primary key from the table client
(ii) Write the degree and cardinality of the table product.