Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

MySQL Part 2

The document discusses various types of Database Management Systems (DBMS), focusing on the relational data model, which organizes data into interrelated tables known as relations. It explains key concepts such as tuples, attributes, primary keys, candidate keys, and foreign keys, emphasizing the importance of data integrity and the properties of relations. Additionally, it highlights the significance of referential integrity in maintaining valid data across related tables.

Uploaded by

mohitbhagtani05
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

MySQL Part 2

The document discusses various types of Database Management Systems (DBMS), focusing on the relational data model, which organizes data into interrelated tables known as relations. It explains key concepts such as tuples, attributes, primary keys, candidate keys, and foreign keys, emphasizing the importance of data integrity and the properties of relations. Additionally, it highlights the significance of referential integrity in maintaining valid data across related tables.

Uploaded by

mohitbhagtani05
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

MySQL Part - 2

Data Models
Different types of DBMS are available and their
classification is done based on the underlying data model.

Types of DBMS
Relational Data Model
(most widely used)
Object-oriented data model
Entity-relationship data model
Document model
Hierarchical data model.
Relational Data Model
Data is stored in the form of multiple inter-
related tables.

Tables are called relations.

Tables contain data stored in the form of rows


and columns.
Relation
A table containing logically related data,
arranged in the form of rows and columns.
Tuple
Each row of data in a relation (table) is called a
tuple or row or record.

Attribute
Characteristic or parameters for which data are to
be stored in a relation, is called the attribute or
field or column of a table.
Degree
The number of columns (Fields) of a table.

Cardinality
The number of rows (Tuples) of a table.
Domain
A pool (set) of values from which the actual
values of a column are derived.
Important Properties of a Relation
Properties of Columns/Attributes
Each attribute in a relation has a unique name.
Sequence of attributes in a relation is immaterial.

Properties of Rows/ Tuples


Each tuple in a relation is distinct. Thus, each tuple
of a relation must be uniquely identified by its
contents.
Sequence of tuples in a relation is immaterial.
Properties of Relations/ Tables

All data values in an attribute (column) must be of the


same data type.

A column's values are from the same domain.

Each data value associated with an attribute must be


atomic (contains single indivisible value).

A special value “NULL” is used to represent values that


are unknown or non-applicable to certain attributes.
For example, if a guardian does not share his or her
contact number with the school authorities, then
GPhone is set to NULL (data unknown).
Keys in a Relational Database
Primary key

The tuples within a relation must be distinct. That


is, there should be at least one attribute in which
data are distinct (unique) and not NULL.

A field or a combination of fields used to uniquely


identify each record of a database table is called a
primary key.
Candidate Key

A relation 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 as each of
them are candidates for the primary key.

All key combinations that are eligible to become a


primary key are called candidate keys.
Alternate key

Out of one or more candidate keys, one attribute is


chosen as the primary key. The remaining attributes in
the list of candidate keys are called the alternate keys.

Taking example of the relation GUARDIAN,


It has four attributes
No two guardians will have same phone number or same
GUID, hence, these two attributes are the candidate
keys.
In the relation GUARDIAN, suppose GUID is chosen as
primary key, then GPhone will be called the alternate
key.
Composite Primary Key
If no single attribute in a relation is able to uniquely
distinguish the tuples, then more than one attribute are
taken together as primary key. Such primary key
consisting of more than one attribute is called
Composite Primary key.

In relation ATTENDANCE,
Roll Number of same student will appear in another row for a
different date.
Similarly, AttendanceDate is repeated for each roll number.
However combination of these two attributes RollNumber
and AttendanceDate together would have unique value as on a
date for a student, attendance will be marked only once.
Hence {RollNumber, AttendanceDate} will make the
composite primary key.
Foreign Key
A foreign key is used to represent the relationship
between two relations. A foreign key is an
attribute whose value is derived from the
primary key of another relation.

The relation in which the referenced primary key


is defined is called primary relation or master
relation or parent relation.

The relation in which the foreign key is defined is


called the secondary relation or the detail relation
or child relation.
Referential integrity
A system of rules to ensure that the related tables
contain valid data and the user does not
accidentally delete / change related data.
Examples of common RDBMS

Open Source

You might also like