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

sonu dbms

The document outlines a Database Management System lab course focusing on implementing Data Definition Language (DDL) and Data Manipulation Language (DML) commands. It includes practical exercises for creating, altering, and managing database tables, along with constraints and relationships between tables. Key operations such as inserting, updating, and deleting records are demonstrated, emphasizing the importance of data integrity and referential constraints.

Uploaded by

24335a0512
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

sonu dbms

The document outlines a Database Management System lab course focusing on implementing Data Definition Language (DDL) and Data Manipulation Language (DML) commands. It includes practical exercises for creating, altering, and managing database tables, along with constraints and relationships between tables. Key operations such as inserting, updating, and deleting records are demonstrated, emphasizing the importance of data integrity and referential constraints.

Uploaded by

24335a0512
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

WEEK-1
Date: 11-12-2024

1. Implement DDL commands to work with Database.

Aim : To implement DDL in DBMS software to work with a database.

Description :
DDL (Data Definition Language) is a set of SQL commands used to define and modify the
structure
of a database. It is used to create, alter, and drop database objects such as tables, indexes,
views,
and relationships.

Types of DDL Commands:

1. CREATE: Creates a new database object, such as a table, index, or view.


Example: CREATE TABLE customers (id INT, name VARCHAR(255));
2. ALTER: Modifies the structure of an existing database object.
Example: ALTER TABLE customers ADD COLUMN email VARCHAR(255);
3. DROP: Deletes a database object.
Example: DROP TABLE customers;
4. TRUNCATE: Deletes all rows from a table and resets the auto-incrementing ID.
Example: TRUNCATE TABLE customers;
5. RENAME: Renames a database object.
Example: RENAME TABLE customers TO clients;

DML (Data Manipulation Language)

DML is used to manipulate the data in the database, such as inserting, updating, or retrieving
records. DML commands focus on managing and modifying the data within tables.

DML Commands

1. INSERT: Adds new records into a table by specifying the values for each column.

2· UPDATE: Updates existing data in a table based on specified conditions.

Department of Computer Science & Engineering, MVGR College of Engineering(A)

1
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

3· DELETE: Removes specific records from a table without affecting its structure.

4· SELECT: Retrieves data from one or more tables based on specified criteria.

COMMAND CREATE

SYNTAX create database “database mvgr”;

QUERY create database mvgr;

OUTPUT

OBSERVATIONS ●​ This command tells the database management system to switch to the
specified database, allowing you to access its tables, views, and other
objects.

COMMAND CREATE

SYNTAX create table table_name(value datatype);

QUERY create table student(snum varchar(15),sname char(20),smarks int);

OUTPUT

OBSERVATIONS ●​ SQL Keywords are Case-Insensitive


●​ In SQL, keywords such as SELECT, FROM, WHERE, USE,
CREATE, and others can be written in either:
●​ - Uppercase (e.g., SELECT, USE, CREATE)
●​ - Lowercase (e.g., select, use, create)

Department of Computer Science & Engineering, MVGR College of Engineering(A)

2
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

COMMAND ALTER + ADD

SYNTAX Alter table “table_name” add column_name datatype ;

QUERY alter table student add column email varchar(30);

OUTPUT

OBSERVATIONS ●​ Alter with modify used to change the datatype and change the size if
mentioned.

COMMAND ALTER + MODIFY

SYNTAX Alter table “table_name” modify column_name datatype ;

QUERY alter table student modify smarks varchar(15);

OUTPUT

OBSERVATIONS ●​ The ALTER TABLE command is used to modify the structure and data
of an existing table.

COMMAND ALTER + RENAME

SYNTAX Alter table “table_name” rename oldname to newname;

QUERY alter table student rename column snum to s_id;

Department of Computer Science & Engineering, MVGR College of Engineering(A)

3
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

OUTPUT

OBSERVATIONS ●​ The ALTER TABLE command is used to modify the structure and data
of an existing table.

COMMAND RENAME

SYNTAX Rename table “oldtable_name” to “new_name”;

QUERY alter table std rename student;

OUTPUT

OBSERVATIONS ●​ The RENAME command, used in conjunction with the ALTER


command, enables you to rename:

COMMAND DROP

SYNTAX Drop table “table_name” ;

QUERY drop table student1;

Desc student1;

OUTPUT

OBSERVATIONS ●​ When you use the DROP command, the specified table is
permanently deleted from the database. This action:.

Department of Computer Science & Engineering, MVGR College of Engineering(A)

4
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

COMMAND TRUNCATE

SYNTAX Truncate table “table_name” ;

QUERY Truncate table student;

OUTPUT

OBSERVATIONS Immediately removes all data from a table


- Works regardless of the table's current data state (empty or
populated)
- Does not require a WHERE clause
- Cannot be rolled back (undo)
- Is generally faster and more efficient

COMMAND INSERT

SYNTAX Insert into “table name” values ( data_value data_type) ;

QUERY insert into student


values('A3','sonu','85','[email protected]'),('D1','Madhu','95','madhu@gmail.
com');

OUTPUT

OBSERVATIONS ●​ Here we can insert all the values at a time and also we can insert some
specific values based on our requirement in the table by using insert
command.
●​ When we insert values in some specific cells then remaining will be

Department of Computer Science & Engineering, MVGR College of Engineering(A)

5
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

null.

COMMAND UPDATE

SYNTAX update “table_name” set column1 = value1, column2 = value2, .. where condition;

QUERRY update student set sname='kitty' where s_id='D2';

OUTPUT

OBSERVATI ●​ The UPDATE command allows you to modify existing data in a table. If no condition is
ONS specified or if there's an error in the condition:
●​ The entire column will be updated with the new value.
●​ All rows in the table will be affected.
●​

Department of Computer Science & Engineering, MVGR College of Engineering(A)

6
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

WEEK-2
Date: 18-12-2024

Aim: Conversion of relations to relational tables with referential constraints.

Description :
On update cascade : When a value in the parent table is updated, the corresponding values in
the
child table are automatically updated to match the new value.
On delete cascade : When a row in the parent table is deleted, the corresponding rows in the
child
table are automatically deleted as well.

1 Create EMPLOYEE table with following schemas:


EMPLOYEE (eno primarykey, ename not null, Email unique, dept, doj , salary check(salary
>5000), city default ‘chicago’)

Query CREATE TABLE employee(eno int primary key,ename char(40) not null,email varchar(20)
unique,dept char(10),doj date,salary int check(salary>5000),city char(15) default 'Chicago');

Output

Department of Computer Science & Engineering, MVGR College of Engineering(A)

7
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

2 Alter table add new column phnumber.

Query alter table employee add column pno bigint;

Output

3
Insert the following data in the table based on constraints

Query insert into employee values(101,'Johndoe','[email protected]',


'HR','2020-06-15',55000,'New York',12345),(102,'Jane Smith',
'[email protected]','Finance','2019-09-22',72000,'Chicago',23456),(103,
'Alice Johnson','[email protected]','IT','2021-01-10',
80000,'San Francisco',34567),(104,'BobBrown',
'[email protected]','Marketing','2018-03-05',60000,'LosAngeles',45678
),(105,'Charliewhite','[email protected]','Sales','2022-07-30',48000,'
Miami',56789);

Department of Computer Science & Engineering, MVGR College of Engineering(A)

8
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

Output

4
Insert (105, 'David Clark', '[email protected]', 'IT', '2020-11-20',
5000.00, 'Seattle')

Query insert into employeevalues(105,'Davidclark'


,'[email protected]',
'IT','2020-11-20',95000.00,'Seattle',124587);

Output

Department of Computer Science & Engineering, MVGR College of Engineering(A)

9
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

5
●​ Attempt to insert (107,’’,'[email protected]', 'HR',
'2021-03-15', 62000.00, 'Austin'), and observe the result

Query insert into employee values(107,'','[email protected]',


'HR','2021-03-15',62000.00,'Austin',12345);

Output

6
Attempt to insert (108, 'Frank Miller', '[email protected]', 'Finance',
'2017-08-05', 2500.00, 'Boston'), and observe the results

Query insert into employee values(108,'Frank miller','[email protected]',


'Finance','2017-08-05',2500.00,'Boston',124589);

Output

Department of Computer Science & Engineering, MVGR College of Engineering(A)

10
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

7
Attempt to insert (109, 'Grace Lee', '[email protected]', 'Sales',
'2023-02-01', 51000.00), and display the table.

Query insert into employee(eno,ename,email,dept,doj,salary,pno)values(109,


'Grace Lee', '[email protected]', 'Sales', '2023-02-01',
51000.00,124568);

Output

Department of Computer Science & Engineering, MVGR College of Engineering(A)

11
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

8
Without department information Insert remaining values into table (110,
'Helen Taylor', '[email protected]', '2016-12-10', 67000.00, 'San
Diego') and display the table.

Query insert into employee(eno,ename,email,doj,salary,city,pno)values(110, 'Helen


Taylor', '[email protected]','2016-12-10', 67000.00, 'San
Diego',124578);

Output

9
Now insert the Dept ‘marketing’ using update command for emp no 110 and
display the table

Query update employee set dept='marketing' where eno=110;

Department of Computer Science & Engineering, MVGR College of Engineering(A)

12
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

Output

10
Delete some records and display the table

Query
delete from employee where eno<104;

Output

Department of Computer Science & Engineering, MVGR College of Engineering(A)

13
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

11
Update the city of Emp no 105 with current city as New York.

Query update employee set city='New York' where eno=105;

Output

12
Display the details of Employee.

Query
select * from employee;

Output

Department of Computer Science & Engineering, MVGR College of Engineering(A)

14
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

13
Delete the email_id of employee John Doe.

Query update employee set email=null where eno=105;

Output

EXP 2

Department (DeptID, DeptName, Location)

1
Set DeptID as a primary key.

Department of Computer Science & Engineering, MVGR College of Engineering(A)

15
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

DeptName should be set to NOTNULL

Add a new column “Manager” with a unique constraint to the department table

Query CREATE TABLE department(deptid int primary key,deptname


char(16) not null, location char(15));
alter table department add column
(manager char(20) unique);

Output

WORKSIN

Eno Dept ID
101 1
102 2
103 3
102 4
104 5

1
Create table WORKSIN with the following fields

Eno foreign key references Employee, DeptID foreign key references Department
table

Query create table worksin(eno int, deptid int, foreign key (eno) references employee(eno),
foreign key (deptid) references department(deptid));

Department of Computer Science & Engineering, MVGR College of Engineering(A)

16
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

Output

ON UPDATE AND ON DELETE CASCADE OPERATIONS:

1
Creating a table dept with deptid set to PRIMARY KEY and deptname set to
NOTNULL and inserting some values in to the relational table.

Query CREATE TABLE dept(deptid int,deptname char(16) not null);


insert into dept values(1,'finance'),(2,'marketing'),(3,'software-dev');

Output

Department of Computer Science & Engineering, MVGR College of Engineering(A)

17
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

2 Creating table emp having eno as primary key, deptno as foreign key referred fr
dept

Query CREATE table emp(eno int primary key,ename char(30),deptno int,foreign


key(deptno) references dept(deptid) on update cascade on delete cascade );
insert into emp values
(501,'ram',1),(502,'tom',1),(503,'jack',2),(504,'harry',3),(505,'peter',3);

Output

ON DELETE CASCADE:
1 Delete from the dept table where deptid=1 and check in the emp table
the corresponding row deleted in the emp table.

Query delete from dept where deptid=1;

Output

Dept table -
ON

Emp table -

UPDATE CASCADE:

Department of Computer Science & Engineering, MVGR College of Engineering(A)

18
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

1 Update the deptid 3 from dept table to 4 and check whether its been
changed in emp table or not.

Query ate dept set deptid=4 where deptname='software-dev';

Output

Dept table -

Emp table -

OBSERVATION:
1. Table Creation and Constraints:
- Successful creation of Employee table with constraints (PRIMARY KEY, NOT NULL,
UNIQUE, DEFAULT, CHECK) ensures data integrity.
- Adding a new column (phnumber) and renaming an existing column (Email to Email_id)
demonstrates table modification capabilities.
2. Data Insertion and Constraint Enforcement:
- Insert operations demonstrate enforcement of PRIMARY KEY, NOT NULL, and CHECK
constraints.
- Errors occur when violating these constraints, ensuring data consistency.
3. Data Update and Deletion:
- Successful updates and deletions demonstrate data manipulation capabilities.
- FOREIGN KEY constraints prevent deletion of referenced data, maintaining referential
integrity.
4. Table Relationships and Joining:
- Creation of Department table and establishment of relationships with Employee table
demonstrate entity-relationship modeling.
- Inner join operation retrieves related data from both tables, showcasing data integration.

Department of Computer Science & Engineering, MVGR College of Engineering(A)

19
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

5. Referential Integrity and Constraint Enforcement:


- FOREIGN KEY constraints prevent invalid department assignments and deletion of referenced
departments.
- Checks and constraints ensure data consistency and prevent errors.
These observations highlight the importance of database design, constraint enforcement, and data
manipulation operations in maintaining a robust and reliable database system.

Department of Computer Science & Engineering, MVGR College of Engineering(A)

20
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

WEEK-3 Date : 22-01-2025

AIM : Implement the following queries to understand the usage of SELECT , WHERE,
BETWEEN ,AND, LIKE operators.

Description:

SELECT Operator
The SELECT operator is used to select data from a database table. It specifies which columns to
retrieve
and can also be used to perform calculations, aggregations, and transformations on the data.
Syntax
SELECT column1, column2, ...
FROM tablename;
Example
SELECT ename, salary
FROM employee;

WHERE Operator
The WHERE operator is used to filter data based on conditions. It specifies which rows to include in
the
result set.
Syntax
SELECT column1, column2, ...
FROM tablename
WHERE condition;

Example
SELECT ename, salary
FROM employee
WHERE salary > 50000;

Department of Computer Science & Engineering, MVGR College of Engineering(A)

21
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

BETWEEN Operator
The BETWEEN operator is used to select data within a specified range. It includes the start and end
values.
Syntax
SELECT column1, column2, ...
FROM tablename
WHERE columnname BETWEEN startvalue AND endvalue;
Example
SELECT ename, salary
FROM employee
WHERE salary BETWEEN 30000 AND 70000;

AND Operator
The AND operator is used to combine multiple conditions. It returns true only if all conditions are
met.
Syntax
SELECT column1, column2, ...
FROM tablename
WHERE condition1 AND condition2 AND ...;
Example
SELECT ename, salary
FROM employee
WHERE salary > 50000 AND deptno = 1;

LIKE Operator

The LIKE operator is used to search for patterns in strings. It uses wildcard characters such as % and

_.Syntax
SELECT column1, column2, ...
FROM tablename
WHERE columnname LIKE pattern;

Department of Computer Science & Engineering, MVGR College of Engineering(A)

22
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

Example
SELECT ename, email
FROM employee
WHERE ename LIKE '%a%';
These operators are fundamental to SQL and are used to manipulate and retrieve data from
databases.

DEPARTMENT TABLE:

EMPLOYEE TABLE:

Department of Computer Science & Engineering, MVGR College of Engineering(A)

23
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

1 Display the employee names and mail id’s who are working in CSE depadepartment.

Query select ename, email from employee where deptno = (select deptid from department
where deptname='cse');

Output

2 Display the record of each employee who works in CSE and ECE.

Query select * from employee where deptno in (select deptid from department where deptname=
cse' and deptname='ece');

Output

3 Display the record of each employee who works in CSE or ECE

Query select * from employee where deptno in (select deptid from department where deptname=

'cse' or deptname='ece');

Department of Computer Science & Engineering, MVGR College of Engineering(A)

24
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

Output

4 Calculate a 10% bonus for all employees and display their updated salaries (Salary * 1.1)

Query update employee set salary=salary*1.1;

Output

Department of Computer Science & Engineering, MVGR College of Engineering(A)

25
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

5 ​ Compute the yearly salary for all employees (Salary * 12).

Query select ename, salary*12 as annualsalary from employee ;

Output

6 Subtract 1000 from the salary of employees who joined before '2020-01-01'.

Query update employee set salary=salary-1000 where joindate < '2020-01-01';

Department of Computer Science & Engineering, MVGR College of Engineering(A)

26
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

Output

7 Add 5000 to the salary of employees in the "HR" department.

Query update employee set salary=salary+5000 where deptno=(select deptid from department
Where deptname='hr');

Output

8 ​ Retrieve details of employees whose salary is greater than 50,000 and who work in
having deptid 2 department.

Query select * from employee where salary>50000 AND deptno=(select deptid from departm
where deptname='it');

Department of Computer Science & Engineering, MVGR College of Engineering(A)

27
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

Output

9 ​ Find employees who joined after '2021-01-01' or whose salary is less than 40,000.

Query select * from employee where joindate>'2021-01-01' or salary<40000;

Output

10 ​ Fetch employees whose department is not located in 'New York'.

Query select * from employee where deptno!=(select deptid from department where
location='newyork');

Department of Computer Science & Engineering, MVGR College of Engineering(A)

28
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

Output

11 ​ Display employees whose salary is greater than 60,000.

Query select * from employee where salary>60000;

Output

12 ​ Retrieve employees who work in the "Sales" department or have a salary between
30,000 and 70,000.

Department of Computer Science & Engineering, MVGR College of Engineering(A)

29
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

Query select * from employee where (salary>30000 and salary<70000) or deptno=(select


deptid from department where deptname='sales');

Output

13 Find employees whose JoinDate is earlier than '2020-01-01'.

Query select * from employee where joindate<'2020-01-01';

Output

14 .​ Select employees who are earning less than 25,000

Query select * from employee where salary <25000;

Department of Computer Science & Engineering, MVGR College of Engineering(A)

30
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

Output

15 ​ Fetch employees whose salary equals 50,000.

Query select * from employee where salary=50000;

Output

16 .​ Find employees whose first name starts with 'A'.

Query select ename from employee where ename like 'A%';

Output

17 Retrieve employees whose last name ends with 'n'.

Department of Computer Science & Engineering, MVGR College of Engineering(A)

31
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

Query select ename from employee where ename like '%n';

Output

18 ​ Fetch employees whose first name contains 'h' anywhere in the name.

Query select ename from employee where ename like '%h%';

Output

19 ​ Find employees whose first name contains a literal %.

Query select ename from employee where ename like '%\%%' ;

Department of Computer Science & Engineering, MVGR College of Engineering(A)

32
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

Output

20 ​ Find employees whose first name starts with % and ends with _.

Query select ename from employee where ename like '\%%\_' ;

Output

21 ​ Find employees whose name ends with 'e' and has at least 4 characters.

Query select * from employee where ename like '%____%e';

Output

Department of Computer Science & Engineering, MVGR College of Engineering(A)

33
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

22 ​ Find employees whose name starts with 'A' and is followed by exactly 3
more characters.

Query select ename from employee where ename like 'A___';

Output

23 ​ Find employees whose first name is exactly 5 characters long.

Query select ename from employee where ename like '_____';

Output

24 ​ Display employees who work in any department except 'ECE' .

Department of Computer Science & Engineering, MVGR College of Engineering(A)

34
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

Query select * from employee where deptno!=(select deptid from department where
deptname='ece');

Output

25 ​ Find employees whose names contain exactly two 'a' characters.

Query select * from employee where joindate<='2021-01-01' and deptno=(select deptid from
Department where deptname='cse');

Output

Department of Computer Science & Engineering, MVGR College of Engineering(A)

35
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

27 27.​ Find employees who have NULL department IDs (employees with deleted
artments).

Query delete from department where deptid=4;


select * from employee where deptno is null;

Output

28 ​ Find employees whose names contain both 'a' and 'e'

Query select ename from employee where ename like '%a%e%';

Output

29 ​ Retrieve employees who joined between '2019-01-01' and '2021-12-31'.

Query select * from employee where joindate > '2019-01-01' and joindate <'2021-12-31';

Department of Computer Science & Engineering, MVGR College of Engineering(A)

36
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

Output

OBSERVATIONS:

1.ON DELETE SET NULL


When using ON DELETE SET NULL instead of ON DELETE CASCADE, the referenced tuple will not be
deleted. Instead, the column referencing the deleted data will be set to NULL.

2.LIKE Operator
The LIKE operator is also known as the pattern matching operator. It uses special characters like % and _ to
match

patterns.

3.Escape Character
The default escape character is \. To identify special literals, use this escape character. For example, to find
the
literal %, use \%.

4.Custom Escape Character


If you want to use a custom escape character, specify it explicitly using the ESCAPE keyword. For example:

5.SELECT * FROM table1 WHERE name LIKE '%a\*%' ESCAPE

Department of Computer Science & Engineering, MVGR College of Engineering(A)

37
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

WEEK 4 Date : 25-01-2025

AIM: Designing ER model for the given scenario.


This system should store data related to Branches, Customers and their accounts. Each branch
can have multiple customers. Since when a customer is associated with bank has to be tracked.
Each Customer can open multiple accounts. Multiple customers can own a single account.
All different accounts are to be tracked with single account Id.
Details of nominees for each of the accounts are to be maintained.
Bank Accounts can be of several types like Fixed Deposit Account, Recurring Deposit Account
and Salary Account. Bank employees should monitor the status of accounts on periodic basis.
Description:
In this scenario,​
Entities are branch, customers, accounts, fixed deposit account, recurring deposit account, salary
account and nominee.
Among those all entities, nominee is a weak entity. It is because it depends on the entity
customers.
Relationships :
1.​ Nominee participate in a weak relationship (depends) with the customers entity.
2.​ Branch entity participate in a relationship (have) with the customers entity.
3.​ Customers entity participate in a relationship (have) with the accounts entity.
Account entity was divided into sub entities such as fixed deposit account, recurring deposit
account and salary account.
Cardinality: Cardinality is very important in er modelling between two entities. It specifies the
number of instances of one entity that can or must be associated with the number of instances of
another entity.

Department of Computer Science & Engineering, MVGR College of Engineering(A)

38
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

There are three types of cardinalities.


1.​ One to one
2.​ One - many
3.​ Many to many
One-to-One (1:1): Each instance of Entity A is related to exactly one instance of Entity B, and
vice versa.
One-to-Many (1:N): One instance of Entity A can be associated with multiple instances of Entity
B, but each instance of Entity B relates to only one instance of Entity A.
Many-to-Many (M:N): Multiple instances of Entity A can relate to multiple instances of Entity
B, and vice versa.

Department of Computer Science & Engineering, MVGR College of Engineering(A)

39
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

Department of Computer Science & Engineering, MVGR College of Engineering(A)

40
R23MSCSL006-DATABASE MANAGEMENT SYSTEM LAB 23331A05A3

OBSERVATION:
1.​ Since the nominee is a weak entity, it will participate in weak entity.
2.​ Weak entity does not have any primary key and it depends on other entity such that foreign
key is referred from other entity.
3.​ Cardinality is very important in er modelling between two entities.
4.​ It specifies the number of instances of one entity that can or must be associated with the
number of instances of another entity.
5.​ Account entity is divided into sub-entities using a process called specialization.
6.​ The attributes except primary key of entity are also the attributes of sub entities derived
from the process specialization.

Department of Computer Science & Engineering, MVGR College of Engineering(A)

41

You might also like