Curriculum Flashcards
What is a Relational Database?
A relational database is a type of database that stores and provides access to data points that are related to one another. Relational databases are based on the relational model, an intuitive, straightforward way of representing data in tables.
What is an Entity Relationship(ER) diagram?
An Entity Relationship (ER) Diagram is a type of flowchart that illustrates how “entities” such as people, objects or concepts relate to each other within a system.
What is an ENTITY in an entity relationship diagram and how is an ENTITY shown in an ER diagram?
A definable thing—such as a person, object, concept or event—that can have data stored about it. Think of entities as nouns. Examples: a customer, student, car or product. Think of the entity name as the table name.
Will typically be shown as a rectangle.
What is an ATTRIBUTE in an entity relationship diagram and how is the ATTRIBUTE displayed in the ER diagram?
An ATTRIBUTE is the property or characteristic of an ENTITY. Think of the attributes at the column names of a table.
An ATTRIBUTE is often shown as an oval or circle.
What is a RELATIONSHIP in an ER diagram and how is the RELATIONSHIP displayed in the ER diagram?
How ENTITIES act upon each other or are associated with each other. Think of RELATIONSHIPS as verbs.
Examples would be “works in”, “goes to”, “teaches”, “studies”, “carrying” “has”, “contains” etc..
RELATIONSHIPS are typically displayed as diamonds.
How would you portray the KEY ATTRIBUTE to distinguish it from other attributes of an ENTITY in an ER diagram?
The KEY ATTRIBUTE should be portrayed with underline.
What is a RECURSIVE RELATIONSHIP in an ER diagram?
When there is a relationship between two entities of the same type, it is known as a recursive relationship. This means that the relationship is between different instances of the same entity type
Ex: An employee can supervise multiple employees. Hence, this is a recursive relationship of entity employee with itself. This is a 1 to many recursive relationship as one employee supervises many employees.
In an ER model this is shown as a relationship which “connects” to the same entity twice.
How would you describe a PRIMARY KEY in DBMS?
A PRIMARY KEY is a column of a table or a set of columns that helps to identify every record present in that table uniquely.
Can a table contain more than one PRIMARY KEY?
No, there can be only one PRIMARY KEY per table.
Can a PRIMARY KEY contain NULL values?
Can a PRIMARY KEY contain duplicates?
No and…. no.
What is a SUPER KEY?
A SUPER KEY is a single column or a set of columns which help identify a row uniquely.
What is a CANDIDATE KEY?
CANDIDATE KEYS are those attributes that uniquely identify rows of a table. The PRIMARY KEY of a table is selected from one of the CANDIDATE KEYS.
What is an ALTERNATE KEY?
When a PRIMARY KEY is chosen from the CANDIDATE KEYS the remaining ones that didn’t get chosen are considered ALTERNATE KEYS.
What is a FOREIGN KEY?
FOREIGN KEYS is used to establish relationships between two tables. A FOREIGN KEY will require each value in a column or set of columns to match the PRIMARY KEY of the referential table.
What is a COMPOSITE KEY?
COMPOSITE KEY is a set of two or more attributes that help identify each tuple in a table uniquely. The attributes in the set may not be unique when considered separately. However, when taken all together, they will ensure uniqueness.
What is a DATABASE MANAGEMENT SYSTEM (DBMS)?
A set of programs to access database which provide a way to store and retrieve
database information that is both convenient and efficient
Why use a DBMS? (5 reasons)
- Data independence and efficient access.
- Reduced application development time.
- Data integrity and security.
- Uniform data administration.
- Concurrent access, recovery from crashes
What is a data model?
A collection of conceptual tools for describing data, data relationships, data semantics, and consistency constraints
What FOUR categories of data models do we have?
▪ Relational Model
▪ Entity-Relationship Model
▪ Object-Based Data Model
▪ Semistructured Data Model
What is data independence?
Capacity to change the schema at one level of a database system without
having to change the schema at the next higher level
What is logical data independence?
Logical Data Independence is defined as the ability to make changes in the structure of the middle level of the Database Management System (DBMS) without affecting the highest-level schema or application programs
What is physical data independence?
Physical Data Independence is defined as the ability to make changes in the structure of the lowest level of the Database Management System (DBMS) without affecting the higher-level schemas.
What is concurrency in DBMS?
Concurrent execution of user programs
Why would concurrency be important in DBMS?
Good concurrent execution would mean better performance of the DBMS.
What is a transaction?
An execution of a DB program. It ensures atomicity
What is important regarding a DB transaction?
Each transaction, executed completely, must leave the DB in a consistent state if DB is consistent when the transaction begins.
How do DBMS ensure the concurrent executions of transactions are atomic?
Do you know the name of the protocol?
Locks ezclap
Before reading/writing an object, a transaction requests a lock on the object, and waits till the DBMS gives it the lock. All locks are released at the end of the transaction.
Protocol is called Strict 2-Phase-Locking protocol.
How do a DBMS ensure atomicity during a transaction in regard to a system crash?
Keep a log while carrying out a set of operations. If there were to be a crash the DBMS can roll back the DB to a previous state. This ensures that all executions on the database is carried out, or none of them (all-or-nothing property).
What actions are recorded in the log?
The transaction log contains enough information to undo all changes made to the data file as part of any individual transaction.
The log records the start of a transaction, all the changes considered to be a part of it, and then the final commit or rollback of the transaction.
Give examples of what the DBMS is used for.
- Maintain database
- Query large datasets
What are 5 benefits of a DBMS?
- System crash recovery
- Concurrent access
- Quick application development
- Data integrity
- Security
A DBMS has a layered architecture, what are the three layers called?
First layer = View level.
Second layer = Logical level.
Third layer = Physical level.
What are the benefit of DBMS abstraction?
It gives data independence
What is an ER model?
A popular high-level conceptual data model and is
frequently used for the conceptual design of database applications.
What is an entity?
An object in the real world with an independent existence,
distinguishable from other objects and is described (in DB) using a set
of attributes.
What is an attribute?
The particular properties that describe the entity.
What is a key attribute?
Key Attribute: An attribute that identifies an entity in the entity set.
What is an Entity set?
A collection of similar entities.
E.g., all employees.
What is a relationship in ER model?
A relationship type represents the association between
entity types. A relationship is uniquely identified by the participating
entities.
What is a multivalued attribute in ER model?
A multivalued attribute can have more than one value at a time for an attribute. For ex., the skills of a surgeon is a multivalued attribute since a surgeon can have more than one skill. Another common example is the address field, which can have multiple values like zip code, street address, state, etc.
What is a composite attribute?
“Composite attribute is an attribute where the values of that attribute can be further subdivided into meaningful sub-parts.” Typical examples for composite attribute are; Name – may be stored as first name, last name, middle initial.
Think of composite attributes as ‘‘attributes of attributes’’.
What is a derived attribute and how is it portrayed?
A derived attribute as the name suggests is the one that can be
derived or calculated with the help of other attributes present themselves.
For example – The ‘age’ of the student can be calculated from
‘date of the birth present as an attribute.
Another example - derived attribute ‘street_number’ can be calculated from the ‘address’ attribute.
A derived attribute is portrayed as a dotted oval.
What is a weak entity?
In a relational database, a weak entity is an entity that cannot be uniquely identified by its attributes alone; therefore, it must use a foreign key in conjunction with its attributes to create a primary key. The foreign key is typically a primary key of an entity it is related to. : Example: a ROOM can only exist in a BUILDING. On the other hand, a TIRE might be considered as a strong entity because it also can exist without being attached to a CAR
Explain a many-to-many relationship.
Example: An employee can work in many departments; a department can have many employees.
Explain a one-to-many relationship.
Example: A manager can manage many departments but a department can only have one manager.
Explain one-to-one relationship
A (silly) example: A person can only have one heart, one heart can only belong to one person.
Another (better) example: In a school database, each student has only one student ID, and each student ID is assigned to only one person.
What is a relational model (RM)?
Relational Model represents how data is stored in Relational Databases. A relational database stores data in the form of relations (tables).
What is the cardinality and degree of a relational model?
Cardinality is number of rows of data present in the model( Not including the head row containing the column names)
Degree is the number of columns in a table.
Do all columns in a relation instance have to be distinct?
Yes, duplicate columns would serve no good purpose whatsoever.
What is SQL and what is it short for?
SQL is short for Structured Query Language and is a query language for getting specific information/data from a database.
How would you add a column “degree” to a ‘Students’ relation(table) between columns/attributes “age” and “address” using SQL?
ALTER TABLE Students
ADD COLUMN degree varchar(255)
BETWEEN age AND address;