1/76
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
What is basic modeling in database design?
Basic modeling involves creating an abstract representation of the data structure in a database. This includes defining the entities, attributes, and relationships that reflect the real-world system.
What are models in the context of database design?
Models in database design represent the structure of data, typically using diagrams such as Entity-Relationship (ER) diagrams or class diagrams. They define how data is stored, organized, and related in a database system.
What are classes and schemas in database design?
Classes are blueprints for objects in object-oriented database design, representing entities or concepts. Schemas define the structure of a database, including tables, views, and relationships, essentially describing the design of the database.
What are associations in database design?
Associations represent relationships between entities or classes in a database model. They describe how different entities are linked, such as one-to-many or many-to-many relationships.
What are object graphs in database design?
Object graphs are representations of interconnected objects in object-oriented databases, showing how objects (or entities) relate to one another. They visualize the relationships between objects in a hierarchical structure.
What is a many-to-many relationship in database design?
A many-to-many relationship occurs when multiple records in one table relate to multiple records in another table. This is typically managed with a junction table that holds the relationships between the entities.
CREATE TABLE students (
student_id INT PRIMARY KEY,
name VARCHAR(100)
);
CREATE TABLE courses (
course_id INT PRIMARY KEY,
course_name VARCHAR(100)
);
CREATE TABLE student_courses (
student_id INT,
course_id INT,
PRIMARY KEY (student_id, course_id),
FOREIGN KEY (student_id) REFERENCES students(student_id),
FOREIGN KEY (course_id) REFERENCES courses(course_id)
);
What is a many-to-many with history relationship in database design?
A many-to-many with history relationship includes a junction table that not only stores the links between the entities but also captures historical data, such as timestamps or change logs, to track the evolution of the relationships over time.
CREATE TABLE student_courses_history (
student_id INT,
course_id INT,
enrollment_date TIMESTAMP,
drop_date TIMESTAMP,
PRIMARY KEY (student_id, course_id, enrollment_date),
FOREIGN KEY (student_id) REFERENCES students(student_id),
FOREIGN KEY (course_id) REFERENCES courses(course_id)
);
What is UML in the context of database design?
UML (Unified Modeling Language) is a standard for modeling the structure and behavior of a system, including databases. It uses diagrams such as class diagrams to represent entities, attributes, and relationships in the system.
What is redundancy in database design?
Redundancy refers to the unnecessary repetition of data in a database. While it can improve performance in some cases, redundancy can also lead to inconsistencies and increased storage requirements.
What is integrity in database design?
Integrity in database design refers to the accuracy and consistency of data. There are various types of integrity constraints, including entity integrity, referential integrity, and domain integrity.
What are functional dependencies in database design?
Functional dependencies describe the relationship between two sets of attributes in a database. If attribute A functionally determines attribute B, then for each value of A, there is a corresponding value of B.
-- Here, student_id functionally determines student_name
CREATE TABLE students (
student_id INT PRIMARY KEY,
student_name VARCHAR(100)
);
What is inheritance in database design?
Inheritance allows one entity (or class) to inherit attributes and behaviors from another entity. In database design, this concept is used in object-oriented models to avoid redundancy and improve reusability.
What are recursive associations in database design?
Recursive associations occur when an entity has a relationship with itself. For example, in a company database, an employee may manage other employees, leading to a recursive relationship within the employee table.
CREATE TABLE employees (
employee_id INT PRIMARY KEY,
manager_id INT,
employee_name VARCHAR(100),
FOREIGN KEY (manager_id) REFERENCES employees(employee_id)
);
What is the relational model in database design?
The relational model organizes data into tables (relations) with rows (tuples) and columns (attributes). It uses keys to define relationships between tables and ensures data integrity and consistency.
What are tables, columns, and rows in relational databases?
Tables store data in rows and columns, representing entities or objects. Columns represent attributes of the entity. Rows represent individual records or instances of the entity.
What are constraints and keys in relational databases?
Constraints enforce rules on data, such as uniqueness or referential integrity. Keys are attributes or sets of attributes that uniquely identify a row in a table (e.g., primary key, foreign key).
What are foreign keys in relational databases?
Foreign keys are attributes that create a link between two tables. A foreign key in one table points to the primary key of another table, establishing a relationship between them.
What are queries in relational databases?
Queries are requests made to the database to retrieve, update, or manipulate data. SQL (Structured Query Language) is the standard language for writing queries.
What are DDL and DML in relational databases?
DDL (Data Definition Language) defines the structure of the database, including creating, altering, and dropping tables and schemas. DML (Data Manipulation Language) deals with the manipulation of data within the database, such as inserting, updating, or deleting records.
What is a join in SQL?
A join combines rows from two or more tables based on a related column, typically a foreign key. Common types of joins are inner join, left join, right join, and outer join.
SELECT students.student_name, courses.course_name
FROM students
INNER JOIN student_courses ON students.student_id = student_courses.student_id
INNER JOIN courses ON student_courses.course_id = courses.course_id;
What are multiple joins in SQL?
Multiple joins occur when you combine more than two tables in a single query. You can use inner joins or outer joins to create relationships between multiple tables.
What are outer joins in SQL?
Outer joins include rows that do not have matching values in both tables, filling in missing values with NULL. Types of outer joins include left outer join, right outer join, and full outer join.
SELECT students.student_name, courses.course_name
FROM students
LEFT JOIN student_courses ON students.student_id = student_courses.student_id
LEFT JOIN courses ON student_courses.course_id = courses.course_id;
What are functions in SQL?
Functions are built-in operations that perform calculations or transformations on data, such as COUNT(), SUM(), AVG(), MAX(), and MIN().
SELECT COUNT(*) FROM students;
What are subqueries in SQL?
A subquery is a query nested inside another query, typically used to filter results or perform operations that depend on the results of the outer query.
SELECT student_name FROM students
WHERE student_id IN (SELECT student_id FROM student_courses WHERE course_id = 1);
What are union and minus in SQL?
UNION combines the result sets of two or more queries into one result set, removing duplicates. MINUS returns the records from the first query that do not exist in the second query's result set.
SELECT student_name FROM students
UNION
SELECT teacher_name FROM teachers;
What are check constraints in SQLAlchemy?
Check constraints are used in SQLAlchemy to enforce rules on column values, such as ensuring that a salary field must always be greater than 0.
What are validators in SQLAlchemy?
Validators are functions or methods that ensure data meets certain conditions before being committed to the database. They are often used in combination with check constraints to ensure data integrity.
What is SQLAlchemy in Python?
SQLAlchemy is an Object Relational Mapping (ORM) library for Python. It provides tools to map Python objects to database tables, enabling interaction with databases using Python objects instead of raw SQL.
What is the document model in databases?
The document model stores data in flexible, semi-structured documents, usually in formats like JSON or BSON. Each document can have a different structure, making this model highly scalable and adaptable.
What are relationships in document databases?
Relationships in document databases are typically represented by embedding documents within other documents (denormalization) or by linking documents through references (normalization).
What is MongoDB $lookup?
The $lookup operator in MongoDB performs a left-outer join to combine documents from two collections. It is used to perform complex queries involving multiple collections.
- **Read Uncommitted**: Dirty reads (uncommitted data)
- **Read Committed**: Non-repeatable reads
- **Repeatable Read**: Phantom reads
- **Serializable**: No anomalies (highest level of isolation).