TOPIC 2 : Introduction To The RDBMS Flashcards

1
Q

What is the purpose of the ER Model in DBMS?

A

The ER Model helps design and show how data is connected.
It uses entities (objects) and relationships (links between objects).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is an “Entity”?

A

An entity is a real thing or person stored in the database, like a student or teacher.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is an “Entity Set”?

A

An entity set is a group of the same kind of entities.
For example, all students together make up the student entity set.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are “Attributes”?

A

Attributes are details about an entity.
For a student, attributes can be name, age, or roll number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a “Simple Attribute”?

A

A simple attribute has a single, basic value, like a student’s age.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a “Composite Attribute”?

A

A composite attribute has multiple parts.
For example, a student’s address can include street, city, and zip code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a “Derived Attribute”?

A

A derived attribute is calculated from other data.
For example, age can be derived from a student’s birth date.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a “Single-Valued Attribute”?

A

It’s an attribute that has only one value.
Example: A student’s roll number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a “Key” in the ER Model?

A

A key is an attribute that can uniquely identify an entity.
For example, a student’s roll number can identify a specific student.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the types of Keys in the ER Model?

A
  1. Super Key
  2. Candidate Key
  3. Primary Key
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a “Relationship” in the ER Model?

A

A relationship shows how one entity is connected to another.
Example: A class is related to a student because students study in classes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the “degree” of a relationship?

A
  1. Binary relationship involves 2 entities.
  2. Ternary relationship involves 3 entities.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is an ER Diagram?

A

An ER Diagram is a visual map of data showing entities, their attributes, and how they are related to each other.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Can you give an example of an ER Diagram?

A

Yes! An ER diagram can show that:

  1. A Developer creates a Website
  2. A Visitor visits the Website
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does a rectangular box represent in an ER Diagram?

A

A rectangular box represents an Entity in an ER Diagram.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How are relationships between entities represented in an ER Diagram?

A

Relationships are represented by a Rhombus (diamond shape) between two or more entities.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

How are attributes for an entity represented in an ER Diagram?

A

Attributes are represented by an Ellipse connected to the entity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

How is a weak entity represented in an ER Diagram?

A

A Weak Entity is represented by double rectangular boxes and is usually connected to another entity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

How is a key attribute represented in an ER Diagram?

A

A Key Attribute is represented by underlining the attribute name inside the ellipse.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

How is a derived attribute represented in an ER Diagram?

A

A Derived Attribute is represented by a dotted ellipse inside the main ellipse.
Example: Age derived from Date of Birth.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

How is a multivalued attribute represented in an ER Diagram?

A

A Multivalued Attribute is represented by a double ellipse, one inside another.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is a composite attribute in an ER Diagram?

A

A Composite Attribute is an attribute that has other attributes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is an entity in an ER Diagram, and how is it represented?

A

An Entity can be any object, place, person, or class.
It is represented by a rectangle in an ER Diagram.
Example: In an organization, Employee, Manager, Department, and Product are entities.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is a weak entity, and how is it represented in an ER Diagram?

A

A Weak Entity depends on another entity and doesn’t have a key attribute of its own.
It is represented by a double rectangle.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

What is an attribute in an ER Diagram, and how is it represented?

A

An Attribute describes a property or characteristic of an entity, such as Name, Age, or Address.
It is represented by an ellipse.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What is a key attribute in an ER Diagram, and how is it represented?

A

A Key Attribute is the main characteristic of an entity, representing the Primary Key.
It is shown by an ellipse with the text underlined.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

What is a composite attribute, and how is it represented?

A

A Composite Attribute is an attribute that has its own attributes.
It is represented by multiple connected ellipses.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What is a relationship in an ER Diagram, and how is it represented?

A

A Relationship describes the relation between entities and is represented by a diamond or rhombus.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

What are the three types of relationships between entities in an ER Diagram?

A

The three types of relationships are:
a) Binary Relationship
b) Recursive Relationship
c) Ternary Relationship

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

What is a binary relationship in an ER Diagram?

A

A Binary Relationship is a relationship between two entities.
It can be
1) One-to-one
2) One-to-many
3) Many-to-one
4) Many-to-many.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

What is a one-to-one relationship?

A

In a One-to-One relationship, one entity is related to only one other entity.
Example: A student enrolls in only one course, and that course has only one student.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

What is a one-to-many relationship?

A

In a One-to-Many relationship, one entity can relate to multiple other entities.
Example: One student can enroll in many courses, but each course has only one student.

33
Q

What is a many-to-one relationship?

A

In a Many-to-One relationship, many entities are related to just one other entity.
Example: Many students enroll in one course, but a course has only one student.

34
Q

What is a many-to-many relationship?

A

In a Many-to-Many relationship, multiple entities are related to multiple other entities.
Example: Students can enroll in many courses, and courses can have many students.

35
Q

What is a recursive relationship in an ER Diagram?

A

A Recursive Relationship occurs when an entity is related to itself.

36
Q

What is a ternary relationship in an ER Diagram?

A

A Ternary Relationship involves three entities.
We usually consider two entities together and then relate the third one.
Example: A company produces products, and a company operates in a sector.

37
Q

What led to the development of the Enhanced ER Model?

A

The complexity of data in the late 1980s made it difficult to use the traditional ER Model for database modeling, leading to the introduction of improvements like
1) Generalization
2) Specialization
3) Aggregation
in the Enhanced ER Model.

38
Q

What is Generalization in the Enhanced ER Model?

A

Generalization is a bottom-up approach where two or more lower-level entities combine to form a higher-level entity.
It generalizes specific sub-classes into a more generalized super-class.
Example: Combining Saving Account and Current Account into a generalized entity called Account.

39
Q

How does Generalization differ from a subclass-superclass system?

A

The difference is in the approach: Generalization uses a bottom-up approach, combining lower-level entities into higher-level entities, while subclass-superclass systems typically have a top-down structure.

40
Q

What is Specialization in the Enhanced ER Model?

A

Specialization is a top-down approach where a higher-level entity is divided into two or more lower-level entities.
It is the opposite of Generalization, and a higher-level entity may not always need to be specialized.
Example: A general entity Vehicle can be specialized into Car and Motorbike.

41
Q

What is Aggregation in the Enhanced ER Model?

A

Aggregation is the process where the relationship between two entities is treated as a single entity.
Example: The relationship between Center and Course can be aggregated into one entity when associating it with another entity, such as Visitor.

42
Q

Why is Aggregation useful in the Enhanced ER Model?

A

Aggregation allows complex relationships between entities to be simplified by treating a relationship as an entity itself, making it easier to model real-world scenarios where multiple entities are closely linked together.

43
Q

What is a DBMS Key?

A

A DBMS key is an attribute or set of attributes used to uniquely identify a row (tuple) in a table. It allows you to find the relationship between two tables and ensures uniqueness within a table.

44
Q

What is a Primary Key?

A

A Primary Key is a column or a group of columns in a table that uniquely identifies each row.
It cannot be null, duplicated, or changed if it’s referenced by a foreign key.

45
Q

What are the rules for defining a Primary Key?

A

The rules for defining a primary key are:
1) No two rows can have the same primary key value.
2) Every row must have a primary key value.
3) The primary key cannot be null.
4) The primary key’s value cannot be modified if a foreign key references it.

46
Q

What is a Foreign Key?

A

A Foreign Key is a column that creates a relationship between two tables.
It maintains referential integrity and allows for navigation between related data in different tables.

47
Q

How does a Foreign Key maintain data integrity?

A

A Foreign Key ensures that the value in a foreign key column corresponds to a valid primary key value in the referenced table, preventing invalid data from being entered.

48
Q

What is Referential Integrity?

A

Referential Integrity is the concept of ensuring that a foreign key value always refers to a valid, existing primary key value in the related table, maintaining consistency in the database.

49
Q

What does ON DELETE CASCADE do in a database?

A

If the parent record is deleted, any child records related to that parent are also automatically deleted.

50
Q

What is an alternative to using ON DELETE CASCADE for keeping track of all data?

A

Using TRIGGERs can be an alternative to track all data changes, including deletions.

51
Q

What does ON UPDATE CASCADE do in a database?

A

If the parent record’s primary key is changed, the corresponding child record values are also updated to reflect the change.

52
Q

Why might frequent primary key updates indicate poor database design?

A

Regular changes to primary keys suggest there could be something wrong with the database design, as primary keys should typically remain stable.

53
Q

What does ON UPDATE CASCADE ON DELETE CASCADE mean?

A

It means that changes to the parent record (whether updating or deleting) will cascade down to the child records, causing them to be updated or deleted accordingly.

54
Q

What happens with a foreign key using cascade delete in SQL Server?

A

If a record in the parent table is deleted, the corresponding records in the child table are automatically deleted.

55
Q

What is a foreign key with cascade delete called in SQL Server?

A

If a record in the parent table is deleted, the corresponding records in the child table are automatically deleted.

56
Q

What is a foreign key with cascade delete called in SQL Server?

A

It is called a cascade delete.

57
Q

How can you create a foreign key with cascade delete in SQL Server?

A

It can be created using either a CREATE TABLE statement or an ALTER TABLE statement.

58
Q

What SQL statement is used to create a foreign key with cascade delete when creating a new table?

A

The CREATE TABLE statement.

59
Q

What does the foreign key with cascade delete ensure when deleting a parent record?

A

It ensures that the related records in the child table are also deleted to maintain referential integrity.

60
Q

What is the syntax to create a foreign key with cascade delete in SQL Server using the CREATE TABLE statement?

A

CREATE TABLE child_table
(
column1 datatype [ NULL | NOT NULL ],
column2 datatype [ NULL | NOT NULL ],

CONSTRAINT fk_name
FOREIGN KEY (child_col1, child_col2, … child_col_n)
REFERENCES parent_table (parent_col1, parent_col2, … parent_col_n)
ON DELETE CASCADE
[ ON UPDATE { NO ACTION | CASCADE | SET NULL | SET DEFAULT } ]
);

61
Q

What does ON DELETE CASCADE do in a foreign key relationship?

A

It deletes the corresponding child data when the parent data is deleted.

62
Q

What is the purpose of the ON UPDATE clause in a foreign key?

A

It specifies the action to take with the child data when the parent data is updated. Options include NO ACTION, CASCADE, SET NULL, and SET DEFAULT.

63
Q

What does the CASCADE option do when used with ON UPDATE or ON DELETE?

A

It means the child data is either updated or deleted when the parent data is updated or deleted.

64
Q

What does the SET NULL option do when used with ON UPDATE or ON DELETE?

A

It sets the child data to NULL when the parent data is updated or deleted.

65
Q

What does the SET DEFAULT option do in the ON UPDATE or ON DELETE clause?

A

It sets the child data to its default value when the parent data is updated or deleted.

66
Q

In the following example, what happens to records in the inventory table when a product is deleted from the products table?

sql
Copy code
CREATE TABLE products
( product_id INT PRIMARY KEY,
product_name VARCHAR(50) NOT NULL,
category VARCHAR(25) );

CREATE TABLE inventory
( inventory_id INT PRIMARY KEY,
product_id INT NOT NULL,
quantity INT,
min_level INT,
max_level INT,
CONSTRAINT fk_inv_product_id
FOREIGN KEY (product_id)
REFERENCES products (product_id)
ON DELETE CASCADE );

A

When a product is deleted from the products table, the corresponding records in the inventory table that use the same product_id will also be deleted.

67
Q

What is the syntax for creating a foreign key with cascade delete using the ALTER TABLE statement in SQL Server?

A

ALTER TABLE child_table
ADD CONSTRAINT fk_name
FOREIGN KEY (child_col1, child_col2, … child_col_n)
REFERENCES parent_table (parent_col1, parent_col2, … parent_col_n)
ON DELETE CASCADE;

68
Q

What does the ON DELETE CASCADE clause do in a foreign key created using the ALTER TABLE statement?

A

It specifies that when the parent data is deleted, the corresponding records in the child table are also deleted.

69
Q

In the ALTER TABLE syntax, what does fk_name represent?

A

It represents the name of the foreign key constraint you are creating.

70
Q

What is the purpose of REFERENCES in the ALTER TABLE statement?

A

It defines the relationship between the columns in the child table and the primary key in the parent table.

71
Q

In the following example, what happens when a product_id is deleted from the products table?

ALTER TABLE inventory
ADD CONSTRAINT fk_inv_product_id
FOREIGN KEY (product_id)
REFERENCES products (product_id)
ON DELETE CASCADE;

A

When a product_id is deleted from the products table, the corresponding records in the inventory table that reference the product_id are also deleted.

72
Q

What is ODBC?

A

ODBC (Open Database Connectivity) is a standard API that allows programs to access different databases (e.g., Access, DB2, Excel) using SQL requests.
It converts these requests so each database understands them.

73
Q

What do you need to use ODBC?

A

1) The ODBC software
2) A driver for each database you want to access (to handle communication between the program and the database).

74
Q

What is JDBC?

A

JDBC (Java Database Connectivity) is a Java API that lets Java programs connect to databases.
It uses Java classes and interfaces to send SQL queries and process results.

75
Q

Who defined the JDBC standard?

A

The JDBC standard was defined by Sun Microsystems, and it allows database providers to create their own JDBC drivers.

76
Q

What is the main difference between ODBC and JDBC?

A

1) ODBC is used by many types of applications to access databases.
2) JDBC is used specifically by Java programs to connect to databases.

77
Q

Can JDBC connect to ODBC databases?

A

Yes, with a small “bridge” program, JDBC can connect to databases that are accessible through ODBC.

78
Q

What are the two models for database access supported by JDBC?

A

1) Two-tier model: A Java app connects directly to the database.
2) Three-tier model: A middle server controls data access, with a simpler API for users.