Intro To Databases (COURSERA. META. Backend Development Certification) Flashcards
Revise SQL
Name three typical use cases for databases.
Banks (customer and transaction data), hospitals (patient and staff data), and online stores (user profiles and shopping history).
What has led to the revolution in database technology?
The rise of Big Data and the Internet of Things (IoT), which generate vast amounts of diverse data.
List four key actions a database typically performs.
- Storing data,
- Forming relationships
- Filtering data
- Searching data.
What practical project will you undertake during this course?
Building a fully operational database and setting up software for local and remote database management.
According to Daniel, what is critical for a database engineer?
Creating an effective data layer for quick and accurate user responses, and influencing other aspects like user interfaces and APIs.
What soft skills are emphasized by Daniel for database engineers?
Communication and organization, especially explaining technical work to team members and end-users.
What advice does Daniel give about database development?
Avoid overcomplicating solutions, focus on current data needs, iterate frequently, and emphasize documentation.
How should you relate technical concepts to real-life scenarios?
Use relatable examples, like a recipe book, to understand and apply database concepts.
What additional task is important alongside coding according to Daniel?
Writing documentation, status updates, and enhancing project documentation.
What are the prerequisites for the Introduction to Databases course?
No previous database or coding experience required, but eagerness to start coding is essential.
What does CRUD stand for?
Create, Read, Update, Delete.
What is database normalization?
The process of organizing data to reduce redundancy and improve data integrity.
What is data?
Data are facts and figures about anything, such as name, age, email for a person, or order number, description, and quantity for a purchase.
What is a database?
A database is electronic storage where data is organized systematically, making it manageable, efficient, and secure.
What are entities in a database?
Entities are elements like employees, customers, products (physical) or orders, invoices (conceptual), stored in a table-like format.
What do attributes and rows represent in a database table?
Attributes are the columns representing features of the entity, and rows are the instances of the entity.
What are the different types of databases mentioned?
- Relational Databases: Use tables and relations.
- Object-Oriented Databases: Store data as objects.
- Graph Databases: Use nodes and edges to represent data and relationships.
- Document Databases: Use JSON objects organized into collections.
How can databases be stored?
On-Premises: Hosted on a dedicated machine within an organization.
Cloud Databases: Hosted on the cloud, accessed via the Internet, providing lower-cost options for data management.
What are the key takeaways about databases?
- Understand what a database is and how it functions.
- Identify real-world uses of databases.
- Understand how data is systematically organized within a database.
Why are data relationships important in a database?
Data must be related to be processed into meaningful information.
What is an example of a task that requires understanding data relationships in a database?
Retrieving customer details from one table and finding the corresponding order from another table.
What fields are typically found in a customer table?
Customer ID, FirstName, LastName, Email.
What is a primary key?
A unique field in a table that identifies each record (e.g., Customer ID).
What fields are typically found in an order table?
Order ID (primary key), Customer ID (foreign key).
What is a foreign key?
A field in one table that connects to the primary key in another table (e.g., Customer ID in the order table).
What are the purposes of using charts for data presentation?
To help people understand data better and to illustrate data relationships visually.
What does a bar chart represent?
Categorical data with rectangular bars, where the heights of the bars are proportional to the values they represent.
What insight does the bookshop’s bar chart from 2018 to 2022 provide?
2018 had the highest sales, while 2022 had the lowest sales.
How does a bubble chart compare different values?
By using bubbles of different sizes, with larger bubbles representing larger values.
What population sizes are represented by the largest bubbles in the 2015 bubble chart example?
China (1.4 billion) and India (1.3 billion).
What does a line chart show?
Trends over time by connecting data points with straight line segments.
What trend does the gold price line chart depict?
Changes in gold prices over a month, highlighting positive and negative changes.
How does a pie chart display data?
By showing how various data points make up a whole (100%) with each slice representing a percentage.
What percentage of students prefer soccer in the sports pie chart example?
50%
What additional types of charts are mentioned for different purposes?
Area charts, dual axis charts, Gantt charts, heat maps, and scatter plots.
What factors should be considered when choosing a chart for data presentation?
The target audience, the type and amount of data, the message, and the goal.
What is the best use of a line chart?
Identifying trends and predicting future data.
What is a simple and effective use of a pie chart?
Showing how various parts create a whole.
What are the chronological stages of database development?
- 1970s-1990s: Flat files, hierarchical, and network databases.
- 1980s-present: Relational databases.
- 1990s-present: Object-oriented, object-relational, and web-enabled databases.
What is a flat file database?
A type of database that stores data in a single file or table, typically as text files.
How is data organized in a hierarchical database?
Data is stored hierarchically, representing one-to-many relationships.
How do network databases differ from hierarchical databases?
Network databases allow multiple parent and child relationships, representing many-to-many relationships.
What key concepts define a relational database?
Storing data in tables with rows and columns, using primary keys for unique IDs, and foreign keys to establish relationships between tables.
What is an object-oriented database?
A database that represents data as objects, aligning with object-oriented programming languages.
What are the main types of NoSQL databases?
- Document Databases
- Key-Value Databases
- Wide-Column Databases
- Graph Databases
Why are NoSQL databases preferred for handling unstructured data?
Because of their higher scalability, distributed architecture, lower costs, flexible schema, and ability to process unstructured and semi-structured data.
What advantages do NoSQL databases offer?
- Higher scalability
- Distributed
- Lower costs
- Flexible schema
- Can process unstructured and semi-structured data
- No complex relationships
What is SQL?
SQL (Structured Query Language) is the standard language used to interact with all databases, especially relational databases.
What are CRUD operations in SQL?
Create, Read, Update, and Delete operations.
Name some examples of relational databases that use SQL.
MySQL, PostgreSQL, Oracle, Microsoft SQL Server.
What is the role of a Database Management System (DBMS) in SQL?
A DBMS interprets and executes SQL instructions for the underlying database.
What does the CREATE command do in SQL?
It is used to create database objects like tables (part of DDL).
What is the purpose of the ALTER command in SQL?
It modifies the structure of database objects (part of DDL).
What does the DROP command do in SQL?
It removes database objects (part of DDL).
What does the INSERT command do in SQL?
It adds data to tables (part of DML).
How do you modify existing data in SQL?
Using the UPDATE command (part of DML).
What command is used to remove data from tables in SQL?
The DELETE command (part of DML).
What is the SELECT command used for in SQL?
To retrieve data from one or multiple tables (part of DQL).
What are the GRANT and REVOKE commands used for in SQL?
GRANT gives users access privileges to data, and REVOKE removes those privileges (part of DCL).
What is DDL in SQL?
Data Definition Language, used to define the structure of a database.
What is DML in SQL?
Data Manipulation Language, used to manipulate data within database objects.
What is DQL in SQL?
Data Query Language, used to read or retrieve data from the database.
What is DCL in SQL?
Data Control Language, used to control access to data within the database.
Give an example scenario where CRUD operations are used.
Creating a database for a college, inserting data, modifying data, and managing access.
How does SQL act as an interface between the database and its users?
By providing commands and sublanguages to manage and interact with the database effectively.
What are the advantages of SQL?
- User-friendly
- Interactive
- Standard language
- Portable
- Comprehensive
- Efficient
Why is SQL considered user-friendly?
It requires minimal coding skills and uses a set of keywords, making it easy to perform CRUD operations.
What makes SQL interactive?
It allows developers to write complex queries quickly.
How is SQL a standard language?
It can be used with all relational databases like MySQL, PostgreSQL, and Oracle, and has extensive support and resources available.
Why is SQL considered portable?
SQL code runs on any hardware and operating system, behaving the same across different platforms.
What makes SQL comprehensive?
It covers all aspects of database management, including creation, manipulation, retrieval, and security.
What are the subsets of SQL?
- Data Definition Language (DDL)
- Data Manipulation Language (DML)
- Data Query Language (DQL)
- Data Control Language (DCL)
What commands are included in Data Definition Language (DDL)?
- CREATE: Creates database objects like tables.
- ALTER: Modifies existing database objects.
- DROP: Deletes database objects.
What commands are included in Data Manipulation Language (DML)?
- INSERT: Adds data to tables.
- UPDATE: Modifies existing data.
- DELETE: Removes data from tables.
What is the main command in Data Query Language (DQL)?
SELECT: Retrieves data from the database.`
What commands are included in Data Control Language (DCL)?
- GRANT: Gives users access privileges.
- REVOKE: Removes access privileges.
How do you create a database using SQL?
CREATE DATABASE college;
How do you create a table using SQL?
CREATE TABLE student ( ID INT, FirstName VARCHAR(50), LastName VARCHAR(50), DateOfBirth DATE );
How do you insert data into a table using SQL?
INSERT INTO student (ID, FirstName, LastName, DateOfBirth) VALUES (1, 'John', 'Murphy', '2000-01-01');
How do you update data in a table using SQL?
UPDATE student SET DateOfBirth = '2000-02-01' WHERE ID = 1;
How do you delete data from a table using SQL?
DELETE FROM student WHERE ID = 3;
How do you query data from a table using SQL?
SELECT FirstName, LastName FROM student WHERE ID = 1;
What is SQL used for?
SQL is used for managing and retrieving data in relational databases.
What are the four main categories of SQL commands?
- Data Definition Language (DDL)
- Data Query Language (DQL)
- Data Manipulation Language (DML)
- Data Control Language (DCL)
- Transaction Control Language (TCL)
What is the purpose of the CREATE command in DDL?
To create a database or tables.
What is the syntax for creating a table?
CREATE TABLE table_name ( column_name1 datatype(size), column_name2 datatype(size), column_name3 datatype(size) );
What is the purpose of the DROP command in DDL?
To delete a database or table.
What is the syntax for dropping a table?
DROP TABLE table_name;
What is the purpose of the ALTER command in DDL?
To change the structure of a table.
What is the syntax for adding a column to a table?
ALTER TABLE table_name ADD (column_name datatype(size));
What is the syntax for adding a primary key to a table?
ALTER TABLE table_name ADD primary key (column_name);
What is the purpose of the TRUNCATE command in DDL?
To remove all records from a table without deleting the table.
What is the syntax for truncating a table?
TRUNCATE TABLE table_name;
What is the purpose of the COMMENT command in DDL?
To add comments to SQL statements.
What is the syntax for adding a comment in SQL?
-- Retrieve all data from a table SELECT * FROM table_name;
What is the purpose of the SELECT command in DQL?
To retrieve data from tables.
What is the syntax for selecting data from a table?
SELECT * FROM table_name;
What is the purpose of the INSERT command in DML?
To add records to a table.
What is the syntax for inserting data into a table?
INSERT INTO table_name (column1, column2, column3) VALUES (value1, value2, value3);
What is the purpose of the UPDATE command in DML?
To modify data in a table.
What is the syntax for updating data in a table?
UPDATE table_name SET column1 = value1, column2 = value2 WHERE condition;
What is the purpose of the DELETE command in DML?
To delete data from a table.
What is the syntax for deleting data from a table?
DELETE FROM table_name WHERE condition;
What is the purpose of the GRANT command in DCL?
To provide user privileges.
What is the syntax for granting privileges?
GRANT privilege_name ON object TO user;
What is the purpose of the REVOKE command in DCL?
To remove user privileges.
What is the syntax for revoking privileges?
REVOKE privilege_name ON object FROM user;
What is the purpose of the COMMIT command in TCL?
To save all changes made in the current transaction.
What is the syntax for committing changes?
COMMIT;
What is the purpose of the ROLLBACK command in TCL?
To restore the database to the last committed state.
What is the syntax for rolling back changes?
ROLLBACK;
What is a database table?
A database table stores and organizes data logically using rows and columns.
What are the components of a database table?
Rows (Records/Tuples), Columns (Fields/Attributes), and Cells.
What do rows in a database table represent?
Individual entries or records.
What do columns in a database table define?
The type of data stored.
What are binary data types used for in SQL?
To store binary data like images and files, such as BINARY, VARBINARY.
What is a primary key?
A column or combination of columns that uniquely identifies each row in a table.
What is a composite primary key?
A primary key that combines multiple columns to create a unique identifier.
What is a foreign key?
A column in one table that links to the primary key of another table.
What are domain constraints?
Rules that define valid values for a column.
What are referential integrity constraints?
Ensure foreign key values exist in the referenced table.
Give an example of a primary key in a Student Table.
student_id
Give an example of a foreign key relationship.
student_id in the Department Table referencing the Student Table.
What is a table (entity) in a database?
A table stores data in rows and columns, representing a type of entity.
What are binary data types used for in SQL?
To store binary data like images and files, such as BINARY, VARBINARY.
What is an Entity Relationship Diagram (ERD)?
A visual representation of how entities relate to each other in a database.
What is cardinality of relationships?
Defines how entities are related: One-to-One, One-to-Many, Many-to-Many.
How are relationships established in the physical database structure?
Using foreign keys.
What does the logical structure of a database include?
The logical structure includes entities, attributes, their names, and data types, represented in an ERD.
What is the purpose of assigning data types to columns in a database table?
To keep the data consistent and define what type of data can be stored in each column.
What is the relational database model based on?
Tables (entities) and relations (connections between tables).
What is a key attribute?
A value used to uniquely identify a record in a table.
Give an example of a key attribute.
staff_id in a staff table.
What is a candidate key?
Any attribute that contains a unique value in each row.
Give examples of candidate keys.
staff_id and contact_number in a staff table.
Give an example of a composite key.
Combination of staff_name and staff_title.
What is a primary key?
The main key attribute used to uniquely identify records.
Give an example of a primary key.
staff_id in a staff table.
What is an alternate key (secondary key)?
A candidate key that was not selected as the primary key.
Give an example of an alternate key.
contact_number in a staff table.
What is a foreign key?
An attribute that references a unique key in another table.
What is a database?
An organized collection of data.
Give examples of real-world database usage.
Banking systems, online stores.
How is data organized in a database?
Data is organized into tables with related data.
What is SQL (Structured Query Language)?
A language used to interact with and manage databases.
What are the advantages of SQL?
- Low entry level
- Wide range of applications
- Portability across operating systems
What are the main subsets of SQL?
- DDL (Data Definition Language)
- DML (Data Manipulation Language)
- DQL (Data Query Language)
What are the main SQL commands?
- CREATE, ALTER, DROP (DDL)
- INSERT, UPDATE, DELETE (DML)
- SELECT (DQL)
What is the purpose of data types in a database table?
To define the kind of data stored (e.g., INT, VARCHAR, DATE).
What did you learn about databases in this module?
Basics of databases, SQL, database structure, how data is stored, and methods for interacting with databases.
What is the purpose of data types in a database?
To define what kind of data is accepted by each field in a table and ensure columns accept the correct type of data.
What are the most common data types used in databases?
Numeric, string, and date and time data types.
What are numeric data types?
Data types that allow a column to store data as numbers in the database.
What is the integer data type used for?
For storing whole numbers.
What is the decimal data type used for?
For storing numbers with fractional values.
Give an example of a column that uses the integer data type.
Product quantity column.
Give an example of a column that uses the decimal data type.
Total price column.
What is TINYINT used for in a MySQL Database Management System?
For storing very small integer number values, with a maximum value of 255.
What is INT used for in a MySQL Database Management System?
For storing large integer number values, with a maximum value of over four billion.
What are string data types used for?
To define columns that accept both numeric and text characters.
What does CHAR stand for and what is it used for?
CHAR stands for character and is used to hold characters of a fixed length.
What does VARCHAR stand for and what is it used for?
VARCHAR stands for variable character and is used to hold characters of a variable length.
Give an example of a column that uses the CHAR data type.
Username column defined as CHAR(50).
Give an example of a column that uses the VARCHAR data type.
Student name column defined as VARCHAR(50).
What is TINYTEXT used for?
For defining columns that require less than 255 characters, like short paragraphs.
What is TEXT used for?
For defining columns that require less than 65,000 characters, like an article.
What is MEDIUMTEXT used for?
For defining columns that require up to 16.7 million characters, like the text of a book.
What is LONGTEXT used for?
For defining columns that require up to four gigabytes of text data.
What is the purpose of database constraints?
Constraints limit the type of data that can be stored in a table to ensure accuracy and reliability.
What happens if a data operation violates a constraint?
The operation is aborted.
What are column-level constraints?
Rules that apply to specific columns in a table.
What are table-level constraints?
Rules that apply to the entire table.
Give an example of a table-level constraint.
Foreign key constraints prevent actions that destroy links between tables.
What is the purpose of the NOT NULL constraint?
Ensures that data fields are always completed and never left blank.
Provide an example of a NOT NULL constraint in an SQL statement.
CREATE TABLE customer ( customer_id INT NOT NULL, customer_name VARCHAR NOT NULL );