0% found this document useful (0 votes)
4 views

Sneha

C programming

Uploaded by

xzbunny1991
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Sneha

C programming

Uploaded by

xzbunny1991
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

DATABASE DESIGN

Presenting by: Sneha C


Relational database
 A RDBMS is a database that organizes data in tables or relations
of columns & rows and shows how different data structures
related to each other
 Here the data is structured in the form of tables, Rows, Columns,
Primary key, Foreign key, Relationships, Normalization
 Customer table:

C-id C-Name Billing Shipping


address address

Order table:
O-id C-id Order date Shipping date
Relational database keys

 Types:
1. Super key
2. Candidate key
3. Primary key
4. Alternate key
5. Unique key
6. Composite key
7. Foreign key
.

Super key:
 It is a set of one or more attributes in a table that can be
uniquely identify a row in that table. In other words, a super key
can uniquely distinguish every tuple(row) in a relation(table)
 A super key can consists of a single attribute or a combination of
attributes. However, it may contain unnecessary attributes

ID Name SSN Salary Phone no. email


101 Mary 123456789012 30000 7018345643 mary@123
102 John 981234567034 25000 6360123404 john@453
103 Mary 543126754897 45000 9900765488 my@342
104 Raj 301276325678 70000 7019345977 raj@987
.

Candidate key:
 The minimal super keys are called Candidate keys. It means a set
of one or more columns in a table that can be uniquely identify a
record, but it contains no unnecessary attributes
 There can be multiple candidate keys in a table, but only one of
them is selected to be the primary key
.

Primary key:
 It is the specific type of candidate key that is chosen to uniquely
identify each record in a table
 It ensures that no duplicate or Null values exist for the primary
key column, making it the main unique identifier for records in
the table
 Student Table:

Stud_id Stud_name Email

101 Priya pri@124


102 Preethi Preethi@190
.

Alternate key:
 The candidate key other than primary key

Unique key:
 It is a database constraint that ensures the values in a column(s)
are unique across all rows in the table
 Unlike a primary key, a unique key can accept one null value, but
all other non-null values must be distinct
Composite key:
.

 It is a type of database key that consists of two or more columns


used together to uniquely identify a row in a table
 Unlike a primary key made up of a single column, a composite
key combines multiple columns to ensure that each combination
of values in these columns is unique across the table
.

Foreign key:
 Is a column or a set of columns in a database table that
establishes a link between the data in two tables.
 The foreign key in one table refers to the primary key in another
table
 This relation enforces the referential integrity
 Customers
cust_id cust_name
1001 John
1002 Smith

Orders
Order-id Cust-id Order-date
1 1001 24-11-2024
2 1002 25-11-2024
DEALING WITH
CONSTRAINT VIOLATIONS

 .
.r

 Here we will learn about the violations that can


occur on a database as a result of any changes
made in the relation
 There are mainly 3 operations that have the ability
to change the state of relations, these operations
are:
1. Insert operation
2. Delete operation
3. Update(Modify) operation
Insert Operation:
.
 To insert new tuples in a relation in the database
 On inserting the tuples in the relation, it may cause
violation of the constraints in the following way:
 Domain constraint:
• Domain constraint gets violated only when a given
value to the attribute does not appear in the
corresponding domain or in case it is not of the
appropriate datatype
• EmployeeName
Emp id
Table Age Phone DNo
101 Aisha 24 656474904 1
3
102 Bindu 25 658930130 2
8
103 Lakshmi 24 901463892 A
.

Department Table:
DNo Dname Location
1 CSE Banglore
2 MECH Banglore
 Entity Integrity constraint:

• On inserting NULL values to any part of the primary


key of a new tuple in the relation can cause violation
of the entity integrity constraint
• Employee Table
.

 Key constraints:
• On inserting a value in the new tuple of a relation
which is already existing in another tuple of the
same relation, can cause violation of key constraints
• Employee Table:
 Referential integrity:
• On inserting a value in the foreign key of relation 1,
for which there is no corresponding value in the
Primary key which is referred to in relation 2, in
such case Referential integrity is violated
.

 Delete Operation:
 To delete some of the existing relation on the
database
 Referential integrity constraints:
• It causes violation only if the tuple in relation 1 is
deleted which is referenced by foreign key from
other tuples of table 2 in the database, if such
deletion t takes place then the values in the tuple of
the foreign key in table 2 will become empty, which
will eventually violate referential integrity constraint
 Update Operation:
 . To make changes in the value of some existing
tuples
.

THANK
YOU

You might also like