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

dbms ans

The document outlines a step-by-step process for drawing an Entity Relationship Diagram (ERD), including identifying entities, defining attributes, specifying relationships, and organizing the diagram. It provides an example of a bank's ERD, detailing entities such as Bank, Branch, Employee, and Customer, along with their attributes and relationships. Additionally, it explains database commands like GRANT, REVOKE, COMMIT, and SAVEPOINT for managing permissions and transaction control.

Uploaded by

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

dbms ans

The document outlines a step-by-step process for drawing an Entity Relationship Diagram (ERD), including identifying entities, defining attributes, specifying relationships, and organizing the diagram. It provides an example of a bank's ERD, detailing entities such as Bank, Branch, Employee, and Customer, along with their attributes and relationships. Additionally, it explains database commands like GRANT, REVOKE, COMMIT, and SAVEPOINT for managing permissions and transaction control.

Uploaded by

Hemanth Atla
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

How to Draw an Entity Relation Diagram (ERD)

A step-by-step process to draw an entity relation diagram (ERD) is:

Step 1: Identifying Entities

Determine the main objects you want to represent in the database. Eg, "students", "courses", or "products".

Step 2: Defining Attributes

Identify the properties(attributes) of properties of each entity. These attributes provide more details about an entity.

Step 3: Specifing Relationships

Create relationships between entities to specify how entities interact with each other. Relationships are verbs like
"teaches", "studies", or "sells".

Step 4: Drawing Entities

Draw entities as rectangle and write the name.

Step 5: Adding Attributes

To add attributes of a entitity write attributes inside the rectangle or connect them with lines.

Step 6: Connecting Entities

Draw lines between the related entities to represent their connection.

Step 7: Specifying Cardinality

Indicate the minimum and maximum number of relationship instances associated with an entity using notations like
crow's foot.

Step 8: Organizing ER Diagram

Organize all entities and relationships in a clean way for better readibility and understanding.

EXAMPLE
Entity Relationship Diagram for BANK

We will follow the steps mentioned above, to draw entity relationship diagram for bank.

Defining Entities

A thing in the real world with an independent existence. It is may be an object with physical existence (ex: house,
person) or with a conceptual existence (ex: course, job). The are represented by rectangle.

Entities for Bank are:

Bank, Branch, Employee, customer, loan, account.


Adding Attributes

Attributes are the kind of properties that describe the entities. They are represented by ovals.

Attributes for Bank are:

• For Bank Entity the Attributes are Bname, code.

• For Branch Entity the Attributes are Blocation, Bname.

• For Employee Entity the Attributes are Eid, Designation, salary.

• For Customer Entity the Attributes are Cid, Cname, Address, DOB.

• For Loan Entity the Attributes are Loan_no, amount, rate.

• For Account Entity the Attributes are acc_no, type.

Establishing Relationships

Entities have some relationships with each other. Relationships define how entities are associated with each other.

Let's Establishing Relationships between them are:

• The Bank has branches.

• The Branch provides loan.

• The Employee works in branch.

• The Branch contains customers.

• The Customers has account.


• The Branch maintains account.

• The Customer avails loan

Specifying Cardinality

Specify cardinality for Bank:

• Bank and branch has One to Many relationship (a bank has multiple branches).

• Branch and loan has also One to Many relationship(a branch can provide many loans).

• Branch and employee has One to Many relationship(one branch has many employees).

• Branch and account has One to Many relationship(one branch has many accounts).

• Branch and customer has Many to Many relationship(multiple branches have multiple customers).

• Customer and account has Many to Many relationship(multiple customers have multiple accounts).

• Customer and loan has Many to Many relationships(multiple customers have multiple loans)

Identify Primary Keys

Primary keys are the unique identifier for each record in database table. It is denoted by an underline under the
attribute name.

• The Primary key of Bank is code.


• The Primary key of Branch is branch_code.

• The Primary key of Employee is Eid.

• The Primary key of Customer is Cid.

• The Primary key of Loan is loan_no.

• The Primary key of Account is acc_no.

Final ER Diagram

The below diagram is our final entity relationship diagram for bank with all entities, their attributes and the
relationship between them with the PRIMARY KEY and Cardinality ratio.
46) Consider the schema R=(A, B, C, D, E) with functional dependencies. Provide a lossless join decomposition into
BCNF.
52) Explain the GRANT and REVOKE commands.

The GRANT and REVOKE commands are used to manage database permissions:

• GRANT: Gives specific privileges (e.g., SELECT, INSERT) to a user or role on a database object (e.g., table,
view).

o Example: GRANT SELECT ON employees TO john; — Grants john permission to read the employees
table.

• REVOKE: Removes previously granted privileges from a user or role.

o Example: REVOKE SELECT ON employees FROM john; — Removes john's permission to read the
employees table.

50) Explain commit and savepoint with an example.

COMMIT: The COMMIT command saves all changes made during the current transaction permanently to the
database. Once committed, changes cannot be undone.

Example:

sql

Copy code

COMMIT;

SAVEPOINT: The SAVEPOINT command sets a point in a transaction to which you can roll back if needed, without
affecting the entire transaction.

Example:

sql

Copy code

SAVEPOINT point1;

ROLLBACK TO SAVEPOINT point1;

You might also like