Professional Documents
Culture Documents
Dbms 1
Dbms 1
Data Semantics.
CIA
DBMS:
Advantages of DBMS
MCQ
An application where only one user accesses the database at a given time is an example of
a(n) ________ .
A
single-user database application
.
B.multiuser database application
C.e-commerce database application
D data mining database application
.
a
Data Independence:
The ability to modify a schema definition in one level without affecting a schema definition in the
next higher level is called a s data independence.
Changes to conceptual schema, such a addition of entry or deletion of new entries should be
possible without affecting existing external schema.
Data Models:
• Underlying the structure of a database is the Data Model:
A collection of conceptual tools for describing data, data relationships and consistency
constraints.
• A data model provides a way to describe the design of a database at the physical, logical and
view level.
1. Relational Model
Entity
An entity can be a real-world object, either animate or inanimate, that can be easily
identifiable. For example, in a school database, students, teachers, classes, and courses
offered can be considered as entities. All these entities have some attributes or properties that
give them their identity.
Attributes
Entities are represented by means of their properties, called attributes. All attributes have
values. For example, a student entity may have name, class, and age as attributes.
Types of Attributes
Simple attribute − Simple attributes are atomic values, which cannot be divided
further. For example, a student's phone number is an atomic value of 10 digits.
Composite attribute − Composite attributes are made of more than one simple
attribute. For example, a student's complete name may have first_name and
last_name.
Derived attribute − Derived attributes are the attributes that do not exist in the
physical database, but their values are derived from other attributes present in the
database. For example, average_salary in a department should not be saved directly in
the database, instead it can be derived. For another example, age can be derived from
data_of_birth.
Single-value attribute − Single-value attributes contain single value. For example −
Social_Security_Number.
Multi-value attribute − Multi-value attributes may contain more than one values.
For example, a person can have more than one phone number, email_address, etc.
Relationship
The association among entities is called a relationship. For example, an employee works_at a
department, a student enrolls in a course. Here, Works_at and Enrolls are called
relationships.
Entity
Entities are represented by means of rectangles. Rectangles are named with the entity set they
represent.
Imp terms
1. Composite
2. Multivalued (double eclipse)
3. Derived (dotted eclipse)
4. Dependent Entity
5. Weak Entity
Generalization
Specialization
ER Diagrams
EXAMPLES
Students in a Class:
Consumer and Supplier
People/Employee in a company:
Cardinality Ratio:
Number of relationship instances in which the entity can participate is defined as Cardinality
Ratio. The possible cardinality ratios are as follows. For the explanation let us consider, there
are two entity sets A and B. :
Degree:
The degree of relationship (also known as cardinality) is the number of occurrences in one
entity which are associated (or linked) to the number of occurrences in another.
1. one-to-one (1:1)
2. one-to-many (1:M)
3. many-to-many (M:N)
One-to-one (1:1)
This is where one occurrence of an entity relates to only one occurrence in another entity.
A one-to-one relationship rarely exists in practice, but it can. However, you may consider
combining them into one entity.
For example, an employee is allocated a company car, which can only be driven by that
employee.
One-to-Many (1:M)
Is where one occurrence in an entity relates to many occurrences in another entity.
For example, taking the employee and department entities shown on the previous page, an
employee works in one department but a department has many employees.
The normalisation process discussed earlier would prevent any such relationships but the
definition is included here for completeness.
For example, an employee may work on several projects at the same time and a project has a
team of many employees.
System - creating a session, table, etc. are all types of system privilege.
Object - any command or query to work on tables comes under object privilege. DCL
is used to define two commands. These are:
Grant - It gives user access privileges to a database.
Revoke - It takes back permissions from the user.
Transaction Control Language (TCL)
Transaction Control statements are used to run the changes made by DML statements. It
allows statements to be grouped into logical transactions.
Types of key:
2. Candidate key
In the EMPLOYEE table, id is best suited for the primary key. Rest of the attributes like
SSN, Passport_Number, and License_Number, etc. are considered as a candidate key.
. Super Key
Super key is a set of an attribute which can uniquely identify a tuple. Super key is a superset
of a candidate key.
4. Foreign key
Foreign keys are the column of the table which is used to point to the primary key of another
table.
. Domain constraints
Domain constraints can be defined as the definition of a valid set of values for an attribute.
The data type of domain includes string, character, integer, time, date, currency, etc. The
value of the attribute must be available in the corresponding domain.
Example:
The entity integrity constraint states that primary key value can't be null.
This is because the primary key value is used to identify individual rows in relation and if the
primary key has a null value, then we can't identify those rows.
A table can contain a null value other than the primary key field.
Example:
Example:
4. Key constraints
Keys are the entity set that is used to identify an entity within its entity set uniquely.
An entity set can have multiple keys, but out of which one key will be the primary key. A
primary key can contain a unique and null value in the relational table.
Example:
1. Domain Integrity
2. Entity Integrity Constraint
3. Referential Integrity Constraint
4. Key Constraints
1. Domain Integrity-
Domain integrity means the definition of a valid set of values for an attribute. You define
data type, length or size, is null value allowed , is the value unique or not for an attribute ,the
default value, the range (values in between) and/or specific values for the attribute.
This rule states that in any database relation value of attribute of a primary key can't be null.
EXAMPLE- Consider a relation "STUDENT" Where "Stu_id" is a primary key and it must
not contain any null value whereas other attributes may contain null value e.g "Branch" in the
following relation contains one null value.
It states that if a foreign key exists in a relation then either the foreign key value must match a
primary key value of some tuple in its home relation or the foreign key value must be null.
1. You can't delete a record from a primary table if matching records exist in a related
table.
2. You can't change a primary key value in the primary table if that record has related
records.
3. You can't enter a value in the foreign key field of the related table that doesn't exist in
the primary key of the primary table.
4. However, you can enter a Null value in the foreign key, specifying that the records are
unrelated.
EXAMPLE-
Consider 2 relations "stu" and "stu_1" Where "Stu_id " is the primary key in the "stu" relation
and foreign key in the "stu_1" relation.
Relation "stu"
Stu_id Duration
11255234 B TECH 4 years
11255369 B TECH 4 years
11255324 B TECH 4 years
11255237 B TECH 4 years
11255678 B TECH 4 years
4.Key Constraints-
A Key Constraint is a statement that a certain minimal subset of the fields of a relation is a
unique identifier for a tuple.