Unit 3 Relational Database Design
Unit 3 Relational Database Design
RELATION
A relation consist of
1. Relational scheme
2. Relational instances.
ATRIBUTE
The name of each column in a database is used to interpret its meaning is called
attribute.
DOMAIN
TUPLE
DEGREE/ARITY
The no. of attributes in the relation scheme is called its degree or arity.
CARDINALITY
KEY
relation.
Types of keys:
1) SUPER KEY: A super key is an attribute or any set of attributes that uniquely
2) COMPOSITE KEY: A composite key is a key that contains more than one attribute.
key.
4) PRIMARY KEY: A primary key is a candidate key which can uniquely identify a
record or tuple. Each table can have only one primary key. The primary key should be
5) ALTERNATE KEY: The alternate keys of any table are those candidate keys which
6) OVERLAPPING KEY: The keys having common attributes are called overlapping
key.
7) FOREIGN KEY: Foreign key is a referential key which must be a primary key of
another table. This way we can link two tables for retrieving the data jointly. we only
insert those values which are present in the base table. If we delete the base table
automatically the the foreign key and primary key relationship is broken.
Rule 4: The Dynamic/Active Online Catalog on the basis of the Relational Model
Rule 5: The Comprehensive Data SubLanguage Rule
Rule 7: The Relational Level Operation (or High-Level Insert, Delete, and Update) Rule
Constraints can’t be referred to as a system of relational DBs because every DB has tables. A DB
that solely contains a relational data model cannot be called a Relational DB Management
System or RDBMS. Some rules determine if a DB is the correct RDBMS. Dr Edgar F. Codd,
who has extensive knowledge on the DB system’s Relational Model, proposed these principles in
1985. Codd presents his 13 criteria for a DB to evaluate the concept of a DB Management
System (DBMS) against the relational model. A DB that follows the rule is referred to as a real
relational DB management system (RDBMS). Codd’s rules are a set of rules that are widely used
in relational DBs.
The DB must be structured in a relational manner so that the system’s relational capabilities can
manage the DB.
A DB comprises a variety of data, which must be recorded in the form of columns and rows in
each and every cell of a table.
A relational DB’s primary key value, column name, and table name can be used to conceptually
retrieve any single or precise data (the atomic value).
The treatment of Null values in DB records is defined by this rule. No value in a cell, missing
data, unsuitable information, unknown data, the primary key that should not be null, etc., are all
examples of null values in DBs.
Rule 4: The Dynamic/Active Online Catalog on the basis of the Relational Model
The relational DB supports a variety of languages, and in order to access the DB, the language
has to be linear, explicit, or a well-defined syntax, character strings. It must support the
following operations:
Data definition.
View definition.
Integrity constraints.
Authorization.
It is considered a DB violation if the DB permits access to the data and information without the
use of any language.
A relational system may support several languages and various modes of terminal use (for
example, the fill-in-the-blanks mode). However, there must be at least one language whose
statements are expressible, per some well-defined syntax, as character strings and that is
comprehensive in supporting all of the following items:
A view table can theoretically be updated, and DB systems must update them in practice.
Rule 7: The Relational Level Operation (or High-Level Insert, Delete, and Update) Rule
In each level or single row, a DB system should adhere to high-level relational operations (for
example, update, insert, and delete). The DB system also includes operations like intersection,
union, and minus.
To access a DB or an application, all stored data must be independent physically. Each piece of
data should not be reliant on another piece of data or an application. External applications that
access data from the DB will have no effect if data is altered or the physical structure of a given
DB is modified.
It’s similar to the independence of physical data. It indicates that any modifications made at the
logical level (or the table structures) should not have an impact on the user’s experience
(application). For example, if a table is split into two separate tables or into two table joins in
order to produce a single table, the application at the user view should not be affected.
When we are using SQL to put data into table cells, a DB must guarantee integrity independence.
All the entered values must not be changed, and the integrity of the data should not be reliant on
any external component or application. It’s also useful for making each front-end app DB-
independent.
This rule denotes that a DB must function properly even if it’s stored in multiple locations and
used by various end-users. Let’s say a person uses an application to access the DB. In such a
case, they must not be aware that another user is using the same data, and thus, the data they
always obtain is only available on one site. The DB can be accessed by end-users, and each
user’s access data must be independent in order for them to run SQL queries.
RDBMS is defined by this rule as a SQL language for storing and manipulating data in a DB. If a
system uses a low-level or different language to access the DB system other than SQL, it should
not bypass or subvert data integrity.
Key Constraint
Domain Constraint
1. Key Constraint
Every table or relation in a database should have at least one attribute or a set of attributes which
uniquely identifies a record. Those attributes or a set of attributes is called key.
For example, rollno in the table ‘Student’ is a key. Two students cannot have the same roll
number. So, a key has two features:
2. Domain Constraint
Domain constraints are the attribute level constraints. A domain is a collection of possible values
for an attribute in the database table. An attribute or a field in a table can accept only those
values which are inside the domain range.
For example, in the below table Student, the rollno attribute has an integer domain so that an
attribute or a field cannot accept values that are not integers,i.e., rollno cannot have values
like10.11, ‘first’, etc.
3. Entity Integrity Constraint
Entity constraint specifies that the value of the primary key cannot be NULL. Because, if the
primary key has a NULL value, you cannot identify those rows. A field other than the primary
key field in a relation can have a NULL value.
Example: In the below table, Student, suppose rollno is the primary key. Thus, from the
definition of Entity Integrity constraint, the value of rollno cannot be null as it uniquely identifies
each record in the table.
Table: Student
A referential integrity constraint is a specified relationship between two tables. It can be defined
as when one field of a relation in a database can take the values from another field in the same
table or another table. The relationship between the database tables is established by the foreign
key.
Example:
Consider two relations Student and Course where rollno is the primary key in the Student table
and foreign key in the Course table.
C1 MCA 101
C2 MBA 102
C3 MCA 103
C4 MCA 104