14 Questions
0 Views

Created by
@PleasingHydrogen

Questions and Answers

DML queries are used for?

modify data in a database

An index can be created on multiple columns.

True

What is the purpose of normalization in database design?

to minimize data redundancy and dependency

The SELECT clause in a query specifies the ______________________ to be retrieved.

<p>columns</p> Signup and view all the answers

Match the following query components with their functions:

<p>SELECT = specifies the columns to be retrieved FROM = specifies the tables to be queried WHERE = specifies the conditions for which data to retrieve GROUP BY = groups data by one or more columns</p> Signup and view all the answers

What is the benefit of indexing in a database?

<p>improves query performance</p> Signup and view all the answers

A clustered index reorders the physical records of a table according to the index.

<p>True</p> Signup and view all the answers

The ______________________ Normal Form (2NF) requires that each non-key attribute must depend on the entire primary key.

<p>Second</p> Signup and view all the answers

数据库 normalization 的主要好处是什么?

<p>所有以上</p> Signup and view all the answers

自连接是将一个表与另一个表连接。

<p>False</p> Signup and view all the answers

数据库设计的主要步骤是什么?

<p>需求收集、概念设计、逻辑设计</p> Signup and view all the answers

第三范式(3NF)要求,如果一个表在 2NF,并且一个非键属性依赖于另一个非键属性,则它应该被移到一个 __________ 表。

<p>separate</p> Signup and view all the answers

将以下连接类型与其描述匹配:

<p>inner join = 返回两个表中的所有匹配行 left join = 返回左表中的所有行和右表中的匹配行 full outer join = 返回两个表中的所有行</p> Signup and view all the answers

以下关于数据库设计的说法正确的是什么?

<p>数据抽象是指提供数据的简化视图</p> Signup and view all the answers

Study Notes

Queries

  • A query is a request for specific data or action from a database
  • Types of queries:
    • DML (Data Manipulation Language): used to modify data in a database
      • INSERT: adds new data
      • UPDATE: modifies existing data
      • DELETE: deletes data
    • DQL (Data Query Language): used to retrieve data from a database
      • SELECT: retrieves data
  • Query components:
    • SELECT clause: specifies the columns to be retrieved
    • FROM clause: specifies the tables to be queried
    • WHERE clause: specifies the conditions for which data to retrieve
    • GROUP BY clause: groups data by one or more columns
    • HAVING clause: filters grouped data
    • ORDER BY clause: sorts data in ascending or descending order
    • LIMIT clause: limits the number of rows returned

Indexing

  • An index is a data structure that improves query performance by providing quick access to specific data
  • Types of indexes:
    • Clustered index: reorders the physical records of a table according to the index
    • Non-clustered index: creates a separate data structure that contains the index keys and pointers to the table records
  • Index characteristics:
    • Uniqueness: ensures that each value in the indexed column is unique
    • Composite index: combines multiple columns into a single index
  • Index benefits:
    • Improves query performance
    • Reduces disk I/O
    • Supports efficient sorting and grouping

Normalization

  • Normalization is the process of organizing data in a database to minimize data redundancy and dependency
  • Normalization rules:
    1. First Normal Form (1NF): each table cell must contain a single value
    2. Second Normal Form (2NF): each non-key attribute must depend on the entire primary key
    3. Third Normal Form (3NF): if a table is in 2NF, and a non-key attribute depends on another non-key attribute, then it should be moved to a separate table
  • Benefits of normalization:
    • Reduces data redundancy
    • Improves data integrity
    • Simplifies database design

Joins

  • A join is a method of combining data from two or more tables based on a related column
  • Types of joins:
    • Inner join: returns only the rows that have matching values in both tables
    • Left join: returns all the rows from the left table and the matching rows from the right table
    • Right join: returns all the rows from the right table and the matching rows from the left table
    • Full outer join: returns all rows from both tables
  • Join types:
    • Equi-join: joins tables based on equal values
    • Non-equi join: joins tables based on non-equal values
    • Self-join: joins a table with itself

Database Design

  • Database design is the process of creating a conceptual representation of a database
  • Design principles:
    • Data independence: separates data from the physical storage
    • Data abstraction: provides a simplified view of the data
    • Data normalization: minimizes data redundancy and dependency
  • Design steps:
    1. Requirements gathering: identifies the data requirements
    2. Conceptual design: creates a high-level design of the database
    3. Logical design: creates a detailed design of the database
    4. Physical design: implements the database on a specific platform
  • Design considerations:
    • Scalability: ability to handle increasing data volumes
    • Security: protects the database from unauthorized access
    • Performance: optimizes query execution and data retrieval

数据库查询

  • 查询是从数据库中请求特定数据或执行特定操作的请求
  • 查询类型:
    • DML(数据操纵语言):用于修改数据库中的数据
      • INSERT:添加新数据
      • UPDATE:修改现有数据
      • DELETE:删除数据
    • DQL(数据查询语言):用于从数据库中检索数据
      • SELECT:检索数据
  • 查询组件:
    • SELECT 子句:指定要检索的列
    • FROM 子句:指定要查询的表
    • WHERE 子句:指定要检索数据的条件
    • GROUP BY 子句:按一或多个列对数据进行分组
    • HAVING 子句:筛选分组数据
    • ORDER BY 子句:对数据进行升序或降序排序
    • LIMIT 子句:限制返回的行数

索引

  • 索引是提高查询性能的数据结构,提供对特定数据的快速访问
  • 索引类型:
    • 聚簇索引:根据索引重新排列表的物理记录
    • 非聚簇索引:创建一个单独的数据结构,包含索引键和指向表记录的指针
  • 索引特征:
    • 唯一性:确保索引列中的每个值都是唯一的
    • 复合索引:将多个列组合成一个索引
  • 索引优点:
    • 提高查询性能
    • 降低磁盘 I/O
    • 支持高效的排序和分组

规范化

  • 规范化是将数据库中的数据组织成最小化数据冗余和依赖的过程
  • 规范化规则: 1.第一范式 (1NF):每个表单元格必须包含单个值 2.第二范式 (2NF):每个非键属性必须依赖于整个主键 3.第三范式 (3NF):如果表满足 2NF,并且非键属性依赖于另一个非键属性,则应将其移到单独的表中
  • 规范化优点:
    • 降低数据冗余
    • 提高数据完整性
    • 简化数据库设计

连接

  • 连接是根据相关列将两个或多个表的数据结合的方法
  • 连接类型:
    • 内连接:返回两个表中具有匹配值的行
    • 左连接:返回左表中的所有行和右表中的匹配行
    • 右连接:返回右表中的所有行和左表中的匹配行
    • 完整外连接:返回两个表中的所有行
  • 连接类型:
    • 等值连接:根据等值连接表
    • 非等值连接:根据非等值连接表
    • 自连接:将表与自身连接

数据库设计

  • 数据库设计是创建数据库的概念表示的过程
  • 设计原则:
    • 数据独立性:将数据与物理存储分离
    • 数据抽象:提供简化的数据视图
    • 数据规范化:最小化数据冗余和依赖
  • 设计步骤: 1.需求收集:确定数据需求 2.概念设计:创建数据库的高级设计 3.逻辑设计:创建数据库的详细设计

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

More Quizzes Like This

SQL Fundamentals Quiz
18 questions

SQL Fundamentals Quiz

EntrancingBaritoneSaxophone avatar
EntrancingBaritoneSaxophone
SQL Queries for Data Analytics
18 questions

SQL Queries for Data Analytics

WorldFamousSeaborgium avatar
WorldFamousSeaborgium
SQL Queries and Operations
14 questions
Use Quizgecko on...
Browser
Browser