dbms ans
dbms ans
Determine the main objects you want to represent in the database. Eg, "students", "courses", or "products".
Identify the properties(attributes) of properties of each entity. These attributes provide more details about an entity.
Create relationships between entities to specify how entities interact with each other. Relationships are verbs like
"teaches", "studies", or "sells".
To add attributes of a entitity write attributes inside the rectangle or connect them with lines.
Indicate the minimum and maximum number of relationship instances associated with an entity using notations like
crow's foot.
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.
Attributes are the kind of properties that describe the entities. They are represented by ovals.
• For Customer Entity the Attributes are Cid, Cname, Address, DOB.
Establishing Relationships
Entities have some relationships with each other. Relationships define how entities are associated with each other.
Specifying Cardinality
• 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)
Primary keys are the unique identifier for each record in database table. It is denoted by an underline under the
attribute name.
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.
o Example: REVOKE SELECT ON employees FROM john; — Removes john's permission to read the
employees table.
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;