Rdbms
Rdbms
What is Database ?
A database is a collection of information—preferably related
information and preferably organized.
-a database is a structured object.
-the structured object consists of data and metadata
-the metadata is the structured part (table definition)
-data is the actual stored descriptive information.
NAME EDUCATION % OF Marks
SMITH M Tech 98
JONES B Tech 89
MILLER Phd 87
…. ...... ….
…. ...... ….
What is DBMS ?
(DataBase Management System)
The trick is to know what to look for—if you want to find the
address of a specific employee, you have to know which
employee to look for, or you can simply examine all
employees.
Tuples/
Record/
Row
Domain
Relational Databases
A relational database is organized as a
-set of tables of data and a
-mathematical language (relational algebra) – is
available to manipulate the tables.
The presentation of data in the form of tables is known as
a relation
A relation is made up of a number of tuples (rows) and
attributes (columns).
Domains are range of values which can appear in each
column are taken from the domain for that attribute.
Example :The AGE will be in the range 16 to 65, so the
domain of the AGE attribute will be an integer in the
range 16 to 65
Relational algebra
In addition to establishing and maintaining the individual
tuples, there are also facilities for manipulating entire
relations.
These operations form what is known as relational
algebra.
Typically, the operations of relational algebra allow us to:
•SELECT – extract tuples to form a new relation
•PROJECT – extract attributes to form a new relation
•JOIN – add attributes from one relation to another
relation
•PRODUCT – combine all the tuples of one relation will all
those of another relation
•UNION – join two relations to form a new relation
•INTERSECT – form a new relation from two relations
where the key values are the same
The formal language of relational algebra is mathematical
in form and differs from that of the commercial RDBMSs.
Database Model Design
Design is the process of ensuring that it all works without actually
building it. Design is a little like testing something on paper before
spending thousands of hours building it in possibly the wrong way.
Entities
TUTOR This DSD tells us that we
need to hold data about:
teaches on
•The tutors
•The courses, and
COURSE •The students
The information which we
attended by need to know about each
entity are its attributes
STUDENT
A data structure diagram showing attributes
Tutor number
Name
TUTOR Address
Subjects taught
teaches on
Title
COURSE Examinations available
attended by
Student enrolment number
Name
Address
STUDENT Telephone number
Subjects studied
Relationships
An entity does not exist in isolation, but is associated with
other entities by means of a relationship.
On a DSD the entities are linked, one to another, by lines
representing the relationships.
The relationships in our DSD are:
•teaches on - One tutor teaches on many courses.
•is attended by - Each course is attended by many
students.
Note that the arrowed lines point from the one end to the
many end: from the one tutor to the many courses,
and from the one course to the many students.
Types of relationship
2. One-to-one relationship
3. One-to-Many relationship
4. Many-to-Many relationship
One-to-One Relationship
Better transformation of one-to-one relationship
One to Many Relationship
Correct transformation of one-to-many relationship
Many to Many ?
Many to Many ….?
Transformation of many-to-many relationship
TWO One – Many Relationship
Navigating through a data structure diagram
In any data structure diagram, it should be possible
conceptually to navigate from entity to entity by
way of the relationships.
By doing this, we shall be creating paths by which
the DBMS – or our programs – can access the data
and use these paths to answer enquiries about the
data.
COMPANY ORDER
PRODUCT LINEITEM
ord_no lineno prodid qty sellprice
prodid prodname sellprice costprice
P1 Mouse 350 300 101 1 P1 2 350