You are on page 1of 2

Q1. Explain relational database and advantages of relational database.

Explain
different types of relationship.

Answer

Relational Database
A database is a means of storing information in such a way that information can be retrieved from it. In simplest
terms, a relational database is one that presents information in tables with rows and columns. A table is referred to
as a relation in the sense that it is a collection of objects of the same type (rows). Data in a table can be related
according to common keys or concepts, and the ability to retrieve related data from a table is the basis for the term
relational database. A Database Management System (DBMS) handles the way data is stored, maintained, and
retrieved. In the case of a relational database, a Relational Database Management System (RDBMS) performs
these tasks. DBMS as used in this book is a general term that includes RDBMS.

Relationship types
You share many relationships with members of your family. For instance, you and your mother are related. You have
only one mother, but she may have several children. You and your siblings are relatedyou may have many brothers
and sisters and, of course, they'll have many brothers and sisters as well. If you're married, both you and your spouse
have a spouseeach otherbut only one at a time. Database relationships are very similar in that they're
associations between tables. There are three types of relationships:

One-to-one: Both tables can have only one record on either side of the relationship. Each primary key value relates
to only one (or no) record in the related table. They're like spousesyou may or may not be married, but if you are,
both you and your spouse have only one spouse. Most one-to-one relationships are forced by business rules and
don't flow naturally from the data. In the absence of such a rule, you can usually combine both tables into one table
without breaking any normalization rules.

One-to-many: The primary key table contains only one record that relates to none, one, or many records in the
related table. This relationship is similar to the one between you and a parent. You have only one mother, but your
mother may have several children.

Many-to-many: Each record in both tables can relate to any number of records (or no records) in the other table.
For instance, if you have several siblings, so do your siblings (have many siblings). Many-to-many relationships
require a third table, known as an associate or linking table, because relational systems can't directly accommodate
the relationship.

Advantages of a relational database


Splitting data into a number of related tables brings many advantages over a flat file database. These include:

1. Data is only stored once. In the previous example, the city data was gathered into one table so now there is only
one record per city. The advantages of this are

No multiple record changes needed


More efficient storage

Simple to delete or modify details.

All records in other tables having a link to that entry will show the change.
2. Complex queries can be carried out. A language called SQL has been developed to allow programmers to
'Insert', 'Update', 'Delete', 'Create', 'Drop' table records. These actions are further refined by a 'Where' clause. For
example

SELECT * FROM Customer WHERE ID = 2

This SQL statement will extract record number 2 from the Customer table. Far more complicated queries can be
written that can extract data from many tables at once.

3. Better security. By splitting data into tables, certain tables can be made confidential. When a person logs on with
their username and password, the system can then limit access only to those tables whose records they are
authorised to view. For example, a receptionist would be able to view employee location and contact details but not
their salary. A salesman may see his team's sales performance but not competing teams.

4. Cater for future requirements. By having data held in separate tables, it is simple to add records that are not yet
needed but may be in the future. For example, the city table could be expanded to include every city and town in
the country, even though no other records are using them all as yet. A flat file database cannot do this.

You might also like