Chapter 6 Introduction To Database
Chapter 6 Introduction To Database
Chapter 6 Introduction To Database
Database
Data Information
• Data are raw facts (INPUT) • Information is processed
data (OUTPUT)
• Data are usually in • Information is usually in
unorganized form organized form
Relationships
Attributes
Key Attribute
Derived Attribute
E-R diagram for Library Management
System
• Entities: Book, Student, Librarian
• Attributes
– Book (B_code, B_title, B_price, B_author, B_edition,
B_publication)
– Student (S_roll, S_name, S_gender, S_phone, S_dob,
S_address, S_program)
– Librarian (L_id, L_name, L_shift, L_phone, L_gender,
L_address)
S_name B_title
S_roll B_code B_author
S_phone
Librarian
L_id L_phone
L_name
Loan
E_id
C_name applies approves
C_phone E_name
C_id creates/
requests
verifies
A_no A_type
Account
Fig: ER diagram of Banking System
E-R diagram for Hospital Management
System
• Entities: Doctor, Patient, Ward, Medicine, Employee
• Attributes:
– Doctor (D_id, D_name, D_dept, D_specilization, D_phone,
D_address, D_gender)
– Patient (P_id, P_name, P_phone, P_gender, P_address)
– Ward (W_id, W_name, W_type)
– Medicine (M_id, M_name, M_price, M_mdate, M_edate,
M_company)
– Employee (E_id, E_degsination, E_name, E_dept,
E_gender)
W_name
W_id W_type
E_name
E_id
Ward
manages
P_id
Employee assigned
admits
E_dept Patient
E_degn
hires
P_name
attends
takes/
bills
M_name
Doctor
prescribes
Medicine
D_id M_id
D_name
Fig: ER diagram of Hospital Management
D_phone System
E-R diagram for College Management
System
• Entities: Student, Course, Lecturer, Admin
• Attributes:
– Student (S_id, S_name, S_program, S_address, S_dob,
S_gender, S_phone, S_email)
– Course (C_code, C_name, C_credit)
– Lecturer (L_id, L_name, L_qualification, L_experience,
L_email, L_dept)
– Admin (A_id, A_designation, A_phone, A_address,
A_email, A_dept)
L_name
L_id L_dept
C_id
Lecturer
S_name facilitate
evaluates s
registers
Student Course
S_phone C_name
S_id
admits
A_name offers
A_id
Admin
A_dept A_degn
{
Emp001 Ram Newroad M
Emp002 Rita Kalanki F tuples/records
body Emp003 Gopal Gaushala M
Foreign Key
• A foreign key refers to a field (in a referencing table) that uniquely
identifies a primary key field of some other table (referenced table).
• It establishes a link between records in two different tables in a
database.
• A foreign key is a reference to a key in another table meaning that the
referencing table has, as one of its attributes, the values of a key in
the referenced table.
Foreign Key
• The figure below shows relational model. Primary
Primary Key
Manager
Employee Key
MID Mdept Mlevel EmpID
EmpID EmpName EmpAdd EmpGdr
M01 Finance M1 Emp002
Emp001 Ram Newroad M
M02 Marketing M2 Emp004
Emp002 Rita Kalanki F
M03 Operations M1 Emp005
Emp003 Gopal Gaushala M
Emp004 Shyam Koteshwor M Referencing relation
Emp005 Hari Patan M
Referenced relation
• Here, EmpID and MID are the primary keys in Employee table
and Manager table respectively.
• These two tables are interlinked through EmpID attribute in
the Manager table, which is a foreign key in Manager table.
• Database management system packages based on the
relational model can link data elements from various tables to
provide information to users.
• The relational model can relate data in any one file with data
in another file if both files share a common data element or
field.
• Because of this, information can be created by retrieving data
from multiple files even if they are not all stored in the same
physical location.
Basic Operations on Relational Databases
There are three operations on relational databases:
• The SELECT operation selects all records in a table that meet a
certain criterion
• The JOIN operation joins or links two or more tables
• The PROJECT operation creates a subset of columns designed
to meet the information needs of the user
THANK YOU!!