本段 215 题 | 来源:backend + general + design | 知识点:数据库
1. 什么是负索引(Negative Indexing)?为什么要使用它?
- 知识点: 数据库 / 编程语言基础 (主题: python;标签: python, indexing)
- 类型: technical | 难度: easy | 子类型:
- 分类: backend
- id: 695b5e5a7fd56f69a88e897c | 官方: 是 | 付费: 否
答案:
TL;DR负索引(Negative Indexing)从序列末尾开始访问:-1 表示最后一个元素。
arr = [10,20,30]
arr = [10,20,30]
print(arr[-1]) # 30
print(arr[-1]) # 30
2. 写一条 SQL 语句:向 leaderboards 表插入一条新的玩家分数记录。
- 知识点: 数据库 (主题: sql;标签: insert, leaderboard, sql)
- 类型: technical | 难度: easy | 子类型:
- 分类: backend
- id: 695df6661da553795635b2bd | 官方: 是 | 付费: 否
答案:
TL;DR使用 INSERT INTO ... VALUES ... 插入一条排行榜记录。
INSERT INTO leaderboards (leaderboard_id, score, created_at, game_id, player_id)
INSERT INTO leaderboards (leaderboard_id, score, created_at, game_id, player_id)
VALUES ("apex_legends", 1, "2050-08-22", "1", "42");
VALUES ("apex_legends", 1, "2050-08-22", "1", "42");
3. 写一条 SQL 语句:更新某个玩家的分数(例如 player_id=42,分数+1)。
- 知识点: 数据库 (主题: sql;标签: update, increment, sql)
- 类型: technical | 难度: easy | 子类型:
- 分类: backend
- id: 695df6661da553795635b2c0 | 官方: 是 | 付费: 否
答案:
TL;DR使用 UPDATE(更新操作)并通过 SET score = score + 1 实现累加。
UPDATE leaderboards
UPDATE leaderboards
SET score = score + 1
SET score = score + 1
WHERE player_id = '42';
WHERE player_id = '42';
4. 在 Redis Sorted Set(有序集合)中,如何新增玩家、移除玩家、以及增加玩家分数?请写出对应命令并解释返回值。
- 知识点: 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: data-structures, system-design;标签: redis, sorted-set, zadd, zrem, zincrby)
- 类型: technical | 难度: easy | 子类型:
- 分类: backend
- id: 695df7bb1da553795635d80c | 官方: 是 | 付费: 否
答案:
TL;DR排行榜可以用 Redis Sorted Set(有序集合)表示:member 是玩家 ID,score 是分数,key 表示某个 leaderboard。新增用 ZADD,移除用 ZREM,加分用 ZINCRBY。
新增玩家:ZADDredis> ZADD leaderboard 1 "one"
(integer) 1返回值:新增进集合的元素个数。
移除玩家:ZREMredis> ZREM leaderboard "one"
(integer) 1返回值:从集合中移除的成员数量。
增加玩家分数:ZINCRBYredis> ZINCRBY leaderboard 2 "one"
"3"返回值:成员的新分数(字符串形式)。
说明key(键) 用于标识具体榜单(例如某个游戏、某个周期的排行榜)。
5. 如何使用 SQL Server Management Studio(SSMS) 连接到 Azure 数据库?
- 知识点: 数据库 / DevOps/云 (主题: sql;标签: SSMS, Azure SQL, Firewall)
- 类型: technical | 难度: easy | 子类型:
- 分类: backend
- id: 6960b0520e32007ea0d0d2ca | 官方: 是 | 付费: 否
答案:
核心答案- 打开 SSMS:首次启动通常会自动弹出Connect to Server(连接到服务器);也可通过 Object Explorer(对象资源管理器) > Connect(连接) > Database Engine(数据库引擎) 手动打开。
- 在连接窗口填写信息(原文字段):- Server type:Database Engine
- Server name:Azure SQL Database 或 Azure Managed Instance 的名称
- Authentication:SQL Server Authentication
- Login/Password:服务器账号与密码
需要的话可在 Options(选项) 中调整额外连接选项。 - 点击 Connect。若防火墙未配置,会提示设置:登录 Azure 账号并配置防火墙规则后确认。
- 验证连接:在 Object Explorer 中展开,检查服务器名、SQL Server 版本与用户名等信息。
6. 如果你启动了一个 RDS(关系型数据库服务) 备用实例(standby),它会和主实例在同一个可用区吗?
- 知识点: 数据库 / DevOps/云 (主题: aws;标签: rds, multi-az, standby, availability-zone)
- 类型: technical | 难度: easy | 子类型:
- 分类: backend
- id: 6960bd800e32007ea0d20b75 | 官方: 是 | 付费: 否
答案:
核心答案不会。Multi-AZ(多可用区) 部署下,RDS 的 standby(备用实例) 通常会自动部署在不同的可用区(Availability Zone),用于故障隔离与高可用。
7. What is normalization in the database?
什么是数据库中的规范化?
- 知识点: 数据库 (标签: interviewbit, accenture, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Accenture
- id: 69b3791b58d557c902b97386 | 官方: 否 | 付费: 否
答案:
- Normalization(data normalization or database normalization) is the technique of data organization in the database to minimize data redundancy and improve data integrity. Through database normalization, we can organize the data in tables and columns, and also we can define a relationship between these tables or columns.
Below are the commonly used normalization forms:
First Normal Form(1NF)第一范式(1NF)
Second Normal Form(2NF)
第二范式(2NF)
Third Normal Form(3NF)
第三范式(3NF)
Boyce-Codd Normal Form(BCNF)
博伊斯-科德范式(BCNF)
Fourth Normal Form(4NF)
第四范式(4NF)
Fifth Normal Form(5NF)
第五范式(5NF)
8. Can you give differences for the Primary key and Unique key in SQL?
你能给出 SQL 中主键和唯一键的区别吗?
- 知识点: 数据库 (标签: interviewbit, accenture, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Accenture
- id: 69b3791b58d557c902b97389 | 官方: 否 | 付费: 否
答案:
| Primary key 主键 | Unique Key 唯一键 |
|---|---|
| It is a unique identifier for each row of a table. 它是表中每一行的唯一标识符。 | It is a unique identifier for table rows in the absence of a Primary key. 在没有主键的情况下,它是表行的唯一标识符。 |
| A single Primary key is allowed in a table. 一个表中只允许有一个主键。 | More than one Unique Key is allowed in a table. 一个表中允许多个唯一键。 |
| NULL value or duplicate value is not permitted. 不允许 NULL 值或重复值。 | It can have a single NULL value but a duplicate value is not permitted. 可以有单个 NULL 值,但不允许重复值。 |
| When we define a Primary key, a clustered index is automatically created if it does not already exist on the table. 当我们定义主键时,如果表上尚未存在聚集索引,则会自动创建一个聚集索引。 | When we define a Unique key, a non-clustered index is created by default to enforce a UNIQUE constraint. 当我们定义唯一键时,默认会创建一个非聚集索引以强制执行 UNIQUE 约束。 |
9. What do you understand about normalization in the context of Database Management Systems (DBMS)? What is the need for normalization?
在数据库管理系统(DBMS)的背景下,你对规范化有何理解?为什么需要规范化?
- 知识点: 数据库 (标签: interviewbit, accolite, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Accolite Digital
- id: 69b3791b58d557c902b973c5 | 官方: 否 | 付费: 否
答案:
The process of organising data in a database is known as normalisation. This includes generating tables and defining relationships between them according to rules aimed to secure data while also allowing the database to be more flexible by removing redundancy and inconsistent dependencies. Normalization aims at avoiding undesired characteristics such as Insertion, Update, and Deletion Anomalies. A normal form is a procedure that compares each relation to a set of criteria and eliminates multivalued, joins, functional, and trivial dependencies. Any data that is updated, deleted, or entered has no effect on database tables and helps to improve the integrity and performance of relational databases.
在数据库中组织数据的过程称为规范化。这包括根据旨在保护数据的规则生成表并定义它们之间的关系,同时通过消除冗余和不一致的依赖关系使数据库更加灵活。规范化旨在避免插入、更新和删除异常等不良特征。范式是一种将每个关系与一组标准进行比较并消除多值、连接、函数和平凡依赖关系的过程。任何被更新、删除或输入的数据都不会对数据库表产生影响,并有助于提高关系数据库的完整性和性能。
The following points illustrate the need for normalization in DBMS :
以下几点说明了在 DBMS 中需要规范化的原因:
- It is used to clean up the relational table by removing duplicate data and database oddities.
- By assessing new data types utilized in the table, normalization helps to decrease redundancy and complexity.
- It's a good idea to break down a huge database table into smaller tables and use relationships to connect them.
- It prevents duplicate data from being entered into a database, as well as no recurring groups.
- It lowers the likelihood of anomalies in a database.
10. What are the advantages of Database Management Systems over File Systems?
数据库管理系统相比文件系统有哪些优势?
- 知识点: 数据库 (标签: interviewbit, accolite, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Accolite Digital
- id: 69b3791b58d557c902b973d1 | 官方: 否 | 付费: 否
答案:
The following are the advantages of Database Management Systems (DBMS) over File Systems:
以下是数据库管理系统(DBMS)相比文件系统的优势:
- Data redundancy and inconsistency - Redundancy refers to the concept of data repetition, which means that any data item may have multiple copies. The file system cannot regulate the redundancy of data as each user defines and maintains the needed files for a given application to execute. It's possible that two users are sharing the same files and data for different programs. As a result, changes performed by one user do not appear in files utilized by other users, resulting in data inconsistency. DBMS, on the other hand, manages redundancy by keeping a single data repository that is defined once and accessed by multiple users. As there is no or less redundancy, data remains consistent.
- Data sharing - The file system does not allow data sharing because it is too complicated. Due to the centralized structure in DBMS, data may be simply shared.
- Data Storage technique - In a File System, data is stored in files, which are then sorted into folders, which are then structured into a hierarchy of directories and subdirectories. In a DBMS, data is stored in a structured and organized manner. Depending on the type of DBMS, it may be stored either in form of tables(if the DBMS is a Relational DBMS) or in the form of nodes (if the DBMS is a Graph DBMS) and so on. This leads to faster retrieval of data based on search queries.
- Concurrent access to data - When more than one user accesses the same data at the same time, this is referred to as data concurrency. Anomalies occur when one user's edits are overwritten by changes made by another user. There is no method in the file system to prevent abnormalities. A locking system is provided by DBMS to prevent abnormalities from occurring.
- Data searching - Each file system search activity necessitates the creation of a separate application program. DBMS, on the other hand, has built-in searching capabilities. To access data from the database, the user merely needs to submit a short query.
- Data integrity - Before putting data into a database, some constraints may need to be applied to the data. There is no process in the file system to check these constraints automatically. DBMS, on the other hand, ensures data integrity by enforcing user-defined restrictions on data.
- System crashes - Systems may crash for a variety of reasons in some circumstances. It's a problem with file systems since there's no way to recover the data that's been lost if the system crashes. A DBMS will have the recovery manager which retrieves the data offering it another advantage over file systems.
- Data security - A file system can safeguard a database using a password, but how long can the password be protected? That is something that no one can promise. In the case of DBMS, this does not occur. A database management system (DBMS) contains particular capabilities that assist in protecting data.
11. What do you understand about indexing in the context of Database Management Systems (DBMS)? What are the different types of indexing?
在数据库管理系统(DBMS)的背景下,你对索引有何理解?索引有哪些不同类型?
- 知识点: 数据库 (标签: interviewbit, accolite, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Accolite Digital
- id: 69b3791b58d557c902b973db | 官方: 否 | 付费: 否
答案:
Indexing is a data structure approach for retrieving records fast from a database file. A short table with only two columns is called an index. A duplicate of a table's primary or candidate key appears in the first column. The second column of the table comprises a series of pointers that carry the address of the disk block where that particular key value is stored. An index takes a search key as input and returns a collection of matching records. In the real world, we can compare indexing with that of the index page of a page. To access the content of a book, we go through its index to know what content lies on which pages. This makes our retrieval faster. In a similar manner, Database Management Systems maintain indexes so as to make retrieval faster from the database.
索引是一种从数据库文件中快速检索记录的数据结构方法。一个只有两列的短表称为索引。表的主键或候选键的副本出现在第一列中。表的第二列包含一系列指针,这些指针携带存储该特定键值的磁盘块的地址。索引将搜索键作为输入,并返回一组匹配的记录。在现实世界中,我们可以将索引与书的索引页进行比较。要访问一本书的内容,我们会查看其索引以了解哪些内容位于哪些页面上。这使我们的检索更快。以类似的方式,数据库管理系统维护索引以使从数据库中检索更快。
The following are the different types of indexing in DBMS:
以下是 DBMS 中索引的不同类型:
- Primary Indexing: A primary index is a two-field, ordered file with a defined length. The first field is the same as the primary key, while the second field points to the data block of concern. There is always a one-to-one relationship between the elements in the index table in the primary index. The primary indexing in a database management system is also divided into two types:
- Dense Index: For each search key value in the database, a record is created in a dense index. This allows you to search more quickly, but it requires more storage space for index information.
- Sparse Index: It's an index record that only appears for a subset of the file's values. Sparse indexes assist you in resolving DBMS dense indexing challenges. This indexing approach keeps the same data block address in a series of index columns, and when data is needed, the block address is retrieved. It takes up less space and has a smaller maintenance overhead for insertions and deletions, but it is slower to locate records than a dense index.
- Secondary Indexing: In a database management system, a secondary index can be constructed by a field that has a unique value for each record and should be a candidate key. A non-clustering index is another name for it.
- Clustering Indexing: The records themselves, not references, are stored in a clustered index. Non-primary key columns are sometimes used to build indexes, and they may not be unique for each record. In this case, you can aggregate two or more columns to generate unique values and create a clustered index. This also aids in the faster identification of the record.
12. What are the advantages of indexing in DBMS?
在DBMS中建立索引有哪些优势?
- 知识点: 数据库 (标签: interviewbit, accolite, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Accolite Digital
- id: 69b3791b58d557c902b973de | 官方: 否 | 付费: 否
答案:
The following are the advantages of indexing in DBMS: - It allows you to reduce the total number of I/O operations required to retrieve that data by eliminating the necessity to access a database entry through an index structure.
在DBMS中建立索引的优势如下:- 它通过消除必须通过索引结构访问数据库条目的必要性,来减少检索该数据所需的总I/O操作次数。
- Users may search and retrieve info more quickly.
You can save tablespace by indexing because you don't need to connect to a row in a table because the ROWID isn't stored in the index. As a result, you will be able to save table space.
The following are the disadvantages of indexing in the context of DBMS: - Partitioning an index-organized table is not permitted.在DBMS的背景下,索引的缺点如下:- 不允许对索引组织表进行分区。
- Indexing in SQL reduces the speed of INSERT, DELETE, and UPDATE queries.
13. Given a table in a database having two attributes employee name and their salary in it, find and print the employee having the Nth highest salary amongst them using Structured Query Language (SQL).
给定一个数据库中的表,其中包含员工姓名和他们的薪水两个属性,使用结构化查询语言(SQL)查找并打印其中拥有第N高薪水的员工。
- 知识点: 数据库 (标签: interviewbit, accolite, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Accolite Digital
- id: 69b3791b58d557c902b973e4 | 官方: 否 | 付费: 否
答案:
Example: Consider the following table:
示例:考虑以下表:
| ename | sal |
|---|---|
| P | 100 |
| Q | 200 |
| R | 300 |
| S | 500 |
| T | 400 |
| U | 100 |
| ename | sal |
|---|---|
| P | 100 |
| Q | 200 |
| R | 300 |
| S | 500 |
| T | 400 |
| U | 100 |
Here, if n = 2, then the output should be
这里,如果n = 2,那么输出应为
| ename | sal |
|---|---|
| T | 400 |
| ename | sal |
|---|---|
| T | 400 |
Approach 1: We use the concept of dense_rank() to compute the Nth highest salary. The function DENSE_RANK() returns the rank of a row in an ordered collection of rows as a NUMBER. The ranks are in ascending order, starting with 1. This function takes any numeric data type as an argument and returns NUMBER. Based on the values of the value_exprs in the order_by_clause, DENSE RANK computes the rank of each row returned from a query in relation to the other rows as an analytic function.
方法1:我们使用dense_rank()的概念来计算第N高薪水。函数DENSE_RANK()以NUMBER形式返回行在有序行集合中的排名。排名按升序排列,从1开始。该函数接受任何数值数据类型作为参数并返回NUMBER。基于order_by_clause中value_exprs的值,DENSE RANK作为分析函数计算查询返回的每一行相对于其他行的排名。
SQL Query:
SQL查询:
select * from(
select * from(
select ename, sal, dense_rank()
select ename, sal, dense_rank()
over(order by sal desc)rnk from Employee)
over(order by sal desc)rnk from Employee)
where rnk=&n;
where rnk=&n;
Approach 2: In this approach, we first find the employees who have the highest N different wages. The Nth highest salary can then be determined by finding the lowest salary among the salaries returned by the above query.
方法2:在此方法中,我们首先找出拥有最高的N个不同工资的员工。然后可以通过查找上述查询返回的工资中的最低工资来确定第N高薪水。
SQL Query:
SQL查询:
SELECT * FROM Employee WHERE sal =
SELECT * FROM Employee WHERE sal =
(
SELECT MIN(sal) FROM Employee
SELECT MIN(sal) FROM Employee
WHERE sal IN (
WHERE sal IN (
SELECT DISTINCT TOP N
SELECT DISTINCT TOP N
sal FROM Employee
sal FROM Employee
ORDER BY sal DESC
ORDER BY sal DESC
)
);
Approach 3: In this approach, we will create two aliases of the Employee table and then compare each salary with the other salaries present in the table to check if the current salary under consideration is greater than N-1 other salaries.
方法3:在这种方法中,我们将创建Employee表的两个别名,然后逐一比较每个薪水与表中的其他薪水,以检查当前考虑的薪水是否大于其他N-1个薪水。
SQL Query:
SQL查询:
SELECT ename,sal from Employee e1 where
SELECT ename,sal from Employee e1 where
N-1 = (SELECT COUNT(DISTINCT sal)from Employee e2 where e2.sal > e1.sal)
N-1 = (SELECT COUNT(DISTINCT sal)from Employee e2 where e2.sal > e1.sal)
14. 描述数据库索引(Index) 的工作原理,以及如何优化查询性能。
- 知识点: 数据库 (主题: database, sql;标签: afterpay, generated)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: backend
- 公司: Afterpay (Block)
- id: 69b3791d58d557c902b97583 | 官方: 是 | 付费: 是
答案:
思路分析从 B+ 树(B+ Tree) 索引结构、索引类型、查询计划(Query Plan) 分析等方面回答。
参考答案B+ 树(B+ Tree) 是最常用的索引结构。主键索引(聚簇(Clustered)索引) vs 二级索引(非聚簇(Non-Clustered)索引)。覆盖索引(Covering Index) 避免回表(Table Lookup)。EXPLAIN(执行计划分析工具) 分析查询计划。复合索引(Composite Index) 和最左前缀原则(Leftmost Prefix Principle)。
评分要点- 索引结构理解
- 索引选择和设计能力
- 查询优化实战经验
常见追问- 什么时候不应该建索引? - 如何处理慢查询?
15. What makes a DBMS an RDBMS?
什么使DBMS成为RDBMS?
- 知识点: 数据库 (标签: interviewbit, amdocs, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Amdocs
- id: 69b3792d58d557c902b98470 | 官方: 否 | 付费: 否
答案:
The Database Management System (DBMS) creates and maintains databases, allowing controlled access to the data. RDBMS stands for Relational Database Management System, an advanced version of a DBMS. While DBMS stores data in a file, RDBMS stores data in tabular format.
数据库管理系统(DBMS)创建和维护数据库,允许对数据进行受控访问。RDBMS代表关系数据库管理系统,是DBMS的高级版本。DBMS将数据存储在文件中,而RDBMS以表格格式存储数据。
16. Write a query that lists the employees who joined in the month of March based on an employee table in a database?
基于数据库中的员工表,编写一个查询,列出在3月份入职的员工?
- 知识点: 数据库 (标签: interviewbit, amdocs, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Amdocs
- id: 69b3792d58d557c902b9847f | 官方: 否 | 付费: 否
答案:
Look at the “employees” table below.
请查看下面的"employees"表。
| Job_ID | Employee_Name | HireDate | Position |
|---|---|---|---|
| 01 | Sonal | 2020-06-22 | Content Writer |
| 02 | Shivam | 2022-03-01 | Senior SDE |
| 03 | Rohit | 2018-03-14 | Associate SDE |
| 04 | Raghav | 2015-12-04 | Manager |
| Job_ID | Employee_Name | HireDate | Position |
|---|---|---|---|
| 01 | Sonal | 2020-06-22 | Content Writer |
| 02 | Shivam | 2022-03-01 | Senior SDE |
| 03 | Rohit | 2018-03-14 | Associate SDE |
| 04 | Raghav | 2015-12-04 | Manager |
If you want to see all the employees who joined in the month of March, then run the following SQL query:
如果你想查看所有在3月份入职的员工,请运行以下SQL查询:
SELECT * FROM employees WHERE to_char(hire_date,'MON') ='MAR';
SELECT * FROM employees WHERE to_char(hire_date,'MON') ='MAR';
OR
或者
SELECT * FROM employees WHERE to_char(hire_date,'MON') IN ('MAR');
SELECT * FROM employees WHERE to_char(hire_date,'MON') IN ('MAR');
OR
或者
SELECT * FROM employees WHERE to_char(hire_date,'MON') LIKE 'MAR%';
SELECT * FROM employees WHERE to_char(hire_date,'MON') LIKE 'MAR%';
Output:
输出:
| Job_ID | Employee_Name | HireDate | Position |
|---|---|---|---|
| 02 | Shivam | 2022-03-01 | Senior SDE |
| 03 | Rohit | 2018-03-14 | Associate SDE |
| Job_ID | Employee_Name | HireDate | Position |
|---|---|---|---|
| 02 | Shivam | 2022-03-01 | Senior SDE |
| 03 | Rohit | 2018-03-14 | Associate SDE |
17. List a few of the benefits of using a database management system.
列出使用数据库管理系统的一些好处。
- 知识点: 数据库 (标签: interviewbit, apisero, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Apisero
- id: 69b3793b58d557c902b9919f | 官方: 否 | 付费: 否
答案:
The following are some of the benefits of a database management system:
以下是数据库管理系统的一些好处:
- It aids in the management of database redundancy.
- Ensures that data is consistent.
- Easily accessible.
- Backup and recovery services are available.
- Integrity limitations are enforced.
- It puts a stop to unauthorized access.
- Multiple user interfaces are available.
- Due to the usage of queries, data extraction and processing are simple.
18. State your understanding of Distributed Database Management Systems with Transparency or Transparent Distributed Database Management Systems?
阐述你对具有透明性或透明分布式数据库管理系统的分布式数据库管理系统的理解?
- 知识点: 数据库 (标签: interviewbit, apisero, company-specific)
- 类型: technical | 难度: easy | 子类型: system-design
- 分类: general
- 公司: Apisero
- id: 69b3793b58d557c902b991a2 | 官方: 否 | 付费: 否
答案:
The transparent Distributed Database Management System is a type of database management system that hides the physical structure of the database from users. Physical structure, also known as physical storage structure, refers to the memory manager of a database management system and describes how data is saved on a disk. There is less abstraction as a result of this. In Distributed Database Management Systems (or DDBMS), there are four forms of transparency: - Transparency in transactions
透明分布式数据库管理系统是一种对用户隐藏数据库物理结构的数据库管理系统。物理结构,也称为物理存储结构,指的是数据库管理系统的内存管理器,并描述数据如何保存在磁盘上。因此,抽象程度较低。在分布式数据库管理系统(或DDBMS)中,有四种透明形式:- 事务透明度
- Transparency in distribution
- Transparency in performance
- Transparency in relational databases.
19. What are the differences between RDBMS (Relational Database Management Systems) and DBMS (Database Management Systems)?
RDBMS(关系数据库管理系统)和DBMS(数据库管理系统)之间有什么区别?
- 知识点: 数据库 (标签: interviewbit, apisero, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Apisero
- id: 69b3793b58d557c902b991a9 | 官方: 否 | 付费: 否
答案:
The key differences between Relational Database Management Systems (RDBMS) and Database Management Systems (DBMS) are as follows:
关系数据库管理系统(RDBMS)和数据库管理系统(DBMS)之间的主要区别如下:
| RDBMS | DBMS |
|---|---|
| They store data in the form of tables of rows and columns 它们以行和列的表形式存储数据 | They store data in the form of files. 它们以文件形式存储数据。 |
| Related data are stored in a single table. 相关数据存储在单个表中。 | There is no relationship between the data stored in a single file of DBMS. DBMS的单个文件中存储的数据之间没有关系。 |
| Many data items can be fetched simultaneously using mechanisms like grouping, etc. 可以使用分组等机制同时获取多个数据项。 | Only a single data item can be fetched at a particular point of time. 在特定时间点只能获取单个数据项。 |
| Relational tables can be normalized due to which Data Redundancy can be reduced. 关系表可以进行规范化,从而减少数据冗余。 | No concept of Normalization and hence Data Redundancy is prevalent. 没有规范化的概念,因此数据冗余普遍存在。 |
| Distributed databases are supported by RDBMS. RDBMS支持分布式数据库。 | DBMS does not support distributed databases. DBMS不支持分布式数据库。 |
| It can support multiple users at the same time (concurrent access is possible). 它可以同时支持多个用户(并发访问是可能的)。 | Only one user can use the DBMS at a particular time. 在特定时间只能有一个用户使用DBMS。 |
| Faster data fetching due to the relational approach. 由于关系方法,数据获取更快。 | Data fetching is normally very slow since there is no relation between data in a file. 由于文件中的数据之间没有关系,数据获取通常非常缓慢。 |
| It has a lot of hardware and software needs. 它有大量硬件和软件需求。 | Very few hardware and software needs are there in it. 它的硬件和软件需求很少。 |
| Data is more secure in RDBMS than in DBMS as various security mechanisms are implemented at various levels in it. RDBMS中的数据比DBMS中的数据更安全,因为它在各个级别实现了各种安全机制。 | Data is highly insecure in DBMS. DBMS中的数据非常不安全。 |
| Examples of RDBMS include Oracle, MySQL, Postgre, etc. RDBMS的例子包括Oracle、MySQL、Postgre等。 | Examples of DBMS include XML, Window Registry, etc. DBMS的例子包括XML、Windows注册表等。 |
20. State your understanding of Distributed Database Management Systems with Transparency?
阐述你对具有透明性的分布式数据库管理系统的理解?
- 知识点: 数据库 (标签: interviewbit, arcesium, company-specific)
- 类型: technical | 难度: easy | 子类型: system-design
- 分类: general
- 公司: Arcesium
- id: 69b3793d58d557c902b993e1 | 官方: 否 | 付费: 否
答案:
The transparent Distributed Database Management System is a type of database management system that hides the physical structure of the database from users. Physical structure, also known as physical storage structure, refers to the memory manager of a database management system and describes how data is saved on a disk. There is less abstraction as a result of this. In Distributed Database Management Systems (or DDBMS), there are four forms of transparency:
透明分布式数据库管理系统是一种对用户隐藏数据库物理结构的数据库管理系统。物理结构,也称为物理存储结构,指的是数据库管理系统的内存管理器,并描述数据如何保存在磁盘上。因此,抽象程度较低。在分布式数据库管理系统(或DDBMS)中,有四种透明形式:
- Transparency in transactions
- Transparency in performance
- Transparency in relational databases
- Transparency in distribution
21. What are the SQL Constraints?
什么是 SQL 约束?
- 知识点: 数据库 (标签: interviewbit, axis-bank, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Axis Bank
- id: 69b3795c58d557c902b9ac54 | 官方: 否 | 付费: 否
答案:
In SQL, constraints specify the rules for table data. To limit the type of data that can be entered into a table, constraints are used. This ensures that the table's data is accurate and reliable. Data actions are aborted when a constraint is violated. Constraints may be defined at the column or table level. As the name implies, a column-level constraint is applied to a particular column, whereas a table-level constraint is applied to the entire table. Constraints can be specified when creating the table, or afterward using the ALTER TABLE statement.
在 SQL 中,约束规定了表数据的规则。为了限制可以输入到表中的数据类型,使用了约束。这确保了表数据的准确性和可靠性。当违反约束时,数据操作将被中止。约束可以在列级或表级定义。顾名思义,列级约束应用于特定列,而表级约束应用于整个表。创建表时可以指定约束,或者之后使用 ALTER TABLE 语句指定。
Syntax:
语法:
CREATE TABLE table_name
CREATE TABLE table_name
(
col1 datatype(size) constraint_name,
col1 datatype(size) constraint_name,
col2 datatype(size) constraint_name,
col2 datatype(size) constraint_name,
col3 datatype(size) constraint_name,
col3 datatype(size) constraint_name,
....
);
Constraints available in SQL - NOT NULL: This constraint prevents us from storing null values in a column. If a column is set to NOT NULL, then the null value can no longer be stored in the given column.
SQL 中可用的约束 - NOT NULL:此约束防止我们在列中存储空值。如果某列设置为 NOT NULL,则给定列中不能再存储空值。
- UNIQUE: If a column is set to UNIQUE, then every value in the column must be unique. This means that no value should be repeated in the column.
- PRIMARY KEY: A primary key of a table is a field that uniquely identifies each row within the table. This constraint specifies a field as a primary key in a table.
- FOREIGN KEY: A foreign key of a table is a field that uniquely identifies each row of another table. This constraint specifies a field as a foreign key in a table.
- CHECK: Using this constraint, the values of a column can be validated to meet a specific condition. This ensures that the value stored within a column meets a particular condition.
- DEFAULT: This constraint sets a default value for the column when no user value is specified.
22. What do you mean by DELETE and TRUNCATE statements in SQL?
在SQL中,DELETE和TRUNCATE语句是什么意思?
- 知识点: 数据库 (标签: interviewbit, axis-bank, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Axis Bank
- id: 69b3795c58d557c902b9ac57 | 官方: 否 | 付费: 否
答案:
Both TRUNCATE and DELETE statements are part of the SQL delete query. Both are used to get rid of unwanted records or rows in a table.
TRUNCATE和DELETE语句都是SQL删除查询的一部分。两者都用于删除表中的不需要的记录或行。
| DELETE | TRUNCATE |
|---|---|
| You can delete all records from a table or only certain records matching your criteria with the SQL Delete command. 使用SQL Delete命令,您可以删除表中的所有记录,或仅删除符合您条件的特定记录。 | The Truncate command in SQL deletes all rows or tuples from a table. SQL中的Truncate命令删除表中的所有行或元组。 |
| It is a DML (Data Manipulation Language) command 这是一个DML(数据操作语言)命令。 | It is a DDL (Data Definition Language) command. 这是一个DDL(数据定义语言)命令。 |
| A WHERE clause can be used with the DELETE command. WHERE clauses are used with DELETE commands to remove or delete only the rows that satisfy a condition, otherwise all rows are removed by default. DELETE命令可以使用WHERE子句。WHERE子句与DELETE命令一起使用,以仅删除满足条件的行,否则默认删除所有行。 | TRUNCATE commands that do not contain a WHERE clause, unlike DELETE commands. TRUNCATE命令与DELETE命令不同,不包含WHERE子句。 |
| Tuples are locked before being removed with the DELETE command. 使用DELETE命令删除元组前,元组会被锁定。 | A data page must be locked prior to removing table data using TRUNCATE. 使用TRUNCATE删除表数据前,必须锁定数据页。 |
| Since the DELETE command maintains the transaction log for each deleted record, it is slower than TRUNCATE. 由于DELETE命令为每条删除的记录维护事务日志,因此比TRUNCATE慢。 | TRUNCATE is faster since it does not scan each record before removing it; rather, it removes entire data blocks at once. TRUNCATE更快,因为它在删除前不会扫描每条记录;相反,它一次性删除整个数据块。 |
| Transaction logs are maintained for each deleted record, allowing us to roll back the change. Using the ROLLBACK or COMMIT statements, we can restore deleted data. 为每条删除的记录维护事务日志,允许我们回滚更改。使用ROLLBACK或COMMIT语句,我们可以恢复删除的数据。 | There are no transaction logs for each deleted row, so we cannot roll back the changes. Once the command has been executed, we cannot revert the changes. 没有为每个删除的行维护事务日志,因此我们无法回滚更改。一旦命令执行,我们无法恢复更改。 |
| Because it keeps a log for each deleted row, it consumes more transaction space than truncate. 因为它为每个删除的行保留日志,所以比TRUNCATE占用更多的事务空间。 | Since a transaction log is maintained for the entire page instead of for each row, it occupies less space than the DELETE command. 由于为整个页面而不是每行维护事务日志,因此比DELETE命令占用更少的空间。 |
| Syntax: DELETE FROM TableName WHERE condition; 语法:DELETE FROM 表名 WHERE 条件; | Syntax: TRUNCATE TABLE TableName; 语法:TRUNCATE TABLE 表名; |
23. Why is it suggested to utilise a database management system (DBMS)? List some of its primary advantages to explain.
为什么建议使用数据库管理系统(DBMS)?列举一些其主要优点来解释。
- 知识点: 数据库 (标签: interviewbit, capgemini, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Capgemini
- id: 69b379f058d557c902ba16be | 官方: 否 | 付费: 否
答案:
Following are some advantages of using DBMS: - Minimizing Data Redundancy: DBMS supports a system to eliminate data redundancy within the database by integrating all data into a single database, and because data is stored in only one location, there is no duplication of data.
以下是使用DBMS的一些优点: - 最小化数据冗余:DBMS支持通过将所有数据集成到单个数据库中来消除数据库中的数据冗余,并且由于数据只存储在一个位置,因此不会重复数据。
- Data Sharing: In a DBMS, data can be shared among several users at the same time because the same database is shared across all users and by various applications.
- Data Integrity: This refers to the database's data being consistent and accurate at all times. It is critical because a database management system (DBMS) contains numerous databases, each of which contains data that is visible to multiple users. As a result, it's critical to guarantee that data is accurate and consistent across all databases and for all users.
- Data Security: Only approved users should be allowed access to the database, and their identities should be authenticated using a legitimate login and password. Under no circumstances should unauthorized users be allowed to access the database, as this would break the integrity limitations.
24. Why is normalization needed in a database?
为什么数据库中需要规范化?
- 知识点: 数据库 (标签: interviewbit, capgemini, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Capgemini
- id: 69b379f058d557c902ba16c1 | 官方: 否 | 付费: 否
答案:
The term "normalization" refers to the process of analyzing relation schemas based on their functional dependencies. Normalization is the technique of splitting up data into numerous tables to reduce redundancy.
术语“规范化”指基于功能依赖分析关系模式的过程。规范化是将数据拆分成多个表以减少冗余的技术。
The advantages of normalization are: - Standardization eliminates the copy information, allowing a smaller database to be maintained. As a result, the size of the database is reduced in general.
规范化的优点是: - 标准化消除复制信息,允许维护更小的数据库。因此,数据库的大小总体上减小了。
- Better execution is assured, which is related to the previous point. As the size of information bases shrinks, the time it takes to process it becomes shorter and more constrained, enhancing reaction time and speed.
- Narrower tables may be possible as standardized tables are altered and feature fewer segments, allowing for more data items per page.
- With fewer files per table, support assignments are completed faster (file modifies).
25. What do you understand about Proactive, Retroactive and Simultaneous Update in the context of DBMS?
在DBMS的上下文中,你对主动更新、追溯更新和同步更新有何理解?
- 知识点: 数据库 (标签: interviewbit, cognizant, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Cognizant
- id: 69b37a3158d557c902ba3ff6 | 官方: 否 | 付费: 否
答案:
- Proactive Updates: These changes are made to the database before it is put into use in the real-world environment.
- Retroactive Updates: These updates are applied to a database after it has been operational in the real-world environment.
- Simultaneous Updates: These updates are applied to the database at the same moment as they become functional in the real-world environment.
26. What is the fill factor in SQL? What is its default value?
SQL中的填充因子是什么?其默认值是多少?
- 知识点: 数据库 (标签: interviewbit, cognizant, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Cognizant
- id: 69b37a3158d557c902ba3ffc | 官方: 否 | 付费: 否
答案:
The fill factor is the percentage of space on each leaf-level page that will be filled with data. The smallest unit in SQL Server is a page, which is made up of 8K pages. Depending on the size of the row, each page can store one or more rows. The Fill Factor's default value is 100, which is the same as the value 0. The SQL Server will fill the leaf-level pages of an index with the highest number of rows it can fit if the Fill Factor is set to 100 or 0. When the fill factor is 100, the page will have no or very little vacant space.
填充因子是每个叶级页面上将填充数据的空间百分比。SQL Server中最小的单元是页面,由8K页面组成。根据行的大小,每个页面可以存储一行或多行。填充因子的默认值为100,这与值0相同。如果填充因子设置为100或0,SQL Server将以能容纳的最大行数填充索引的叶级页面。当填充因子为100时,页面将没有或很少有空白空间。
27. Explain the following terminologies in the context of Commvault: IRM CommCell, CommServe, CommServe Database, CommCell Console, MediaAgent, IRM Clients.
在Commvault的上下文中,解释以下术语:IRM CommCell、CommServe、CommServe数据库、CommCell控制台、MediaAgent、IRM客户端。
- 知识点: 数据库 (标签: interviewbit, commvault, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Commvault
- id: 69b37a4d58d557c902ba50e0 | 官方: 否 | 付费: 否
答案:
- IRM CommCell: The IRM CommCell, which is based on the Microsoft Windows platform and Microsoft's SQL Server Express, consolidates all task management functions, metadata, scheduling, and reporting into a single console. The CommServe application and the MediaAgent are two standard components in this IRM CommCell. These two components share a single operating area known as a CommCell.
- CommServe: CommServe is the master server in charge of CommCell's configuration and operations. It runs on a Windows host server and includes an embedded version of Microsoft SQL Express, which serves as IRM's top-level database. Each CommCell has one CommServe, which must be available to run operations. The CommServe handles only job control and metadata. The MediaAgent specified in the CommCell is used to perform indexing and snapshot management.
- CommServe Database: The CommServe Database is built on Microsoft SQL Express Edition and contains all of the CommServe's history and usage. Information such as work history, client settings, media type, and so on are all maintained in the database, and every item of data that is retrieved, saved, or deleted is recorded in the CommServe database.
- CommCell Console: It is the console that contains all of the CommCell environment's administration features and capabilities in a single pane. The console is java-based and may be launched as a local console instance or accessible through a browser from anywhere. In this console, all policies, operations, scheduling, alerting, and reporting are integrated and displayed to users depending on their security permissions and roles.
- MediaAgent: The MediaAgent is a data mover and indexing resource in a data management environment's data movement workflow. This component plays a variety of roles in the creation/mounting of snapshots and the cataloguing of client-relevant material. The MediaAgent will also act as the disc library's media library manager, storing index data. Those indexes are stored in the Archive file format, so they can't be mounted or used directly; instead, you'll need to do a restore to get a native recovery copy of the data.
- IRM Clients: In IRM, clients are servers and systems that use snapshot integration with production storage arrays. Each server will have a base File System iDataAgent installed to facilitate essential connectivity with the CommServe. You can then load more iDataAgents for application integration or VMware integration, depending on the information or data you want to safeguard. These agents provide the appropriate level of integration for File Systems, Databases, Exchange, SQL, and VMware guests to guarantee that the necessary data is secured at the appropriate level.These agents will also ensure that VSS writers are properly called to ensure that the data in the snapshot at the point-in-time is consistent, that "ESEUtil" commands can be used to check Exchange Database consistency, and that VMware calls the appropriate software quiescing mechanisms to create consistent VMs.
28. What do you know about the Deduplication Database in the context of Commvault?
在Commvault的上下文中,你对去重数据库有何了解?
- 知识点: 数据库 (标签: interviewbit, commvault, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Commvault
- id: 69b37a4d58d557c902ba50ec | 官方: 否 | 付费: 否
答案:
In Commvault, whenever a storage policy with deduplication is implemented, signatures are generated for data blocks during backups, compared, and then stored in the deduplication database (DDB). The DDB backup subclient automatically protects DDBs. All active DDBs controlled by the MediaAgent that hosts the DDB are backed up by this subclient. You can set up a reconstruction task for an automatic or on-demand restore of the DDB from the DDB backup in the event of DDB failure. The storage metadata can then be used to rebuild missing records.
在Commvault中,每当实施带去重的存储策略时,备份期间会为数据块生成签名,进行比较,然后存储在去重数据库(DDB)中。DDB备份子客户端自动保护DDB。此子客户端备份由托管DDB的MediaAgent控制的所有活动DDB。您可以设置重建任务,以便在DDB失败时从DDB备份中自动或按需恢复DDB。然后可以使用存储元数据重建缺失的记录。
29. State some of the uses of normalization?
列举规范化的某些用途?
- 知识点: 数据库 (标签: interviewbit, delhivery, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Delhivery
- id: 69b37a6e58d557c902ba6924 | 官方: 否 | 付费: 否
答案:
- When we are dealing with a large amount of data the chances of redundancy increase therefore normalization helps in decreasing redundancy.
- In order to decrease complexity, normalization looks at the new data types added to the table.
- A big database table can be broken up into smaller tables and linked with relationships.
- Anomalies are less likely to appear in a database with the help of normalization.
30. Differentiate between hierarchical database models and network in DBMS.
区分DBMS中的层次数据库模型和网络模型。
- 知识点: 数据库 (标签: interviewbit, deloitte, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: 德勤
- id: 69b37a6f58d557c902ba69bb | 官方: 否 | 付费: 否
答案:
Data are grouped into nodes in a tree-like structure in a hierarchical database model. A node can only have one parent node above it. As a result, the data nodes in this model have one-to-many relationships. The Document Object Model (DOM), which is often used in web browsers, is an example of this model.
在层次数据库模型中,数据以树状结构分组到节点中。一个节点上方只能有一个父节点。因此,该模型中的数据节点具有一对多关系。Web 浏览器中常用的文档对象模型(DOM)就是这种模型的一个例子。
The network database model is a more sophisticated variation of the hierarchical database architecture. Data is organised in a graph-like structure here as well. One child node, on the other hand, can be connected to several parent nodes. A many-to-many relationship between data nodes is an outcome of this. Network databases include IDMS (Integrated Database Management System) and IDS (Integrated Data Store).
网状数据库模型是层次数据库架构的一种更复杂的变体。这里的数据同样以类似图的结构组织。另一方面,一个子节点可以连接到多个父节点。这导致了数据节点之间的多对多关系。网状数据库包括 IDMS(集成数据库管理系统)和 IDS(集成数据存储)。
| Hierarchical model 层次模型 | Network model 网状模型 |
|---|---|
| The relationship among the records is of the parent-child form. 记录之间的关系是父子形式。 | The relationship among the records is in the form of pointers or links 记录之间的关系以指针或链接的形式存在 |
| Inconsistencies in data may occur during the update and delete actions. 在更新和删除操作期间可能会发生数据不一致。 | Data inconsistencies do not occur. 不会发生数据不一致。 |
| It does not support many to many relationships between the data nodes. 它不支持数据节点之间的多对多关系。 | It does support many to many relationships between data nodes. 它确实支持数据节点之间的多对多关系。 |
| It generates a tree structure, and data traversal is a little complicated. 它生成树结构,数据遍历有点复杂。 | It generates a graph structure in which data traversal is simple because each node may be accessed in both directions, i.e. parent-child and vice versa. 它生成图结构,其中数据遍历很简单,因为每个节点都可以双向访问,即父到子和子到父。 |
31. What are the differences between stored procedure and triggers in SQL?
SQL 中存储过程和触发器有什么区别?
- 知识点: 数据库 (标签: interviewbit, deloitte, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: 德勤
- id: 69b37a6f58d557c902ba69be | 官方: 否 | 付费: 否
答案:
Stored procedures are small pieces of PL/SQL code that perform a specific task. The user can call stored procedures directly. It's similar to a program in that it can take some input as a parameter, process it, and return values.
存储过程是执行特定任务的小段 PL/SQL 代码。用户可以直接调用存储过程。它类似于程序,可以接受一些输入作为参数,进行处理,并返回数值。
Trigger, on the other hand, is a stored process that executes automatically when certain events occur (eg update, insert, delete in a database). Triggers are similar to event handlers in that they operate in response to a specified event. Triggers are unable to accept input or return values.
另一方面,触发器是一种存储过程,在发生某些事件(例如数据库中的更新、插入、删除)时自动执行。触发器类似于事件处理程序,它们响应指定的事件而运行。触发器无法接受输入或返回值。
| Triggers 触发器 | Stored procedures 存储过程 |
|---|---|
| A trigger is a stored procedure that executes automatically in response to certain events (such as updates, inserts, and deletions). 触发器是一种存储过程,响应某些事件(如更新、插入和删除)自动执行。 | Stored procedures are sections of PL/SQL code that perform a specified operation. 存储过程是执行指定操作的 PL/SQL 代码段。 |
| It has the ability to run automatically in response to events. 它能够响应事件自动运行。 | It can be called by the user explicitly. 它可以由用户显式调用。 |
| It is unable to accept input as a parameter. 它无法接受输入作为参数。 | It has the ability to accept input as a parameter. 它能够接受输入作为参数。 |
| Transaction statements aren't allowed inside a trigger. 触发器内部不允许使用事务语句。 | Within a stored procedure, we can use transaction statements like begin transaction, commit transaction, and rollback. 在存储过程中,我们可以使用诸如 begin transaction、commit transaction 和 rollback 之类的事务语句。 |
| Triggers do not have the ability to return values. 触发器不具备返回值的能力。 | Values can be returned by stored procedures. 存储过程可以返回值。 |
32. Explain transaction atomicity in context to OS.
结合操作系统解释事务原子性。
- 知识点: 数据库 (标签: interviewbit, deloitte, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: 德勤
- id: 69b37a6f58d557c902ba69e2 | 官方: 否 | 付费: 否
答案:
The transaction process can be thought of as a series of read and write activities on data, followed by a commit operation. Transaction atomicity means that if a transaction fails to finish successfully, the transaction must be aborted, and all modifications made during execution must be rolled back. It indicates that a transaction must seem like a single, non-divisible process. This guarantees that the integrity of the data being updated is preserved. If the concept of atomicity is not applied in transactions, every transaction that is cancelled in the middle may result in data inconsistency because two transactions may be sharing the same data value.
事务过程可以看作是对数据的一系列读写活动,随后是一个提交操作。事务原子性意味着,如果事务未能成功完成,则必须中止该事务,并且执行期间所做的所有修改都必须回滚。这表明事务必须看起来像是一个单一的、不可分割的过程。这保证了被更新数据的完整性得以保持。如果事务中未应用原子性概念,那么每一个中途取消的事务都可能导致数据不一致,因为两个事务可能共享同一个数据值。
33. What are some of the benefits of using Views in a Database Management System?
在数据库管理系统中使用视图有哪些好处?
- 知识点: 数据库 (标签: interviewbit, dxc, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: DXC Technology
- id: 69b37ab758d557c902ba94cc | 官方: 否 | 付费: 否
答案:
The following are some of the advantages of employing views in a database management system: - A view can represent a subset of a table's data. As a result, a view can limit the extent to which the underlying tables are visible to the outside world: for example, a user may be able to query the view but not the entire base database.
在数据库管理系统中使用视图有以下一些优点:- 视图可以表示表数据的子集。因此,视图可以限制底层表对外部世界的可见范围:例如,用户可能能够查询视图,但不能查询整个基础数据库。
- Views are aggregated tables in which the database engine aggregates data (sum, average, and so on) and shows the resulting results alongside the data.
- Using views, we may merge and simplify several tables into a single virtual table.
- Views take up very little storage space; the database just stores the view's specification, not a copy of all the data it displays.
- The complexity of data can be obscured by views.
- Views can provide additional protection depending on the SQL engine being used.
- Data Science
- All Events
- My Events
34. SQL question: Problem Statement: Find the second largest value in a specified column of a relation or table.
SQL 问题:问题陈述:查找关系或表的指定列中的第二大值。
- 知识点: 数据库 (标签: interviewbit, ey, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: 安永
- id: 69b37aee58d557c902bab5f4 | 官方: 否 | 付费: 否
答案:
Input:
输入:
| Employee Name 员工姓名 | Salary 薪资 |
|---|---|
| Rajesh | 34000 |
| Amit | 20000 |
| Harshit | 24000 |
| Mukul | 31000 |
Output:
输出:
31000
Method 1:
方法1:
SELECT MAX (name_of_column) FROM name_of_table WHERE name_of_column NOT IN (SELECT MAX (name_of_column) FROM name_of_table);
SELECT MAX (name_of_column) FROM name_of_table WHERE name_of_column NOT IN (SELECT MAX (name_of_column) FROM name_of_table);
Explanation:
说明:
Here, firstly we are finding the maximum value in the specified column and then we are searching again by excluding the found maximum value.
这里,首先我们找到指定列中的最大值,然后再次搜索时排除已找到的最大值。
Method 2:
方法2:
SELECT name_of_column
SELECT name_of_column
FROM name_of_table p
FROM name_of_table p
WHERE 2 = (SELECT COUNT (DISTINCT name_of_column) FROM name_of_table q WHERE p.column_name <= q.column_name)
WHERE 2 = (SELECT COUNT (DISTINCT name_of_column) FROM name_of_table q WHERE p.column_name <= q.column_name)
We have used a nested sub-query above. Note that this is a generic SQL query that prints the nth largest value. For each record processed by the outer query, the inner query would be executed and it will return how many records have a value lesser than the current value. As our task here is to determine the second largest value, therefore we will stop as soon as the inner returns 2.
上面我们使用了嵌套子查询。注意,这是一个通用的SQL查询,用于打印第n大的值。对于外层查询处理的每条记录,内层查询都会执行,并返回有多少条记录的值小于当前值。由于这里的任务是确定第二大的值,因此一旦内层返回2,我们就会停止。
35. What do you mean by “normalization”?
“规范化”是什么意思?
- 知识点: 数据库 (标签: interviewbit, ey, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: 安永
- id: 69b37aee58d557c902bab5fd | 官方: 否 | 付费: 否
答案:
- Normalization is a way to keep data in the database in an organized manner. In this process, tables are created and relationships are established according to the rules designed to protect the data and to make the database flexible by removing redundancy and inconsistent dependency. Normalization is crucial for many reasons.
- But more specifically, it is important because it enables databases to take up less disk space resulting in increased performance.
36. What is a transparent DBMS?
什么是透明DBMS?
- 知识点: 数据库 (标签: interviewbit, ey, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: 安永
- id: 69b37aef58d557c902bab615 | 官方: 否 | 付费: 否
答案:
A transparent DBMS is one that keeps its physical structure hidden from the users.
透明DBMS是一种对用户隐藏其物理结构的DBMS。
37. What is meant by Proactive Updates, Retroactive Updates and Simultaneous Update in Database Management Systems?
在数据库管理系统中,主动更新、追溯更新和同时更新分别是什么意思?
- 知识点: 数据库 (标签: interviewbit, genpact, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Genpact
- id: 69b37afe58d557c902babf74 | 官方: 否 | 付费: 否
答案:
The meaning of the given terms are as follows: - Proactive Updates: These changes are made to the database before it is put into use in the actual world.
所给术语的含义如下:- 主动更新:这些更改是在数据库投入实际使用之前所做的。
- Retroactive Updates: These updates are applied to a database after it has been operational in the real world.
- Simultaneous Updates: These updates are applied to the database at the same moment as they become effective in the actual world.
38. What is meant by Intension and Extension in Database Management Systems?
在数据库管理系统中,Intension 和 Extension 分别指什么?
- 知识点: 数据库 (标签: interviewbit, genpact, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Genpact
- id: 69b37afe58d557c902babf77 | 官方: 否 | 付费: 否
答案:
The meaning of Intension and Extension are as follows: - Intension: Intension, often known as Database Schema, is a term that refers to the description of a database. This is defined during database design and is largely unmodified.
Intension 和 Extension 的含义如下:- Intension:Intension,通常称为数据库模式(Database Schema),是指数据库的描述。它在数据库设计期间定义,并且基本不会修改。
- Extension: The number of tuples available in the database at any given time is referred to as the extension. The value of this variable changes as tuples are created, updated, and destroyed. As a result, the data in the database at a certain point in time is referred to as the database's extension or, more generally, the database's snapshot.
39. Define Index Hunting. What is it used for in Database Management Systems?
什么是索引查找(Index Hunting)?它在数据库管理系统中有什么用途?
- 知识点: 数据库 (标签: interviewbit, genpact, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Genpact
- id: 69b37afe58d557c902babf7a | 官方: 否 | 付费: 否
答案:
Index hunting is the process of enhancing a collection of indices. The purpose of doing Index Hunting is that indexes make the performance of the queries better and also reduce the time required to process a query. Given below are the various ways in which Index Hunting improves the performance of the queries: - The most optimal queries are suggested with the usage of the query optimizer.
索引查找是优化索引集合的过程。进行索引查找的目的是,索引能提升查询性能,并减少处理查询所需的时间。以下是索引查找改善查询性能的各种方式:- 查询优化器会建议最合适的查询。
- For checking the effect, measurements such as index, query distribution, and performance are used.
- Optimization is also done on the databases for a few of the problem queries.
40. What do you understand about transactions in SQL? What are the properties of transactions in SQL?
你如何理解 SQL 中的事务?SQL 中事务的属性有哪些?
- 知识点: 数据库 (标签: interviewbit, genpact, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Genpact
- id: 69b37afe58d557c902babf7d | 官方: 否 | 付费: 否
答案:
A transaction is a logical unit of work performed on a database. Transactions are logically ordered units or sequences of work that can be completed manually by a human or automatically by a database application. The propagation of one or more changes to the database is referred to as a transaction. For instance, whether you create, update, or delete a record from a table, you are completing a transaction on that table. To preserve data integrity and address database issues, it's critical to keep track of these transactions. In practice, you will group several SQL queries together and run them all at the same time as part of a transaction. Transactions n SQL contain the four standard qualities listed below, which are frequently abbreviated as ACID. - Atomicity: Atomicity ensures the successful completion of all processes inside the work unit. Otherwise, the transaction will be aborted at the point of failure, and all preceding activities would be reversed.
事务是在数据库上执行的逻辑工作单元。事务是由人手动或由数据库应用程序自动完成的逻辑有序单元或工作序列。一个或多个数据库更改的传播称为事务。例如,无论你是创建、更新还是删除表中的记录,你都在对该表执行一个事务。为了保持数据完整性并解决数据库问题,跟踪这些事务至关重要。实际上,你会将多个 SQL 查询分组在一起,并在一个事务中同时运行它们。SQL 中的事务包含以下四个标准特性,通常缩写为 ACID。- 原子性:原子性确保工作单元内所有过程的成功完成。否则,事务将在失败点中止,并且所有先前操作将被撤销。
- Consistency: When a transaction is successfully committed, consistency ensures that the database changes states properly.
- Isolation: Isolation allows transactions to execute independently of one another while remaining transparent to them.
- Durability: Durability ensures that a committed transaction's outcome or effect is preserved in the event of a system failure.
41. Define Subqueries in SQL. Given a table of employees, write down a SQL query using subqueries to find all the employees with salaries greater than five thousand.
在 SQL 中定义子查询。给定一个员工表,写一个使用子查询的 SQL 查询,以找出所有薪水大于五千的员工。
- 知识点: 数据库 (标签: interviewbit, genpact, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Genpact
- id: 69b37afe58d557c902babf80 | 官方: 否 | 付费: 否
答案:
A subquery in SQL is a query that is defined inside another query to retrieve data or information from the database. The outer query of a subquery is referred to as the main query, while the inner query is referred to as the subquery. Subqueries are always processed first, and the subquery's result is then passed on to the main query. It can be nested inside any query, including SELECT, UPDATE, and OTHER. Any comparison operators, such as >, or =, can be used in a subquery. The syntax of a subquery in SQL is given as follows:
SQL 中的子查询是在另一个查询内部定义以从数据库检索数据或信息的查询。子查询的外部查询称为主查询,而内部查询称为子查询。子查询总是首先处理,然后子查询的结果传递给主查询。它可以嵌套在任何查询中,包括 SELECT、UPDATE 和其他查询。子查询中可以使用任何比较运算符,例如 > 或 =。SQL 中子查询的语法如下:
SELECT columnName [, columnName ]
SELECT columnName [, columnName ]
FROM tableOne [, tableTwo ]
FROM tableOne [, tableTwo ]
WHERE columnName OPERATOR
WHERE columnName OPERATOR
(SELECT columnName [, columName ]
(SELECT columnName [, columName ]
FROM tableOne [, tableTwo ]
FROM tableOne [, tableTwo ]
[WHERE])
[WHERE])
A SQL query using subqueries to find all the employees with salaries greater than five thousand in the employee's table is given below:
下面给出一个使用子查询查找员工表中所有工资超过五千的员工的 SQL 查询:
SQL> SELECT * FROM EMPLOYEES
SQL> SELECT * FROM EMPLOYEES
WHERE EMPLOYEE_ID IN (SELECT EMPLOYEE_ID
WHERE EMPLOYEE_ID IN (SELECT EMPLOYEE_ID
FROM EMPLOYEES
FROM EMPLOYEES
WHERE SALARY > 4500) ;
WHERE SALARY > 4500) ;
42. State the various levels of data abstraction in Database Management Systems.
说明数据库管理系统中的数据抽象的各种级别。
- 知识点: 数据库 (标签: interviewbit, genpact, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Genpact
- id: 69b37aff58d557c902babf8c | 官方: 否 | 付费: 否
答案:
In Database Management Systems, there are three basic levels of data abstraction. They are as follows: - Physical Level: The physical level of abstraction specifies how data is stored and is the lowest degree of abstraction.
在数据库管理系统中,有三个基本的数据抽象级别。它们如下:- 物理级:抽象的物理级规定了数据如何存储,是抽象的最低级别。
- Logical or Conceptual Level: After the Physical level, there is the Logical level of abstraction. This layer decides what data is saved in the database and how the data pieces relate to one another.
- View Level: The greatest level of abstraction, the View Level describes only a portion of the entire database.
43. What are Database objects in Database Management Systems?
数据库管理系统中的数据库对象是什么?
- 知识点: 数据库 (标签: interviewbit, genpact, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Genpact
- id: 69b37aff58d557c902babfa8 | 官方: 否 | 付费: 否
答案:
A database object is any object defined in a database that is used to store or reference data. Everything we create from the create command is called a database object. It can be used to store and manipulate data. Some examples of database objects are as follows: - Table - Table is a basic storage unit with compound rows and columns. Its syntax is as follows:
数据库对象是在数据库中定义的、用于存储或引用数据的任何对象。我们通过 create 命令创建的所有内容都称为数据库对象。它可以用于存储和操作数据。数据库对象的一些示例如下:- 表 - 表是具有复合行和列的基本存储单元。其语法如下:
CREATE TABLE [schema.]table (column datatype DEFAULT expr); - Views - Views are a logical representation of subsets of data from one or more tables. A view is a logical table that is based on another view or a table. A view is similar to a window through which data from tables can be viewed or updated, but it does not include any data of its own. Base tables are the tables that a view is built on. In the data dictionary, the view is saved as a SELECT statement. Its syntax is as follows:
CREATE TABLE [schema.]table (column datatype DEFAULT expr); - 视图 - 视图是一个或多个表中数据子集的逻辑表示。视图是基于另一个视图或表的逻辑表。视图类似于一个窗口,通过它可以查看或更新表中的数据,但它本身不包含任何数据。基表是视图所基于的表。在数据字典中,视图保存为一条 SELECT 语句。其语法如下:
CREATE [OR REPLACE] [FORCE|NOFORCE] VIEW view
CREATE [OR REPLACE] [FORCE|NOFORCE] VIEW view
[(alias[, alias]...)]
[(alias[, alias]...)]
AS subquery
AS subquery
[WITH CHECK OPTION [CONSTRAINT constraint]]
[WITH CHECK OPTION [CONSTRAINT constraint]]
[WITH READ ONLY [CONSTRAINT constraint]]; - Sequence - Sequences generate primary key values. A sequence is a database object that has been created by a user and can be shared by several users to generate unique integers. The creation of a primary key value, which must be unique for each row, is a common use for sequences. An internal Oracle routine generates the sequence and increments (or decrements) it. Its syntax is as follows:
[WITH READ ONLY [CONSTRAINT constraint]]; - 序列 - 序列生成主键值。序列是由用户创建的数据库对象,可以由多个用户共享以生成唯一的整数。创建主键值(每行必须唯一)是序列的常见用途。内部Oracle例程生成序列并递增(或递减)它。其语法如下:
CREATE SEQUENCE sequence
CREATE SEQUENCE sequence
[INCREMENT BY n]
[INCREMENT BY n]
[START WITH n]
[START WITH n]
[{MAXVALUE n | NOMAXVALUE}]
[{MAXVALUE n | NOMAXVALUE}]
[{MINVALUE n | NOMINVALUE}]
[{MINVALUE n | NOMINVALUE}]
[{CYCLE | NOCYCLE}]
[{CYCLE | NOCYCLE}]
[{CACHE n | NOCACHE}]; - Indexes - Indexes are used to improve the performance of some queries on the databases. This database object is used to create an index in the database. It is a schema object that can speed up row fetching by using a pointer. Indexes can be created explicitly or automatically. If you don't have an index on the column, full crawling of the table will occur. Indexes provide direct and fast access to table rows. Its goal is to reduce disk Input and Output needs by using an indexed path to quickly locate data. The index is used and maintained automatically by the database server. Once an index is created, no direct action is required by the user. Indexes are logically and physically independent of the table they index. This means they can be created or deleted at any time and do not affect the base tables or other indexes. Its syntax is as follows:
[{CACHE n | NOCACHE}]; - 索引 - 索引用于提高数据库上某些查询的性能。此数据库对象用于在数据库中创建索引。它是一个模式对象,可以通过使用指针加速行提取。索引可以显式或自动创建。如果列上没有索引,将发生全表扫描。索引提供对表行的直接和快速访问。其目标是通过使用索引路径快速定位数据来减少磁盘输入和输出需求。索引由数据库服务器自动使用和维护。一旦创建索引,用户无需直接操作。索引在逻辑和物理上独立于其所索引的表。这意味着它们可以随时创建或删除,并且不影响基表或其他索引。其语法如下:
CREATE INDEX index
CREATE INDEX index
ON table (column[, column]...); - Synonyms - This database object is used to build database indexes. It creates a synonym to make object access easier (another name for an object). You can use synonyms to make referring to a table owned by another user easier and to shorten long object names. You must prefix the table name with the name of the user who created it, followed by a period, to refer to a table owned by another user. Creating a synonym for a table, view, sequence, procedure, or other object avoids the requirement to qualify the object name with the schema and gives you an alternate name. This approach is very handy when dealing with long object names, such as views.In terms of syntax, the meaning of various things are as follows:
ON table (column[, column]...); - 同义词 - 此数据库对象用于构建数据库索引。它创建同义词以使对象访问更容易(对象的另一个名称)。您可以使用同义词使引用另一个用户拥有的表更容易,并缩短长对象名称。要引用另一个用户拥有的表,必须在表名前加上创建它的用户名,后跟一个句点。为表、视图、序列、过程或其他对象创建同义词可避免使用模式限定对象名称的要求,并为您提供替代名称。在处理长对象名称(如视图)时,这种方法非常方便。在语法方面,各种内容的含义如下:
PUBLIC: creates a synonym accessible to all users SYNONYM: it is the name of the synonym to be created OBJECT: identifies the object for which the synonym is created
PUBLIC:创建所有用户均可访问的同义词 SYNONYM:要创建的同义词的名称 OBJECT:标识为其创建同义词的对象
Its syntax is as follows:
其语法如下:
CREATE [PUBLIC] SYNONYM synonym FOR object;
CREATE [PUBLIC] SYNONYM synonym FOR object;
44. State some benefits of using views in a Database Management System.
说明在数据库管理系统中使用视图的一些好处。
- 知识点: 数据库 (标签: interviewbit, genpact, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Genpact
- id: 69b37aff58d557c902babfab | 官方: 否 | 付费: 否
答案:
Some benefits of using views in a Database Management System are as follows: - Views can represent a subset of the data in a table. As a result, a view can limit the extent to which the underlying tables are exposed to the outside world: a user may be allowed to query the view but not the whole of the base database.
在数据库管理系统中使用视图的一些好处如下: - 视图可以表示表中数据的子集。因此,视图可以限制底层表对外部世界的暴露程度:可以允许用户查询视图,但不能查询整个基础数据库。
- Views can be used as aggregated tables, in which the database engine aggregates data (sum, average, and so on) and displays the generated results alongside the data.
- Views allow us to combine and simplify numerous tables into a single virtual table.
- Views take up extremely minimal storage space; the database simply maintains the specification of a view, not a copy of all the data it displays.
- Views can obscure data complexity.
- Views can give additional security depending on the SQL engine utilized.
45. State your understanding of Entity Relationship (or the ER) model. Also, define the following terms: Entities, Entity Types, and Entity Sets in Database Management Systems.
说明您对实体关系(或ER)模型的理解。此外,在数据库管理系统中定义以下术语:实体、实体类型和实体集。
- 知识点: 数据库 (标签: interviewbit, genpact, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Genpact
- id: 69b37aff58d557c902babfb2 | 官方: 否 | 付费: 否
答案:
A diagrammatic approach to database architecture in which real-world things are represented as entities and relationships between them are indicated is known as an Entity-Relationship model. Given below is an image of a sample ER diagram for a student studying in college.
一种数据库架构的图解方法,其中现实世界的事物被表示为实体,它们之间的关系被表示出来,这被称为实体-关系模型。下面是一张示例ER图,用于展示一个在大学学习的学生。
The definition of the given terms are as follows: - Entity: A real-world object with attributes that indicate the object's qualities is defined as an entity. A student, an employee, or a teacher, for example, symbolizes an entity.
所给术语的定义如下:- 实体:具有指示对象品质的属性的现实世界对象被定义为实体。例如,一个学生、一名员工或一位教师代表一个实体。
- Entity Type: A group of entities with the same attributes is referred to as an entity type. An entity type is represented by one or more linked tables in a database. Entity type or attributes can be thought of as a trait that distinguishes the entity from others. A student, for example, is an entity with properties such as student id, student name, and so on.
- Entity Set: An entity set is a collection of all the entities in a database that belongs to a given entity type. For instance, a group of all students, employees, teachers, and so on represents an entity set.
46. What do you understand about the ACID properties in Database Management Systems?
关于数据库管理系统中的ACID属性,你了解什么?
- 知识点: 数据库 (标签: interviewbit, genpact, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Genpact
- id: 69b37aff58d557c902babfb8 | 官方: 否 | 付费: 否
答案:
ACID is an acronym for Atomicity, Consistency, Isolation, and Durability. A transaction is a logical unit of work that reads and updates the contents of a database in some instances. Transactions employ read and write operations to access data. To maintain database consistency, certain properties are followed before and after a transaction. They are referred to as ACID properties. Let us now take a closer look at each of these characteristics: - Atomicity: When a transaction is atomic, it means that it either happens all at once or it does not happen at all. There is no intermediate ground, which means that there are no steps to transactions. Each transaction is viewed as a single entity that is either completed or not. It entails the two processes listed below.
ACID是原子性(Atomicity)、一致性(Consistency)、隔离性(Isolation)和持久性(Durability)的缩写。事务是一个逻辑工作单元,在某些情况下读取和更新数据库的内容。事务使用读和写操作来访问数据。为了保持数据库一致性,在事务前后遵循某些属性。它们被称为ACID属性。现在让我们更仔细地看看这些特性:- 原子性:当一个事务是原子的时,意味着它要么全部发生,要么根本不发生。没有中间状态,这意味着事务没有中间步骤。每个事务都被视为一个单一实体,要么完成,要么未完成。它涉及下面列出的两个过程。
Abort: Any database updates are lost if a transaction aborts. Commit: When a transaction commits, the changes contained within it become visible. Atomicity is often known as the "all or nothing rule.
中止:如果事务中止,任何数据库更新都会丢失。提交:当事务提交时,其中包含的更改变得可见。原子性通常被称为“全有或全无规则”。
Think about the following scenario: T, which is made up of two separate transactions: T1 and T2. A $100 transfer was made from account X to account Y. The amount deducted from X but not added to Y is deducted if a transaction fails after T1 but before T2 (for example, after write(X) but before write(Y)). As a result, the database is in a state of inconsistency. As a result, to ensure that the database state is legitimate, the transaction must be completed in its entirety. - Consistency: To ensure that the database is consistent, integrity constraints must be maintained both before and after the transaction. It relates to the accuracy of a database. As seen in the sample above, the total amount before and after the transaction must be maintained.The total before T is 500 + 200 = 700.The total after T is 400 + 300 = 700.As a result, the database is well-organized. There is inconsistency when T1 succeeds but T2 fails. As a result, T isn't finished.
考虑以下场景:T由两个独立的事务组成:T1和T2。从账户X向账户Y转移了100美元。如果在T1之后但在T2之前事务失败(例如,在write(X)之后但在write(Y)之前),则从X扣除的金额未添加到Y。因此,数据库处于不一致状态。因此,为了确保数据库状态合法,事务必须完整完成。- 一致性:为了确保数据库一致,必须在事务前后维护完整性约束。它与数据库的准确性有关。如上面的示例所示,事务前后的总额必须保持不变。T之前的总额是500 + 200 = 700。T之后的总额是400 + 300 = 700。因此,数据库是有序的。当T1成功但T2失败时,就会出现不一致。因此,T没有完成。
- Isolation: This property ensures that several transactions can run concurrently without generating database state inconsistencies. Transactions are carried out in a non-disruptive manner. Changes in one transaction are not visible to other transactions until the change for that transaction is put to memory or committed. This feature ensures that concurrently running transactions provide the same state as if they were run sequentially in some order. To better understand Isolation, consider the following scenario. Let us say X and Y are both 500, and there are two transactions T and T."
Assume T has been operating until Read (Y), after which T" will start. T" reads the correct value of X but the incorrect value of Y as a result of this interleaving, and the sum computed by T" (X+Y = 50, 000+500=50, 500) is inconsistent with the sum at the end of the transaction: T = 50, 000 + 450 = 50, 450 (X+Y = 50, 000 + 450 = 50, 450). This results in a database inconsistency due to the loss of 50 units. As a result, transactions must be carried out in isolation, and modifications should be seen only after they have been written to the main memory. - Durability: This property ensures that database updates and modifications are stored and written to disk after the transaction has concluded and that they survive even if the system fails. These modifications are now permanently recorded in nonvolatile memory. As a result, the transaction's effects are never lost.
假设T一直运行到Read (Y),之后T"将开始。由于这种交错,T"读取了正确的X值但错误的Y值,并且T"计算的总和(X+Y = 50, 000+500=50, 500)与事务结束时的总和:T = 50, 000 + 450 = 50, 450(X+Y = 50, 000 + 450 = 50, 450)不一致。这由于丢失50个单位而导致数据库不一致。因此,事务必须隔离执行,并且修改应仅在写入主存后才可见。- 持久性:此属性确保在事务结束后数据库更新和修改被存储并写入磁盘,并且即使系统发生故障它们也能存活。这些修改现在永久记录在非易失性存储器中。因此,事务的影响永远不会丢失。
Each transaction is a series of actions that works as a single unit, provides consistent outcomes, is separated from other processes, and the modifications it makes are durably stored, according to the ACID properties.
根据ACID属性,每个事务是一系列操作,作为单个单元工作,提供一致的结果,与其他过程隔离,并且它所做的修改被持久存储。
47. Define the terms: Aggregation and Atomicity in Database Management Systems.
定义数据库管理系统中的术语:聚合和原子性。
- 知识点: 数据库 (标签: interviewbit, genpact, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Genpact
- id: 69b37aff58d557c902babfbb | 官方: 否 | 付费: 否
答案:
The definition of the given terms are as follows: - Aggregation: Aggregation is an Entity Relationship model feature that allows one relationship set to interact with another relationship set.
所给术语的定义如下:- 聚合:聚合是实体关系模型的一个特性,它允许一个关系集与另一个关系集交互。
Atomicity: The atomicity attribute specifies that a database alteration must either adhere to all of the rules or not at all. As a result, if one portion of the transaction fails, the transaction as a whole fails.
GenPact Interview Preparation
48. What is a join in SQL?
SQL中的连接是什么?
- 知识点: 数据库 (标签: interviewbit, goldman-sachs, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: 高盛
- id: 69b37b1458d557c902bacbfe | 官方: 否 | 付费: 否
答案:
Joins in SQL join rows from two or more tables based on a shared column. The different categories of joins are: - INNER JOIN returns rows when both tables have a match.
SQL中的连接基于共享列连接来自两个或多个表的行。连接的不同类别有:- INNER JOIN在两个表都有匹配时返回行。
- LEFT JOIN returns all rows from the left table, even if the right table has no matches.
- RIGHT JOIN returns all rows from the right table, even if the left table doesn't have any matches.
- FULL OUTER JOIN returns rows when one of the tables has a match.
- SELF JOIN is a SQL statement that joins a table to itself as if it were two tables, temporarily renaming at least one table.
CARTESIAN JOIN (CROSS JOIN) returns the Cartesian product of two or more joined tables' sets of records.
Additional Resources其他资源
SQL
SQL
Data Structures
数据结构
OOPs
面向对象编程
Java
Java
JavaScript
JavaScript
Networking
网络
49. What is a Database Transaction? And why are Database Transactions Important?
什么是数据库事务?为什么数据库事务很重要?
- 知识点: 数据库 (标签: interviewbit, hashedin, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: HashedIn
- id: 69b37b3058d557c902badbba | 官方: 否 | 付费: 否
答案:
A database transaction is a set of operations that are treated as a single unit of work. If one operation fails, then the entire transaction is rolled back (canceled) and the data is restored to the state it was in before the transaction started. Transactions ensure that the database maintains its integrity by preventing data from being corrupted or lost if one of its components fails. If no transaction is specified, the database system will treat each SQL statement as an independent transaction, which can lead to inconsistent data and errors if any of the SQL statements fail.
数据库事务是一组被视为单一工作单元的操作。如果一个操作失败,则整个事务被回滚(取消),数据恢复到事务开始前的状态。事务通过防止在某个组件发生故障时数据被损坏或丢失,确保数据库保持其完整性。如果未指定事务,数据库系统会将每条SQL语句视为独立的事务,这可能导致数据不一致,并且如果任何SQL语句失败还会引发错误。
The main reason database transactions are important is to ensure data integrity. When using a database, there is always a risk that something might go wrong and cause an error, or worse, corrupt data. Transactions can be set to automatically roll back if an error occurs, thus preventing data from being changed in the case of an error. If you’re writing data to your database, it’s important to use database transactions. By doing so, you can ensure that your data is written correctly and that if there’s an error, it will be rolled back so no data is lost. If you don’t use database transactions, an error could cause your data to be written incorrectly or not written at all.
数据库事务之所以重要的主要原因是确保数据完整性。使用数据库时,总是存在某些环节出错并导致错误、甚至更糟——损坏数据的风险。事务可以设置为在发生错误时自动回滚,从而在出错时防止数据被更改。如果你正在向数据库写入数据,使用数据库事务很重要。通过这样做,你可以确保数据被正确写入,并且如果出现错误,它将被回滚,从而不会丢失任何数据。如果你不使用数据库事务,错误可能导致数据被错误写入或完全未写入。
50. What is DBMS?
什么是DBMS?
- 知识点: 数据库 (标签: interviewbit, hashedin, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: HashedIn
- id: 69b37b3058d557c902badbbd | 官方: 否 | 付费: 否
答案:
DBMS is a software application used to create, manage, and store databases. Some of the most popular database management systems are Microsoft SQL Server, Oracle, MySQL, and IBM DB2. The most important function of a database management system is to store and retrieve data from a database. The data can come from almost any source, from different kinds of sensors or scanners, or from a legacy system such as ERP or HRM. A database contains information that can be accessed, updated, and shared. It is stored on a server, accessed by many people at the same time, and can be used to analyze trends and make predictions. A database management system is a software used to manage the database: create it, populate it with data, and secure it.
DBMS是用于创建、管理和存储数据库的软件应用程序。一些最流行的数据库管理系统包括Microsoft SQL Server、Oracle、MySQL和IBM DB2。数据库管理系统最重要的功能是从数据库中存储和检索数据。数据可以来自几乎任何来源,来自不同类型的传感器或扫描仪,或来自ERP或HRM等遗留系统。数据库包含可以访问、更新和共享的信息。它存储在服务器上,可被许多人同时访问,并可用于分析趋势和做出预测。数据库管理系统是用于管理数据库的软件:创建它、用数据填充它并保护它。
51. What are Databases?
什么是数据库?
- 知识点: 数据库 (标签: interviewbit, hashedin, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: HashedIn
- id: 69b37b3058d557c902badbc6 | 官方: 否 | 付费: 否
答案:
Databases consist of logical, consistent, and organized data that can be accessed, managed, and updated easily. It is also known as an electronic database. Electronic databases are structured to provide the facility of creating, inserting, and updating data efficiently. They are typically stored on magnetic disks, tapes, or another sort of secondary storage medium. Objects in the database are called tables, and the records and fields are called records. An entity described by a database is described in terms of fields, which contain information about particular aspects or attributes of that entity. Database management systems are used to extract data from databases using queries.
数据库由逻辑上一致且有组织的数据组成,这些数据可以轻松地被访问、管理和更新。它也被称为电子数据库。电子数据库的结构旨在提供高效创建、插入和更新数据的功能。它们通常存储在磁盘、磁带或另一种二级存储介质上。数据库中的对象称为表,记录和字段称为记录。数据库所描述的实体通过字段来描述,字段包含有关该实体特定方面或属性的信息。数据库管理系统用于通过查询从数据库中提取数据。
52. What do you mean by DBMS?
你说的DBMS是什么意思?
- 知识点: 数据库 (标签: interviewbit, hcl, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: HCL Technologies
- id: 69b37b3658d557c902badf6e | 官方: 否 | 付费: 否
答案:
The Database management system (DBMS), is software or a tool that helps in managing the data of the entire organization. Large amounts of data can be stored properly and can be presented as information whenever required to take business decisions.
数据库管理系统(DBMS)是帮助管理整个组织数据的软件或工具。大量数据可以被妥善存储,并在需要做出业务决策时随时作为信息呈现。
Following are some of the features of a Database management system (DBMS): - Database Customization.
以下是数据库管理系统(DBMS)的一些特性:- 数据库定制。
- Easiness in Data Management.
- Data Availability.
- Minimized Redundancy.
- Data Accuracy, Consistency and Relevance.
- File Consistency.
- Improved Data Security.
Data Structuring.
Some DBMS examples are MySQL, PostgreSQL, FileMaker, Oracle, Microsoft Access.一些DBMS示例包括MySQL、PostgreSQL、FileMaker、Oracle、Microsoft Access。
53. What are constraints in SQL?
SQL中的约束是什么?
- 知识点: 数据库 (标签: interviewbit, hcl, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: HCL Technologies
- id: 69b37b3658d557c902badf71 | 官方: 否 | 付费: 否
答案:
Constraints in SQL are the limits or rules that we can apply to the different types of data in a given table. Constraints are used to ensure the accuracy and reliability of the data in the table.
SQL中的约束是我们可以应用于给定表中不同类型数据的限制或规则。约束用于确保表中数据的准确性和可靠性。
The constraints in SQL are as follows: - NOT NULL: This particular constraint informs us that one cannot store a null value within a column.
SQL 中的约束如下:- NOT NULL:这一特定约束告诉我们,不能在列中存储空值。
- UNIQUE: When specified with a column, this constraint informs that all the values in a given column must be unique.
- PRIMARY KEY: A primary key is a field that can uniquely identify each row in a table. This is typically used to specify a field in a table as the primary key.
- FOREIGN KEY: A Foreign key is a field that can uniquely identify each row in another table.
- CHECK: This constraint helps us to validate the values of a column to attain a particular condition.
- DEFAULT: This constraint gives a default value for the column when the user does not specify a value.
54. What are aggregate functions in SQL?
什么是 SQL 中的聚合函数?
- 知识点: 数据库 (标签: interviewbit, hcl, company-specific)
- 类型: technical | 难度: easy | 子类型: coding
- 分类: general
- 公司: HCL Technologies
- id: 69b37b3658d557c902badf74 | 官方: 否 | 付费: 否
答案:
A function is a unit of code that is used for the purpose of reusability of a part of a program. An SQL aggregate function calculates on a set of values and returns a single value. The function should return a value. Some SQL aggregate functions are as follows: - AVG() - It returns the average of a set.
函数是一段用于实现程序某部分可重用性的代码单元。SQL 聚合函数对一组值进行计算并返回单个值。该函数应返回一个值。一些 SQL 聚合函数如下:- AVG() - 它返回一组值的平均值。
- COUNT() - It returns the number of items in a set.
- MAX() - It returns the maximum value in a set.
- MIN() - It returns the minimum value in a set.
- SUM() - It returns the sum of all or distinct values in a set.
55. What is the procedure for creating a MySQL database with PHP?
使用 PHP 创建 MySQL 数据库的步骤是什么?
- 知识点: 数据库 / 编程语言基础 (标签: interviewbit, justdial, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Justdial
- id: 69b37b8158d557c902bb13ea | 官方: 否 | 付费: 否
答案:
A database is a collection of interconnected data that allows for efficient data retrieval, insertion, and deletion from a database and organises the data into tables, views, schemas, and reports. For example, a university database organises data about students, faculty, and administrative staff, among other things, allowing for easy data retrieval, insertion, and deletion.
数据库是相互关联数据的集合,它允许高效地从数据库中检索、插入和删除数据,并将数据组织成表、视图、模式和报表。例如,大学数据库组织有关学生、教职员工和行政人员等的数据,从而便于轻松地检索、插入和删除数据。
The following are the fundamental procedures for creating a MySQL database with PHP: - Connect to the MySQL server from your PHP script.
以下是使用 PHP 创建 MySQL 数据库的基本步骤:- 从你的 PHP 脚本连接到 MySQL 服务器。
- If the connection is successful, construct a database using SQL and save it in a string variable.
- Then, one by one, the constructed queries will be run.
56. What are the benefits of a database management system (DBMS)? Mention the many DBMS languages available.
数据库管理系统(DBMS)有哪些好处?提及可用的多种 DBMS 语言。
- 知识点: 数据库 (标签: interviewbit, justdial, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Justdial
- id: 69b37b8158d557c902bb140b | 官方: 否 | 付费: 否
答案:
Database Management System (DBMS) is a collection of apps or tools that allow users to construct and manage databases. A database management system (DBMS) provides a tool or interface for executing various database activities such as inserting, removing, updating, and so on. It is software that allows data to be stored more compactly and securely than a file-based system. A database management system (DBMS) assists a user in overcoming issues such as data inconsistency, data redundancy, and other issues in a database, making it more comfortable and organised to use. The following are some of the benefits of using a database management system: - Data sharing: Data from the same database can be accessed by multiple people at the same time.
数据库管理系统(DBMS)是允许用户构建和管理数据库的应用程序或工具的集合。数据库管理系统(DBMS)提供用于执行各种数据库活动(如插入、删除、更新等)的工具或接口。它是一种软件,允许比基于文件的系统更紧凑、更安全地存储数据。数据库管理系统(DBMS)帮助用户克服数据库中的数据不一致、数据冗余等问题,使其使用起来更舒适、更有条理。以下是使用数据库管理系统的一些好处:- 数据共享:同一数据库中的数据可同时被多人访问。
- Integrity limitations: These limitations allow for more refined data storage in a database.
- Data redundancy control: Supports a system for controlling data redundancy by combining all data into a single database.
- Data Independence: This allows the structure of the data to be changed without affecting the structure of any running application.
Backup and recovery feature: Provides a 'backup and recovery capability that automatically creates a data backup and restores the data as needed.
The following are the several languages found in DBMS: - DDL (Data Definition Language) is a set of commands used to define a database.以下是 DBMS 中发现的几种语言:- DDL(数据定义语言)是用于定义数据库的一组命令。
- DML (Data Manipulation Language) is a set of commands that can be used to manipulate data in a database.
- DCL (Data Control Language) - Consists of commands that deal with database system user permissions and controls.
- TCL (Transaction Control Language) is a set of instructions that deal with database transactions.
57. What are the ACID attributes of a database management system (DBMS)?
数据库管理系统(DBMS)的 ACID 属性是什么?
- 知识点: 数据库 (标签: interviewbit, justdial, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Justdial
- id: 69b37b8158d557c902bb140e | 官方: 否 | 付费: 否
答案:
Any type of information can be stored in a database using a database management system. ACID (atomicity, consistency, isolation, and durability) properties must be supported by the database management system. It is used to verify that data transactions in a database system are processed reliably. - Atomicity: Atomicity refers to transactions that are either totally successful or completely unsuccessful. Each transaction here refers to a single logical data operation. As a result, even if one element of a transaction fails, the transaction as a whole fails, leaving the database state unaffected.
使用数据库管理系统可以将任何类型的信息存储在数据库中。数据库管理系统必须支持 ACID(原子性、一致性、隔离性和持久性)属性。它用于验证数据库系统中的数据事务是否被可靠地处理。- 原子性:原子性指事务要么完全成功,要么完全失败。这里的每个事务指单个逻辑数据操作。因此,即使事务的某个元素失败,整个事务也会失败,数据库状态不受影响。
- Consistency: Consistency ensures that the data adheres to all of the validation standards. In basic terms, your transaction never leaves the database before it has completed its state. The purpose is to verify that the database is consistent before and after the transaction. A transaction is aborted and an error is raised if it leaves data in an incorrect state.
- Isolation: Concurrency control is the primary purpose of isolation. This feature ensures that each transaction is isolated, ensuring that it will not be affected by any other concurrent transactions. It means that until a transaction is completed, it will not be interrupted by another transaction.
Durability: Once a transaction is completed and committed, its modifications are saved in the database indefinitely. This attribute assures that the data saved in the database is immutable until it is affected by another update or deletion transaction.
Even if a significant problem occurs, such as a crash or a power outage, once the transaction is committed, it will remain in this condition. The completed transactions are recorded on non-volatile memory devices such as hard drives, for this reason, ensuring that the data is always available, even if the DB instance is restarted.即使发生重大问题,如崩溃或断电,一旦事务提交,它将保持此状态。已完成的事务记录在硬盘等非易失性存储设备上,因此确保数据始终可用,即使 DB 实例重新启动。
The ACID qualities protect the database's data integrity and consistency, ensuring that data does not become corrupt as a result of a failure. Only transactions that were successful will be handled in databases that use the ACID features, and if a failure occurs before a transaction is completed, the data will not be modified.
ACID 特性保护数据库的数据完整性和一致性,确保数据不会因故障而损坏。在使用 ACID 特性的数据库中,只有成功的事务才会被处理,如果事务完成前发生故障,数据将不会被修改。
58. What are the various levels of abstraction in a database management system?
数据库管理系统中有哪些不同的抽象级别?
- 知识点: 数据库 (标签: interviewbit, justdial, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Justdial
- id: 69b37b8158d557c902bb1427 | 官方: 否 | 付费: 否
答案:
The technique of hiding unnecessary elements from the user is known as data abstraction. To achieve Data Independence, there are three degrees of data abstraction, which we divide into three levels. Users and data should not interact directly with each other, according to data independence. The user should be on a different level than the data, and the data should also be on a distinct level. Data Independence can be obtained in this way. In DBMS, there are three degrees of data abstraction. They are as follows: - Physical level: The physical level of abstraction specifies how data is kept and is the lowest degree of abstraction. The physical level of a database management system (DBMS) specifies how data is really stored and describes data structures in-depth as well as database access techniques. The database developer will pick how to store the data in the database. It is quite difficult to comprehend.
对用户隐藏不必要元素的技术称为数据抽象。为了实现数据独立性,有三个数据抽象程度,我们将其分为三个级别。根据数据独立性,用户和数据不应直接相互交互。用户应处于与数据不同的级别,数据也应处于不同的级别。这样可以获得数据独立性。在 DBMS 中,有三个数据抽象程度。它们如下:- 物理层:抽象的物理层指定数据如何保存,是最低程度的抽象。数据库管理系统(DBMS)的物理层指定数据实际如何存储,并深入描述数据结构以及数据库访问技术。数据库开发者将选择如何在数据库中存储数据。这相当难以理解。
- Logical level: After the Physical level, there is the Logical level of abstraction. This layer decides what data is saved in the database and how the data pieces relate to one another. Let's look at an example where we're storing data using the relational model. The student table will comprise columns such as student name, age, mail id, roll no, and so on to hold the data of a student. All of them must be defined at this level while developing the database. Though the data is kept in the database, the tables' structures, such as the student table, teacher table, books table, and so on, are specified at the conceptual or logical level. The relationship between the tables is also defined here. Overall, we might say that we are developing a conceptual model of the data.
- View Level: The greatest level of abstraction, the View Level describes only a portion of the entire database. When you get to the third level, which is the highest level, you'll see that it's called the view level. This is the level that is visible from the outside. In the view level, there are various levels of views, each of which attempts to describe only a portion of the complete data. Because it provides different views of the same database, it simplifies user interaction. It also allows you to have several views of the same database. As a student, we can examine our grades, attendance, price structure, and other information if we have a login-id and password in a university system. The university professors, on the other hand, will hold a different viewpoint. He will have options such as salary, editing a student's grades, entering student attendance, and so on. As a result, both the student and the instructor have opposing viewpoints. As a result, the system's security is enhanced. In this case, the student is unable to alter his grades, but the faculty member who is permitted to do so can do so. As a result, depending on their level of authorisation, different users will see things differently.
59. What do you understand by query optimisation in the context of SQL?
在 SQL 的上下文中,你对查询优化有何理解?
- 知识点: 数据库 (标签: interviewbit, lti, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: LTIMindtree
- id: 69b37b8b58d557c902bb1ce7 | 官方: 否 | 付费: 否
答案:
A single query can be run using various methods or rewritten in various formats and structures. As a result, the topic of query optimization arises: which of these forms or paths is the most efficient? The query optimizer considers all alternative query plans to discover the most efficient way to execute a query.
一个查询可以使用多种方法运行,或以各种格式和结构重写。因此,查询优化的问题就出现了:这些形式或路径中哪一种最有效?查询优化器会考虑所有备选查询计划,以找出执行查询的最高效方式。
The purpose of query optimization is to reduce the number of system resources necessary to complete a query, allowing the user to receive the proper result set more quickly. - It gives the user faster results, making the application appear to be speedier.
查询优化的目的是减少完成查询所需的系统资源数量,使用户能够更快地收到正确的结果集。- 它为用户提供更快的结果,使应用程序看起来更迅速。
- Second, because each request takes less time than unoptimized queries, the system can handle more queries in the same amount of time.
Finally, query optimization decreases the amount of wear on the server's hardware (for example, disk drives) and allows it to run more efficiently (e.g. lower power consumption, less memory usage).
A query can be optimised in one of two ways: - Analyze and alter relational phrases that are equivalent: Reduce the number of tuples and columns in the intermediate and final query processes (discussed here).查询可以通过以下两种方式之一进行优化:- 分析并改写等价的关系表达式:减少中间查询过程和最终查询过程中的元组和列的数量(此处讨论)。
- For each operation, multiple algorithms can be used: These underlying techniques influence the frequency of disk and block accesses by determining how tuples are accessed from the data structures they are stored in, indexing, hashing, and data retrieval.
60. What do you understand about Data Independence in the context of DataBase Management Systems (DBMS)?
在数据库管理系统(DBMS)的背景下,你对数据独立性有何理解?
- 知识点: 数据库 (标签: interviewbit, lti, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: LTIMindtree
- id: 69b37b8b58d557c902bb1cf4 | 官方: 否 | 付费: 否
答案:
In Database Management Systems (DBMS), data independence implies that the application is independent of the storage structure and data access mechanism. It allows you to change the schema definition at one level without having to change the schema definition at the next level up.
在数据库管理系统(DBMS)中,数据独立性意味着应用程序独立于存储结构和数据访问机制。它允许你在一个层次上更改模式定义,而无需在上一层次更改模式定义。
Data independence can be divided into two categories: - Physical Data Independence: The data contained in the database is referred to as physical data. It's in a binary format. Physical changes should not have an impact on the logical level. For example, if we wish to edit data within a table, we shouldn't change the table's format.
数据独立性可以分为两类:- 物理数据独立性:数据库中包含的数据称为物理数据。它采用二进制格式。物理更改不应影响逻辑层次。例如,如果我们希望编辑表中的数据,就不应该更改表的格式。
- Logical Data Independence (LDI): The ability to update the conceptual schema without having to change the external schema is referred to as logical data independence. To distinguish the external level from the conceptual view, logical data independence is used. Any modifications to the conceptual representation of the data will not affect the user’s view of the data.
61. What do you understand about ACID properties in the context of Database Management Systems (DBMS)?
在数据库管理系统(DBMS)的背景下,你对 ACID 属性有何理解?
- 知识点: 数据库 (标签: interviewbit, lti, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: LTIMindtree
- id: 69b37b8b58d557c902bb1cf7 | 官方: 否 | 付费: 否
答案:
The ACID properties for a transaction in SQL DBMS refers to the following properties:
SQL DBMS 中事务的 ACID 属性指的是以下属性:
- Atomicity: Atomicity refers to the fact that data remains atomic. It means that if any operation on the data is conducted, it should either be performed or executed completely, or it should not be performed at all. It also implies that the operation should not be interrupted or just half completed. When performing operations on a transaction, the operation should be completed rather than partially.
- Consistency: The term "consistency" denotes that the value should be retained at all times. The integrity of the data should be maintained in DBMS, which means that whenever a modification is made to the database, it should always be preserved. The integrity of the data is critical in transactions so that the database remains consistent before and after the transaction. The information should always be accurate.
- Isolation: The term "isolation" refers to the act of being separated from others. Isolation in DBMS refers to the property of a database where no data from one database should impact the other and where many transactions can take place at the same time. In other words, when the operation on the first database is finished, the process on the second database should begin. It indicates that if two actions are conducted on two different databases, the value of one database may not be affected by the value of the other. When two or more transactions occur at the same time in the case of transactions, consistency should be maintained. Any modifications made in one transaction will not be visible to other transactions until the change is committed to the memory.
- Durability: The term "durability" refers to something's ability to last. The term durability in DBMS refers to the fact that if an operation is completed successfully, the data remains permanent in the database. The database's durability should be such that even if the system fails or crashes, the database will survive. However, if the database is lost, the recovery manager is responsible for guaranteeing the database's long-term viability. Every time we make a change, we must use the COMMIT command to commit the values.
62. What do you understand about checkpoints in the context of Database Management Systems (DBMS)? What are the advantages of using checkpoints?
在数据库管理系统(DBMS)的背景下,你对检查点有何理解?使用检查点有哪些优势?
- 知识点: 数据库 (标签: interviewbit, lti, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: LTIMindtree
- id: 69b37b8b58d557c902bb1cfd | 官方: 否 | 付费: 否
答案:
The checkpoint specifies a time when the DBMS was in a consistent state and all transactions had been committed. These checkpoints are tracked during transaction execution. Transaction log files will be created after the execution. The log file is destroyed when it reaches the savepoint/checkpoint by recording its update to the database. Then a new log is produced with the transaction's upcoming execution actions, which is updated until the next checkpoint, and the process continues.
检查点指定了 DBMS 处于一致状态且所有事务均已提交的时间点。这些检查点在事务执行期间被跟踪。事务日志文件将在执行后创建。当日志文件通过记录其对数据库的更新到达保存点/检查点时,该日志文件被销毁。然后会生成一个新的日志,其中包含事务即将执行的操作,该日志会持续更新直到下一个检查点,此过程不断重复。
When transaction logs are created in a real-time setting, they consume a significant amount of storage space. Keeping track of each update and maintaining it may also take up more physical space on the system. As the transaction log file grows in size, it may eventually become unmanageable. Checkpoints can be used to address this. A Checkpoint is a way for deleting all prior transaction logs and saving them in a permanent storage location.
在实时环境中创建事务日志时,它们会消耗大量存储空间。跟踪每次更新并维护它也可能占用系统上更多的物理空间。随着事务日志文件大小的增长,它最终可能变得难以管理。检查点可用于解决此问题。检查点是一种删除所有先前事务日志并将其保存到永久存储位置的方法。
The following are the advantages of checkpoints: - It makes the data recovery procedure go faster.
以下是检查点的优势:- 它使数据恢复过程进行得更快。
- The majority of DBMS packages perform self-checkpoints.
- To avoid unnecessary redo operations, checkpoint records in the log file are employed.
- It has very low overhead and can be done frequently because dirty pages are flushed away continuously in the background.
63. What do you understand by super key, candidate key, primary key and foreign key in the context of database management systems?
在数据库管理系统的上下文中,你对超键、候选键、主键和外键的理解是什么?
- 知识点: 数据库 (标签: interviewbit, mindtree, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Mindtree
- id: 69b37bd358d557c902bb4bf3 | 官方: 否 | 付费: 否
答案:
- Super key: Super Key is a set of attributes that can be used to uniquely identify a tuple. The super key is created by adding zero or more attributes to the candidate key. A candidate key is a super key, but not the other way around.
- Candidate key: A candidate key is the smallest set of attributes that can uniquely identify a tuple. For each tuple, the Candidate Key value is unique and non-null. In relation, there can be more than one candidate key. The candidate key might be simple (only having one attribute) or composite (containing multiple attributes).
- Primary key: In relation, there may be more than one candidate key, with one being chosen as the primary key. This primary key is chosen by the database administrator based on the requirements amongst the candidate keys.
- Foreign key: A foreign key is a column or set of columns in a relational database table that connects data from two other tables. It serves as a cross-reference between tables by referencing the primary key of another table and therefore creating a relationship between them.
For example, let us consider tables with the following schema :
例如,让我们考虑具有以下模式的表:
Teacher :
Teacher:
teacher_id (primary key), teacher_name, teacher_phone_number, teacher_aadhar, teacher_department_id
teacher_id(主键)、teacher_name、teacher_phone_number、teacher_aadhar、teacher_department_id
Department :
Department:
department_id (primary key), department_name
department_id(主键)、department_name
Here, for the Teacher table, the following are the different types of keys present : - The candidate keys can be teacher_id, teacher_phone_number and teacher_aadhar since they all can uniquely identify a record of the table.
这里,对于 Teacher 表,存在以下不同类型的键:- 候选键可以是 teacher_id、teacher_phone_number 和 teacher_aadhar,因为它们都能唯一标识表中的一条记录。
- Out of the above three candidate keys, any one of them can be chosen as the primary key. We generally choose teacher_id as the primary key.
- Any of the above candidate keys when grouped with any other key form the super key. For example, teacher_id, teacher_name can together form a super key.
- Teacher_department_id is a foreign key for the Teacher table since it is a primary key in the Department table and it links the two tables.
Successful Tech Career for FREE!
免费开启成功的科技职业生涯!
Successful Tech Career!
成功的技术职业生涯!
Interview Process
面试流程
CTC & Designation
CTC与职位级别
Projects on the Job
工作项目
Referral System
推荐系统
Try It Out
试试看
2 Lakh+ Roadmaps Created
已生成20万+职业规划
64. What are the different types of SQL commands?
SQL 命令有哪些不同类型?
- 知识点: 数据库 (标签: interviewbit, mindtree, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Mindtree
- id: 69b37bd358d557c902bb4bf7 | 官方: 否 | 付费: 否
答案:
Following are the different types of SQL commands : - Data Definition Language (DDL): DDL commands are those commands that modify the table's structure, such as by adding, deleting, or changing a table. All DDL commands are auto-committed, which means they store all database changes permanently. Example - Create, Drop, Truncate, Alter.
以下是 SQL 命令的不同类型:- 数据定义语言(DDL):DDL 命令是那些修改表结构的命令,例如添加、删除或更改表。所有 DDL 命令都是自动提交的,这意味着它们会永久保存所有数据库更改。示例 - Create、Drop、Truncate、Alter。
- Data Manipulation Language (DML): The database is modified using DML commands. It is in charge of all database modifications of any kind. The DML command is not auto-committed, which means it cannot preserve all database modifications permanently. They have the potential to be rolled back. Example - Insert, Update, Delete.
- Data Control Language: Any database user can be granted or revoked authority using DCL commands. Example - Grant, Revoke.
- Transaction Control Language (TCL): Transaction Control Language commands are commands that are used to manage transactions in a database. Only DML commands like INSERT, DELETE, and UPDATE can be used with TCL commands. Because these activities are automatically committed to the database, they can't be used while creating or dropping tables. Example - Commit, Rollback, Savepoint.
- Data Query Language (DQL): DQL commands are used to fetch data from the database. Example - Select.
65. Differentiate between Delete and Truncate SQL commands.
区分 Delete 和 Truncate SQL 命令。
- 知识点: 数据库 (标签: interviewbit, mindtree, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Mindtree
- id: 69b37bd358d557c902bb4bfd | 官方: 否 | 付费: 否
答案:
The following table lists the differences between Delete and Truncate SQL commands:
下表列出了 Delete 和 Truncate SQL 命令之间的区别:
| Delete | Truncate |
|---|---|
| The DELETE command is used to remove specific rows from a table (one or more). DELETE 命令用于从表中删除特定行(一行或多行)。 | This command is used to delete all of the rows in a table. 此命令用于删除表中的所有行。 |
| It is a Data Manipulation Language (DML) command. 它是数据操作语言(DML)命令。 | It is a Data Definition Language (DDL) command. 它是数据定义语言(DDL)命令。 |
| In order to filter the records, the DELETE command may include a WHERE clause. 为了筛选记录,DELETE 命令可以包含 WHERE 子句。 | The TRUNCATE command may not use a WHERE clause. TRUNCATE 命令不能使用 WHERE 子句。 |
| The DELETE statement deletes rows one by one and records each deleted row in the transaction log. DELETE 语句逐行删除行,并在事务日志中记录每个删除的行。 | TRUNCATE TABLE deletes data by relocating the data pages that were used to hold the table data, and only the page deallocations are recorded in the transaction log. TRUNCATE TABLE 通过重新定位用于保存表数据的数据页来删除数据,并且仅在事务日志中记录页释放。 |
| A tuple is locked before being deleted with the DELETE statement. 使用 DELETE 语句删除元组之前,会锁定该元组。 | Before removing the table data, the data page is locked in this command. 在此命令中,删除表数据之前会锁定数据页。 |
| DELETE permission on the table is required to use Delete. 使用 Delete 需要对表具有 DELETE 权限。 | To use Truncate on a table, the table must have at least ALTER permission. 要对表使用 Truncate,该表必须至少具有 ALTER 权限。 |
| The DELETE command is more time consuming than the TRUNCATE command. DELETE 命令比 TRUNCATE 命令更耗时。 | The TRUNCATE command, on the other hand, is faster than the DELETE command. 另一方面,TRUNCATE 命令比 DELETE 命令更快。 |
| With indexed views, the delete command can be used. 对于索引视图,可以使用 delete 命令。 | Truncate isn't compatible with indexed views. Truncate 与索引视图不兼容。 |
| After performing the DELETE Statement on the table, the identity of the column is preserved. 对表执行 DELETE 语句后,列的身份标识会保留。 | If the table contains an identity column, the column's identity is reset to its seed value. 如果表包含标识列,则该列的标识会重置为其种子值。 |
66. Write a query in SQL to find the details of an employee having the nth highest salary from a given table Employee. The value of n needs to be taken as user input. Assume that the table Employee has the following schema.
编写一个 SQL 查询,从给定表 Employee 中查找具有第 n 高薪水的员工的详细信息。n 的值需要作为用户输入。假设表 Employee 具有以下模式。
- 知识点: 数据库 (标签: interviewbit, mindtree, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Mindtree
- id: 69b37bd358d557c902bb4c09 | 官方: 否 | 付费: 否
答案:
name - denoting the name of the employee salary - denoting the salary of the employee
name - 表示员工的姓名 salary - 表示员工的薪水
Approach:
方法:
We use the dense_rank() function to display the details of the employee having the nth highest salary. The function DENSE_RANK returns the rank of a row in an ordered collection of rows as a NUMBER. The ranks are in ascending order, starting with 1. Based on the values of the value exprs in the order by clause, DENSE RANK computes the rank of each row returned from a query in relation to the other rows as an analytic function.
我们使用 dense_rank() 函数来显示具有第 n 高薪水的员工的详细信息。函数 DENSE_RANK 将一行在有序行集合中的排名返回为 NUMBER。排名按升序排列,从 1 开始。根据 order by 子句中 value exprs 的值,DENSE RANK 作为分析函数计算查询返回的每一行相对于其他行的排名。
Query:
查询:
select name, salary from(
select name, salary from(
select name, salary, dense_rank()
select name, salary, dense_rank()
over(order by salary desc)input from Employee)
over(order by salary desc)input from Employee)
where input = &n;
where input = &n;
Explanation:
说明:
In the above query, we first sort the data according to the descending order of the salary and assign a rank to each of the employees starting from 1. In case of an event where the salary of two employees is the same, they both are assigned the same rank. Then we display the data whose rank is equal to the given input.
在上面的查询中,我们首先根据工资的降序对数据进行排序,并为每位员工从1开始分配一个排名。如果两位员工的工资相同,则他们被分配相同的排名。然后我们显示排名等于给定输入的数据。
67. Differentiate between SQL and NoSQL databases.
区分 SQL 和 NoSQL 数据库。
- 知识点: 数据库 (标签: interviewbit, mindtree, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Mindtree
- id: 69b37bd358d557c902bb4c15 | 官方: 否 | 付费: 否
答案:
Following are the differences between SQL and NoSQL databases:
以下是 SQL 和 NoSQL 数据库之间的区别:
| SQL Database SQL 数据库 | NoSQL Database NoSQL 数据库 |
|---|---|
| SQL databases are referred to as Relational Database Management Systems (RDBMS). SQL 数据库被称为关系数据库管理系统(RDBMS)。 | NoSQL databases are referred to as non-relational or distributed databases. NoSQL 数据库被称为非关系型或分布式数据库。 |
| SQL databases have fixed and static predefined schema. SQL 数据库具有固定且静态的预定义模式。 | NoSQL databases can have dynamic schema. NoSQL 数据库可以具有动态模式。 |
| SQL databases are vertically scalable in almost all cases. This means that by boosting RAM, CPU, or SSD, you may increase the demand on a single server. 在几乎所有情况下,SQL 数据库都是垂直可扩展的。这意味着通过提升 RAM、CPU 或 SSD,你可以增加单个服务器的需求。 | NoSQL databases, on the other hand, are horizontally scalable. By sharding, or adding multiple servers to your NoSQL database, you can handle greater traffic. It's the difference between adding more storeys to a single building and adding more buildings to a neighbourhood. NoSQL databases can grow in size and power, making them the best solution for huge or constantly changing data sets. 另一方面,NoSQL 数据库是水平可扩展的。通过分片或向你的 NoSQL 数据库添加多个服务器,你可以处理更大的流量。这就像在单个建筑上增加更多楼层与在社区中添加更多建筑之间的区别。NoSQL 数据库可以在规模和能力上增长,使其成为庞大或不断变化的数据集的最佳解决方案。 |
| SQL databases are table-based. As a result, relational SQL databases are a preferable choice for applications that require multi-row transactions, such as accounting systems, or for legacy systems that were designed with a relational structure in mind. SQL 数据库是基于表的。因此,对于需要多行事务的应用程序(如会计系统)或按照关系结构设计的遗留系统,关系型 SQL 数据库是更可取的选择。 | Key-value pairs, document-based, graph databases, and wide-column stores are all types of NoSQL databases. 键值对、基于文档、图数据库和宽列存储都是 NoSQL 数据库的类型。 |
| The ACID characteristics (Atomicity, Consistency, Isolation, and Durability) are followed by SQL databases. SQL 数据库遵循 ACID 特性(原子性、一致性、隔离性和持久性)。 | The Brewers CAP theorem is followed by NoSQL databases (Consistency, Availability and Partition tolerance). NoSQL 数据库遵循 Brewer 的 CAP 定理(一致性、可用性和分区容错性)。 |
68. What do the words Entity, Entity Type, and Entity Set mean in DBMS?
在 DBMS 中,Entity、Entity Type 和 Entity Set 这些词是什么意思?
- 知识点: 数据库 (标签: interviewbit, mphasis, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Mphasis
- id: 69b37bd658d557c902bb4dbb | 官方: 否 | 付费: 否
答案:
- Entity: An entity is a real-world entity with attributes, which are nothing more than the object's qualities. An employee, for example, is a type of entity. This entity can have characteristics like empid (employee id), empname (employee name), and so on.
- Entity Type: An entity type is a group of objects with similar attributes. An entity type, in general, corresponds to one or maybe more related tables in a database. As a result, entity type can be thought of as a trait that uniquely identifies an entity. Employees can have properties like empid, empname, department, and so on.
- Entity Set: In a database, an entity set is a group of all the objects of a specific entity type. An entity set can include a group of employees, a group of companies, as well as a group of persons, for example.
69. What do you know about Top-N Analysis in SQL?
你对 SQL 中的 Top-N 分析了解多少?
- 知识点: 数据库 (标签: interviewbit, mphasis, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Mphasis
- id: 69b37bd658d557c902bb4dce | 官方: 否 | 付费: 否
答案:
In SQL, Top-N Analysis is used to limit the number of rows returned from ordered collections of data. Top-N queries look for a column's n least or greatest values. Top-N inquiries include both the lowest and largest value sets. Following this method of searching could save you a great deal of effort. Top-N analyses are beneficial when only the n bottom-most or n top-most records from a table must be displayed based on criteria. This set of results could be used for subsequent analysis.
在 SQL 中,Top-N 分析用于限制从有序数据集合返回的行数。Top-N 查询查找某一列的最小或最大的 n 个值。Top-N 查询包括最小和最大的值集。遵循这种搜索方法可以为你节省大量精力。当需要根据条件仅显示表中最低的 n 条或最高的 n 条记录时,Top-N 分析非常有用。这组结果可用于后续分析。
We can, for example, use Top-N analysis to run the following queries: - The top two products with the most sales in the previous two months.
例如,我们可以使用 Top-N 分析来运行以下查询: - 前两个月销售额最高的两个产品。
The top two agents by the number of policies sold.
Performing Top-N Analysis: We can readily grasp the workings of Top-N analysis in SQL by running the following queries:执行 Top-N 分析:通过运行以下查询,我们可以轻松掌握 SQL 中 Top-N 分析的工作原理:
Syntax:
语法:
SELECT [column_list], ROWNUM
SELECT [column_list], ROWNUM
FROM (SELECT [column_list]
FROM (SELECT [column_list]
FROM table_name
FROM table_name
ORDER BY Top-N_clolumn)
ORDER BY Top-N_clolumn)
WHERE ROWNUM<=N;
WHERE ROWNUM<=N;
70. What are some of the most popular SQL clauses used with SELECT queries?
与 SELECT 查询一起使用的一些最流行的 SQL 子句有哪些?
- 知识点: 数据库 (标签: interviewbit, mphasis, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Mphasis
- id: 69b37bd658d557c902bb4de5 | 官方: 否 | 付费: 否
答案:
The following are some examples of SQL clauses that are commonly used in conjunction with a SELECT query: - In SQL, the WHERE clause is used to filter records based on certain requirements.
以下是一些常与 SELECT 查询结合使用的 SQL 子句示例:- 在 SQL 中,WHERE 子句用于根据特定条件筛选记录。
- The ORDER BY clause in SQL is used to sort entries in ascending (ASC) or descending (DESC) order based on specified field(s).
- The SQL GROUP BY clause is used to aggregate records with similar data and can be combined with some aggregation methods to provide summarised database results.
In SQL, the HAVING clause is used in conjunction with the GROUP BY clause to filter records. It differs from the WHERE clause in that aggregated records cannot be filtered using the WHERE clause.
Mphasis Interview Preparation
71. What is Database Trigger?
什么是数据库触发器?
- 知识点: 数据库 (标签: interviewbit, nagarro, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Nagarro
- id: 69b37bf958d557c902bb617f | 官方: 否 | 付费: 否
答案:
A database trigger is a SQL statement that is run when you insert, update, or delete a row in your database. It allows you to execute code before or after the data is inserted into your database. This can be useful if you want to check for certain conditions before inserting data into your database, such as making sure the value of one field does not already exist. It also has other uses, such as checking if a user is logged in before allowing them to modify a record or deleting an existing record. A database trigger can be written in any programming language, although some languages are better suited than others. There are two types of triggers: Stored and User-Defined. - Stored triggers execute the code when a row is inserted (INSERT), updated (UPDATE), or deleted (DELETE).
数据库触发器是一种 SQL 语句,当您在数据库中插入、更新或删除一行时运行。它允许您在将数据插入数据库之前或之后执行代码。如果您想在将数据插入数据库之前检查某些条件,例如确保某个字段的值尚不存在,这会很有用。它还有其他用途,例如在允许用户修改或删除现有记录之前检查用户是否已登录。数据库触发器可以用任何编程语言编写,尽管有些语言比其他语言更合适。触发器有两种类型:存储触发器和用户定义触发器。- 存储触发器在插入(INSERT)、更新(UPDATE)或删除(DELETE)一行时执行代码。
- User-defined triggers can have custom logic built on top of them using VALUES.
72. What is the job of ALTER DATABASE command?
ALTER DATABASE 命令的作用是什么?
- 知识点: 数据库 (标签: interviewbit, ntt-data, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: NTT DATA
- id: 69b37bff58d557c902bb6663 | 官方: 否 | 付费: 否
答案:
The ALTER DATABASE command is a SQL command used to modify the properties or characteristics of a database in a relational database management system (RDBMS). Some examples of modifications that can be made using the ALTER DATABASE command include:
ALTER DATABASE 命令是一种 SQL 命令,用于修改关系数据库管理系统(RDBMS)中数据库的属性或特征。使用 ALTER DATABASE 命令可以进行的修改示例如下:
Changing the name of the database. 2. Modifying the default file locations for the database's data and log files. 3. Changing the compatibility level of the database. 4. Adding or removing filegroups from the database. 5. Setting the default language for the database. 6. Enabling or disabling features such as full-text search or change data capture.
- 更改数据库的名称。 2. 修改数据库数据和日志文件的默认文件位置。 3. 更改数据库的兼容性级别。 4. 向数据库添加或从中删除文件组。 5. 设置数据库的默认语言。 6. 启用或禁用全文搜索或变更数据捕获等功能。
Here is an example of how the ALTER DATABASE command could be used to change the default file location for a database's data files in SQL Server:
以下是一个示例,说明如何在 SQL Server 中使用 ALTER DATABASE 命令更改数据库数据文件的默认文件位置:
ALTER DATABASE MyDatabase
ALTER DATABASE MyDatabase
MODIFY FILE (NAME = MyDatabase_Data, FILENAME = 'C:\MyDatabase\MyDatabase_Data.mdf');
MODIFY FILE (NAME = MyDatabase_Data, FILENAME = 'C:\MyDatabase\MyDatabase_Data.mdf');
This command will change the default file location for the data files of the database "MyDatabase" to the specified location on the C drive.
此命令会将数据库“MyDatabase”的数据文件的默认文件位置更改为 C 盘上的指定位置。
73. What is SQL?
什么是 SQL?
- 知识点: 数据库 (标签: interviewbit, ntt-data, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: NTT DATA
- id: 69b37c0058d557c902bb6679 | 官方: 否 | 付费: 否
答案:
SQL (Structured Query Language) is a programming language used to manage data stored in relational database management systems (RDBMS). It is used to create, modify, and query databases, as well as to manage the data stored in them.
SQL(结构化查询语言)是一种编程语言,用于管理存储在关系数据库管理系统(RDBMS)中的数据。它用于创建、修改和查询数据库,以及管理其中存储的数据。
Some common tasks that can be performed using SQL include:
使用 SQL 可以执行的一些常见任务包括:
Creating and modifying tables: SQL can be used to create new tables in a database, as well as to modify the structure of existing tables. 2. Inserting, updating, and deleting data: SQL can be used to add new rows of data to a table, update existing data in a table, or delete rows of data from a table. 3. Querying data: SQL can be used to retrieve specific data from a database, based on various criteria. 4. Joining tables: SQL can be used to combine data from multiple tables in a database, based on shared columns or keys.
- 创建和修改表:SQL 可用于在数据库中创建新表,以及修改现有表的结构。 2. 插入、更新和删除数据:SQL 可用于向表中添加新数据行、更新表中的现有数据或从表中删除数据行。 3. 查询数据:SQL 可用于根据各种条件从数据库中检索特定数据。 4. 联接表:SQL 可用于根据共享列或键合并数据库中多个表的数据。
SQL is a standard language that is supported by most RDBMS, such as MySQL, Oracle, and Microsoft SQL Server. It is a powerful tool for managing and querying data, and is widely used in web development, data analysis, and many other fields.
SQL 是一种标准语言,大多数 RDBMS(如 MySQL、Oracle 和 Microsoft SQL Server)都支持它。它是管理和查询数据的强大工具,广泛应用于 Web 开发、数据分析以及许多其他领域。
74. What is an Oracle data integrator?
什么是 Oracle 数据集成器?
- 知识点: 数据库 (标签: interviewbit, ntt-data, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: NTT DATA
- id: 69b37c0058d557c902bb667c | 官方: 否 | 付费: 否
答案:
Oracle Data Integrator (ODI) is a data integration and ETL (extract, transform, load) tool developed by Oracle. It is designed to help organizations extract data from various sources, transform it into a desired format, and load it into a target database or system.
Oracle Data Integrator (ODI) 是 Oracle 开发的一款数据集成和 ETL(提取、转换、加载)工具。它旨在帮助组织从各种来源提取数据,将其转换为所需格式,并加载到目标数据库或系统中。
ODI is a graphical design tool that allows developers to build data integration workflows using a visual interface. It includes a number of pre-built connectors and transformations that can be used to extract data from various sources, including relational databases, flat files, and web services. It also includes a runtime engine that can execute the data integration workflows and load the data into the target systems.
ODI 是一款图形化设计工具,允许开发者使用可视化界面构建数据集成工作流。它包含许多预构建的连接器和转换,可用于从各种来源(包括关系数据库、平面文件和 Web 服务)提取数据。它还包含一个运行时引擎,可以执行数据集成工作流并将数据加载到目标系统中。
Some key features of Oracle Data Integrator include:
Oracle Data Integrator 的一些关键特性包括:
Data integration: ODI can extract data from various sources, transform it, and load it into the target systems. 2. Data quality: ODI includes a range of data quality transformations that can be used to clean and validate data before it is loaded into the target systems. 3. Scalability: ODI can handle large volumes of data and can be scaled to meet the needs of enterprise-level data integration projects. 4. Reusability: ODI allows developers to create reusable objects, such as mappings and transformations, which can be used in multiple data integration workflows.
- 数据集成:ODI 可以从各种来源提取数据,对其进行转换,并将其加载到目标系统中。 2. 数据质量:ODI 包含一系列数据质量转换,可用于在将数据加载到目标系统之前清理和验证数据。 3. 可扩展性:ODI 可以处理大量数据,并可以扩展以满足企业级数据集成项目的需求。 4. 可重用性:ODI 允许开发者创建可重用对象,例如映射和转换,这些对象可用于多个数据集成工作流。
ODI is often used to support data warehousing, master data management, and other data integration projects in organizations.
ODI 通常用于支持组织中的数据仓库、主数据管理和其他数据集成项目。
75. What are the benefits of a DataBase Management System?
数据库管理系统有哪些优势?
- 知识点: 数据库 (标签: interviewbit, ntt-data, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: NTT DATA
- id: 69b37c0058d557c902bb6681 | 官方: 否 | 付费: 否
答案:
A database management system (DBMS) is a software application that is used to create, manage, and manipulate databases. A database is a collection of data that is organized in a specific way, and a DBMS is used to access and manipulate that data.
数据库管理系统 (DBMS) 是一种用于创建、管理和操作数据库的软件应用程序。数据库是以特定方式组织的数据集合,而 DBMS 用于访问和操作这些数据。
There are several benefits to using a DBMS, including:
使用 DBMS 有若干优势,包括:
Data organization: A DBMS helps to organize data in a structured and efficient way, making it easier to access and retrieve data when needed. 2. Data security: A DBMS provides various security features, such as user authentication and data encryption, to protect data from unauthorized access. 3. Data integrity: A DBMS ensures that data is stored and accessed correctly, and it prevents data inconsistencies and corruption. 4. Data consistency: A DBMS ensures that data is consistent across the entire database, and it prevents data inconsistencies caused by multiple users accessing the same data simultaneously. 5. Data independence: A DBMS allows users to access data without having to know the underlying physical structure of the data, which makes it easier to modify the physical structure without affecting the way users access the data. 6. Data scalability: A DBMS can handle large volumes of data and can be scaled to meet the needs of an organization as it grows.
- 数据组织:DBMS 有助于以结构化和高效的方式组织数据,使在需要时访问和检索数据更加容易。 2. 数据安全:DBMS 提供各种安全功能,例如用户身份验证和数据加密,以保护数据免遭未经授权的访问。 3. 数据完整性:DBMS 确保数据被正确存储和访问,并防止数据不一致和损坏。 4. 数据一致性:DBMS 确保数据在整个数据库中保持一致,并防止多个用户同时访问相同数据所导致的数据不一致。 5. 数据独立性:DBMS 允许用户访问数据而无需了解数据的底层物理结构,这使得修改物理结构更加容易,而不会影响用户访问数据的方式。 6. 数据可扩展性:DBMS 可以处理大量数据,并可以随着组织的发展进行扩展以满足其需求。
76. What is a Relational DataBase Management System (RDBMS)?
什么是关系数据库管理系统 (RDBMS)?
- 知识点: 数据库 (标签: interviewbit, ntt-data, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: NTT DATA
- id: 69b37c0058d557c902bb6684 | 官方: 否 | 付费: 否
答案:
A relational database management system (RDBMS) is a type of DBMS (database management system) that is based on the relational model of data. In a relational database, data is organized into tables (also known as relations) and is accessed using a standard language called SQL (Structured Query Language).
关系数据库管理系统 (RDBMS) 是一种基于关系数据模型的 DBMS(数据库管理系统)。在关系数据库中,数据被组织成表(也称为关系),并使用一种称为 SQL(结构化查询语言)的标准语言进行访问。
In an RDBMS, data is stored in tables that consist of rows and columns. Each row represents a record (also known as a tuple), and each column represents an attribute of that record. For example, consider the following table:
在 RDBMS 中,数据存储在由行和列组成的表中。每一行代表一条记录(也称为元组),每一列代表该记录的一个属性。例如,考虑以下表:
| ID | FirstName | LastName | Age |
|---|---|---|---|
| 1 | John | Smith | 25 |
| 2 | Jane | Doe | 30 |
| 3 | Bob | Johnson | 35 |
| ID | FirstName | LastName | Age |
|---|---|---|---|
| 1 | John | Smith | 25 |
| 2 | Jane | Doe | 30 |
| 3 | Bob | Johnson | 35 |
In this table, "ID" is an attribute that uniquely identifies each record, "FirstName" and "LastName" are attributes that store the first and last names of each person, and "Age" is an attribute that stores the age of each person.
在这个表中,“ID”是唯一标识每条记录的属性,“FirstName”和“LastName”是存储每个人名字和姓氏的属性,而“Age”是存储每个人年龄的属性。
RDBMS are widely used to store and manage data in many types of organizations and are popular because they provide a number of benefits, such as:
RDBMS 广泛用于在许多类型的组织中存储和管理数据,并且因其提供了许多优势而受欢迎,例如:
Data integrity: RDBMSs ensure that data is stored and accessed correctly, and they prevent data inconsistencies and corruption. 2. Data security: RDBMSs provide various security features, such as user authentication and data encryption, to protect data from unauthorized access. 3. Data scalability: RDBMSs can handle large volumes of data and can be scaled to meet the needs of an organization as it grows. 4. Data independence: RDBMSs allow users to access data without having to know the underlying physical structure of the data, which makes it easier to modify the physical structure without affecting the way users access the data.
- 数据完整性:RDBMS 确保数据被正确存储和访问,并防止数据不一致和损坏。 2. 数据安全性:RDBMS 提供各种安全功能,如用户认证和数据加密,以保护数据免受未经授权的访问。 3. 数据可扩展性:RDBMS 可以处理大量数据,并且可以扩展以满足组织增长的需求。 4. 数据独立性:RDBMS 允许用户访问数据,而无需了解数据的底层物理结构,这使得修改物理结构更容易,而不会影响用户访问数据的方式。
77. What are functions and their usage in SQL?
SQL 中的函数及其用法是什么?
- 知识点: 数据库 (标签: interviewbit, paypal, company-specific)
- 类型: technical | 难度: easy | 子类型: coding
- 分类: general
- 公司: PayPal
- id: 69b37c0f58d557c902bb6f59 | 官方: 否 | 付费: 否
答案:
SQL functions are short bits of code that are commonly used and reused in database systems to process and manipulate data. The measured values are the functions. It always accomplishes a certain goal. When constructing functions, keep the following rules in mind:
SQL 函数是常用于数据库系统中处理和操作数据的简短代码片段,可重复使用。这些测量值就是函数。它总是实现某个特定目标。在构建函数时,请牢记以下规则:
- A function must be given a name, which cannot begin with a special character such as @, $, #, or other characters.
- Only SELECT statements can be used by functions.
- It compiles every time a function is called.
- Functions are required to return a value or a result.
- Input parameters are always utilised with functions.
78. What do you mean by autocommit mode in SQL Server?
SQL Server 中的自动提交模式是什么意思?
- 知识点: 数据库 (标签: interviewbit, paypay, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: PayPay
- id: 69b37c1158d557c902bb701a | 官方: 否 | 付费: 否
答案:
If you enable auto-commit mode, this means that once you have finished your statement, the method commit will be automatically called on the statement. The SQL Server Database Engine uses it as its default transaction management mode. By setting implicit_transactions ON, you can disable auto-commit. In SQL Server, you can disable auto-commit by running the following T-SQL command.
如果启用自动提交模式,这意味着一旦你完成语句,提交方法将自动在语句上调用。SQL Server 数据库引擎将其用作默认事务管理模式。通过设置 implicit_transactions ON,你可以禁用自动提交。在 SQL Server 中,你可以通过运行以下 T-SQL 命令来禁用自动提交。
SET IMPLICIT_TRANSACTIONS ON
SET IMPLICIT_TRANSACTIONS ON
When you use implicit transactions, every change you make starts a transaction that must be manually committed. If you want to enable it, simply run the OFF clause in the above command. You may enable auto-commit with the following command.
当你使用隐式事务时,你所做的每个更改都会启动一个必须手动提交的事务。如果你想启用它,只需运行上述命令中的 OFF 子句。你可以使用以下命令启用自动提交。
SET IMPLICIT_TRANSACTIONS OFF
SET IMPLICIT_TRANSACTIONS OFF
79. What is a rollback transaction?
什么是回滚事务?
- 知识点: 数据库 (标签: interviewbit, paypay, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: PayPay
- id: 69b37c1158d557c902bb702b | 官方: 否 | 付费: 否
答案:
In SQL, a rollback can be defined as the process of restoring a database to its previous state if there has been an error during the execution of a transaction. A rollback can either be performed automatically by a database system or manually by an end-user. The rollback function brings a transaction back to the beginning or undo any changes since the last COMMIT. Additionally, it releases resources used by the transaction.
在 SQL 中,回滚可以定义为在事务执行过程中出现错误时,将数据库恢复到先前状态的过程。回滚可以由数据库系统自动执行,也可以由最终用户手动执行。回滚功能将事务带回起点或撤销自上次 COMMIT 以来的任何更改。此外,它还释放事务使用的资源。
Example: Consider the following ScalerEmp table.
示例:考虑以下 ScalerEmp 表。
| Emp_ID | Name | Date of Joining | Position | Age |
|---|---|---|---|---|
| 101 | Ankit Verma | 1 July 2022 | Program Manager | 29 |
| 102 | Ashutosh Mukherji | 5 Jan 2021 | SEO Manager | 25 |
| 103 | Sonal Dange | 23 March 2020 | Content Writer | 26 |
| 104 | Isha Joshi | 1 July 2022 | Data Analyst | 27 |
| 105 | Kunal Swami | 10 October 2021 | Business Development Executive | 29 |
| Emp_ID | Name | Date of Joining | Position | Age |
|---|---|---|---|---|
| 101 | Ankit Verma | 1 July 2022 | Program Manager | 29 |
| 102 | Ashutosh Mukherji | 5 Jan 2021 | SEO Manager | 25 |
| 103 | Sonal Dange | 23 March 2020 | Content Writer | 26 |
| 104 | Isha Joshi | 1 July 2022 | Data Analyst | 27 |
| 105 | Kunal Swami | 10 October 2021 | Business Development Executive | 29 |
Perform the following SQL query:
执行以下 SQL 查询:
DELETE from ScalerEmp Where Age = 29;
DELETE from ScalerEmp Where Age = 29;
ROLLBACK;
ROLLBACK;
Output:
输出:
| Emp_ID | Name | Date of Joining | Position | Age |
|---|---|---|---|---|
| 102 | Ashutosh Mukherji | 5 Jan 2021 | SEO Manager | 25 |
| 103 | Sonal Dange | 23 March 2020 | Content Writer | 26 |
| 104 | Isha Joshi | 1 july 2022 | Data Analyst | 27 |
| Emp_ID | Name | Date of Joining | Position | Age |
|---|---|---|---|---|
| 102 | Ashutosh Mukherji | 5 Jan 2021 | SEO Manager | 25 |
| 103 | Sonal Dange | 23 March 2020 | Content Writer | 26 |
| 104 | Isha Joshi | 1 july 2022 | Data Analyst | 27 |
In the above table, we can see that two employee records with the age of 29 that satisfy the age criteria have been removed from the ScalerEmp table. Lastly, we executed a ROLLBACK query to undo the changes.
在上表中,我们可以看到 ScalerEmp 表中符合年龄条件的两位年龄为 29 的员工记录已被移除。最后,我们执行了一个 ROLLBACK 查询以撤销更改。
Now, use the select command to display records from the ScalerEmp table.
现在,使用 select 命令显示 ScalerEmp 表中的记录。
Select * from ScalerEmp;
Select * from ScalerEmp;
Output:
输出:
| Emp_ID | Name | Date of Joining | Position | Age |
|---|---|---|---|---|
| 101 | Ankit Verma | 1 July 2022 | Program Manager | 29 |
| 102 | Ashutosh Mukherji | 5 Jan 2021 | SEO Manager | 25 |
| 103 | Sonal Dange | 23 March 2020 | Content Writer | 26 |
| 104 | Isha Joshi | 1 July 2022 | Data Analyst | 27 |
| 105 | Kunal Swami | 10 October 2021 | Business Development Executive | 29 |
| Emp_ID | Name | Date of Joining | Position | Age |
|---|---|---|---|---|
| 101 | Ankit Verma | 1 July 2022 | Program Manager | 29 |
| 102 | Ashutosh Mukherji | 5 Jan 2021 | SEO Manager | 25 |
| 103 | Sonal Dange | 23 March 2020 | Content Writer | 26 |
| 104 | Isha Joshi | 1 July 2022 | Data Analyst | 27 |
| 105 | Kunal Swami | 10 October 2021 | Business Development Executive | 29 |
As we can see from the above table, the Rollback statement restored the ScalerEmp table to its previous state.
从上表中我们可以看到,Rollback 语句将 ScalerEmp 表恢复到了之前的状态。
80. Write SQL query to find an employee with the second highest salary.
编写 SQL 查询以找出薪水第二高的员工。
- 知识点: 数据库 (标签: interviewbit, persistent, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Persistent Systems
- id: 69b37c1858d557c902bb7426 | 官方: 否 | 付费: 否
答案:
Consider the following table “Employee”:
考虑以下表“Employee”:
| Name | Position | Salary |
|---|---|---|
| Gourav | SDE 2 | 1,00,000 |
| Sonal | Data Analyst | 1,50,000 |
| Kunal | Content Specialist | 80,000 |
| Farhan | Team Lead | 2,00,000 |
| Ashutosh | Product Lead | 1,70,000 |
| Name | Position | Salary |
|---|---|---|
| Gourav | SDE 2 | 1,00,000 |
| Sonal | Data Analyst | 1,50,000 |
| Kunal | Content Specialist | 80,000 |
| Farhan | Team Lead | 2,00,000 |
| Ashutosh | Product Lead | 1,70,000 |
To find the second-highest-paid employee, simply run the SQL query below:
要找出薪水第二高的员工,只需运行下面的 SQL 查询:
SELECT MAX(Salary) FROM Employee WHERE Salary < (SELECT MAX(Salary) FROM Employee);
SELECT MAX(Salary) FROM Employee WHERE Salary < (SELECT MAX(Salary) FROM Employee);
Or
或者
SELECT Name, MAX(Salary) as Salary from Employee where Salary <(SELECT MAX(Salary) FROM Employee);
SELECT Name, MAX(Salary) as Salary from Employee where Salary <(SELECT MAX(Salary) FROM Employee);
81. What does aggregation mean in relation to databases?
在数据库方面,聚合是什么意思?
- 知识点: 数据库 (标签: interviewbit, persistent, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Persistent Systems
- id: 69b37c1858d557c902bb7429 | 官方: 否 | 付费: 否
答案:
The aggregate function in database management is a function that takes the values of multiple rows and combines them into a single valuable entity. Since the values do not make sense separately, they are combined. Aggregation establishes a relationship which combines these values from different rows to create a single entity. Some common aggregate functions include Count, Average (i.e., arithmetic mean), Median, Minimum, Maximum, Mode, Sum, and Range.
数据库管理中的聚合函数是一种将多行的值组合成一个有价值实体的函数。由于这些值单独没有意义,因此将它们组合起来。聚合建立了一种关系,将来自不同行的这些值组合起来创建单个实体。一些常见的聚合函数包括计数、平均值(即算术平均值)、中位数、最小值、最大值、众数、求和和范围。
82. Describe the ACID properties of a database.
描述数据库的ACID属性。
- 知识点: 数据库 (标签: interviewbit, persistent, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Persistent Systems
- id: 69b37c1858d557c902bb742c | 官方: 否 | 付费: 否
答案:
A transaction is a sequence of operations performed as one unit of work, and it can include one or more steps. Transactions make use of the read and write operations to access data. A database must follow certain properties and guidelines before and after each transaction to maintain consistency. Such properties are known as ACID properties. ACID stands for Atomicity, Consistency, Isolation and Durability, which are properties of a transaction in a database system.
事务是作为单个工作单元执行的一系列操作,它可以包含一个或多个步骤。事务利用读和写操作来访问数据。数据库必须在每个事务前后遵循某些属性和准则以保持一致性。这些属性被称为ACID属性。ACID代表原子性、一致性、隔离性和持久性,它们是数据库系统中事务的属性。
ACID properties are designed to maintain the integrity of the data, ensuring that the data does not become corrupted by some failure, guaranteeing validity even in the presence of errors or failures. Therefore, all transactions in a database must adhere to ACID properties.
ACID属性旨在维护数据的完整性,确保数据不会因某些故障而损坏,即使在出现错误或故障时也能保证有效性。因此,数据库中的所有事务都必须遵守ACID属性。
83. How do you create a table in MySQL?
如何在MySQL中创建表?
- 知识点: 数据库 (标签: interviewbit, publicis-sapient, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Publicis Sapient
- id: 69b37c2058d557c902bb7a38 | 官方: 否 | 付费: 否
答案:
To create a table in MySQL, you can use the CREATE TABLE statement. Here is the syntax for creating a table in MySQL:
要在MySQL中创建表,可以使用CREATE TABLE语句。以下是在MySQL中创建表的语法:
CREATE TABLE table_name (
CREATE TABLE table_name (
column_name1 data_type(size),
column_name1 data_type(size),
column_name2 data_type(size),
column_name2 data_type(size),
...
);
Replace "table_name" with the name you want to give to your table, and "column_name" and "data_type" with the names and data types of the columns you want to include in your table. The size parameter is optional and specifies the size or precision of the column.
将“table_name”替换为您想为表指定的名称,将“column_name”和“data_type”替换为您想包含在表中的列的名称和数据类型。size参数是可选的,用于指定列的大小或精度。
Here is an example of how you might create a table in MySQL:
以下是一个如何在MySQL中创建表的示例:
CREATE TABLE customers (
CREATE TABLE customers (
customer_id INT(11) NOT NULL AUTO_INCREMENT,
customer_id INT(11) NOT NULL AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
PRIMARY KEY (customer_id)
PRIMARY KEY (customer_id)
);
This MySQL statement will create a table with the name "customers", and will include three columns: "customer_id", "name", and "email". The "customer_id" column is an integer data type with a size of 11, and is set as the primary key for the table. The "name" and "email" columns are both variable character data types with a size of 255.
这个 MySQL 语句将创建一个名为“customers”的表,并包含三个列:“customer\_id”、“name”和“email”。“customer\_id”列是大小为 11 的整数数据类型,并被设置为该表的主键。“name”和“email”列都是大小为 255 的可变字符数据类型。
84. Can you explain the difference between a UNION and a UNION ALL in SQL?
你能解释一下 SQL 中 UNION 和 UNION ALL 的区别吗?
- 知识点: 数据库 (标签: interviewbit, publicis-sapient, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Publicis Sapient
- id: 69b37c2058d557c902bb7a3b | 官方: 否 | 付费: 否
答案:
In SQL, the UNION and UNION ALL clauses are used to combine the results of two or more SELECT statements into a single result set. However, they are used in slightly different ways and serve different purposes.
在 SQL 中,UNION 和 UNION ALL 子句用于将两个或多个 SELECT 语句的结果合并为一个结果集。然而,它们的使用方式略有不同,且服务于不同的目的。
The UNION clause is used to combine the results of two or more SELECT statements, but only includes unique rows in the final result set. This means that if a row appears in more than one SELECT statement and is included in the final result set, it will only be included once.
UNION 子句用于合并两个或多个 SELECT 语句的结果,但最终结果集中只包含唯一的行。这意味着,如果某一行出现在多个 SELECT 语句中并被包含在最终结果集中,它只会被包含一次。
Here is an example of how you might use a UNION clause in SQL:
以下是一个你可能如何在 SQL 中使用 UNION 子句的示例:
SELECT * FROM table1
SELECT * FROM table1
UNION
UNION
SELECT * FROM table2;
SELECT * FROM table2;
This SQL statement will return all rows from both the "table1" and "table2" tables, but will only include unique rows in the final result set.
这个 SQL 语句将返回“table1”和“table2”表中的所有行,但最终结果集中只包含唯一的行。
The UNION ALL clause is similar to the UNION clause, but includes all rows in the final result set, regardless of whether they are duplicates or not.
UNION ALL 子句与 UNION 子句类似,但会在最终结果集中包含所有行,无论它们是否重复。
Here is an example of how you might use a UNION ALL clause in SQL:
以下是一个你可能如何在 SQL 中使用 UNION ALL 子句的示例:
SELECT * FROM table1
SELECT * FROM table1
UNION ALL
UNION ALL
SELECT * FROM table2;
SELECT * FROM table2;
This SQL statement will return all rows from both the "table1" and "table2" tables, including any duplicates.
这个 SQL 语句将返回“table1”和“table2”表中的所有行,包括任何重复项。
The UNION and UNION ALL clauses are useful tools for combining the results of multiple SELECT statements in SQL, but are used in slightly different ways and serve different purposes. Understanding the differences between these two clauses can help you use them effectively in your SQL queries.
UNION 和 UNION ALL 子句是在 SQL 中合并多个 SELECT 语句结果的有用工具,但它们的使用方式略有不同,且服务于不同的目的。理解这两个子句之间的差异可以帮助你在 SQL 查询中有效地使用它们。
85. Can you explain the difference between a primary and a foreign key in a database?
你能解释一下数据库中主键和外键的区别吗?
- 知识点: 数据库 (标签: interviewbit, publicis-sapient, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Publicis Sapient
- id: 69b37c2058d557c902bb7a3e | 官方: 否 | 付费: 否
答案:
In a database, a primary key is a field or set of fields that uniquely identifies each row in a table. A foreign key is a field or set of fields in one table that refers to the primary key of another table.
在数据库中,主键是唯一标识表中每一行的字段或字段集。外键是一个表中引用另一个表的主键的字段或字段集。
Here is an example of how primary and foreign keys can be used in a database:
以下是一个在数据库中使用主键和外键的示例:
Consider a database with two tables: a "customers" table and an "orders" table. The "customers" table might contain fields for the customer's ID, name, address, and phone number, while the "orders" table might contain fields for the order ID, customer ID, product ID, and quantity.
考虑一个包含两个表的数据库:一个“customers”表和一个“orders”表。“customers”表可能包含客户ID、姓名、地址和电话号码等字段,而“orders”表可能包含订单ID、客户ID、产品ID和数量等字段。
In this example, the customer ID field in the "customers" table could be used as the primary key, since it uniquely identifies each customer. The customer ID field in the "orders" table could then be used as a foreign key, since it refers to the primary key (customer ID) in the "customers" table.
在这个例子中,“customers”表中的客户ID字段可以用作主键,因为它唯一标识每个客户。“orders”表中的客户ID字段则可以用作外键,因为它引用了“customers”表中的主键(客户ID)。
By using primary and foreign keys in this way, the database can establish relationships between the two tables and ensure that the data is consistent and accurate. For example, if a customer's name or address changes in the "customers" table, that change will be automatically reflected in the "orders" table, since the "orders" table uses the customer ID as a foreign key to refer to the "customers" table.
通过以这种方式使用主键和外键,数据库可以在两个表之间建立关系,并确保数据的一致性和准确性。例如,如果“customers”表中客户的姓名或地址发生变化,该变化将自动反映在“orders”表中,因为“orders”表使用客户ID作为外键来引用“customers”表。
Overall, primary and foreign keys are important concepts in database design, and are used to establish relationships between tables and ensure the integrity and accuracy of the data in the database.
总的来说,主键和外键是数据库设计中的重要概念,用于在表之间建立关系,并确保数据库中数据的完整性和准确性。
Here is a comparison of primary and foreign keys in tabular form:
以下是以表格形式对主键和外键的比较:
| Property 属性 | Primary Key 主键 | Foreign Key 外键 |
|---|---|---|
| Definition 定义 | A field or set of fields that uniquely identifies each row in a table 唯一标识表中每一行的字段或字段集 | A field or set of fields in one table that refers to the primary key of another table 一个表中引用另一个表的主键的字段或字段集 |
| Role in database 在数据库中的作用 | Establishes a unique identifier for each row in a table 为表中的每一行建立唯一标识符 | Establishes a relationship between two tables by linking rows in one table to the primary key of another table 通过将一个表中的行链接到另一个表的主键,在两个表之间建立关系 |
| Example 示例 | Customer ID, order ID 客户ID、订单ID | Customer ID in orders table (refers to the primary key in customers table) orders表中的客户ID(引用customers表中的主键) |
| - Definition: A primary key is a field or set of fields that uniquely identifies each row in a table, while a foreign key is a field or set of fields in one table that refers to the primary key of another table. - 定义:主键是唯一标识表中每一行的字段或字段集,而外键是一个表中引用另一个表的主键的字段或字段集。 |
- Role in database: Primary keys play a crucial role in establishing a unique identifier for each row in a table, while foreign keys are used to establish relationships between tables and link rows in one table to the primary key of another table.
Example: In the example provided earlier, the customer ID field in the "customers" table could be used as the primary key, while the customer ID field in the "orders" table could be used as a foreign key to refer to the primary key in the "customers" table.
primary and foreign keys are important concepts in database design and are used to establish relationships between tables and ensure the integrity and accuracy of the data in the database. Understanding the differences between these two types of keys can help you design and use databases more effectively.主键和外键是数据库设计中的重要概念,用于在表之间建立关系,并确保数据库中数据的完整性和准确性。理解这两种键之间的区别可以帮助你更有效地设计和使用数据库。
86. What is a database, and why is it important?
什么是数据库,为什么它很重要?
- 知识点: 数据库 (标签: interviewbit, publicis-sapient, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Publicis Sapient
- id: 69b37c2058d557c902bb7a41 | 官方: 否 | 付费: 否
答案:
A database is a collection of data that is organized and stored in a structured way so that it can be accessed and manipulated efficiently. Databases are used to store and manage large amounts of data and are an important tool in a variety of settings, including business, government, and education.
数据库是以结构化方式组织和存储的数据集合,以便能够高效地访问和操作。数据库用于存储和管理大量数据,是各种环境中的重要工具,包括商业、政府和教育领域。
There are several types of databases, including relational databases, which store data in tables with rows and columns, and object-oriented databases, which store data in the form of objects. While object-oriented databases do support the storage of complex data types and objects, they are not limited to just that data model. Object-oriented databases can also support other data models such as key-value or document-oriented databases.
数据库有多种类型,包括将数据存储在具有行和列的表格中的关系型数据库,以及以对象形式存储数据的面向对象数据库。虽然面向对象数据库确实支持复杂数据类型和对象的存储,但它们并不仅限于该数据模型。面向对象数据库还可以支持其他数据模型,例如键值或面向文档的数据库。
In fact, many modern databases are designed to support multiple data models to provide greater flexibility and meet the needs of different applications. For example, some databases may support both relational and document-oriented data models, allowing developers to choose the model that best fits their data and application requirements.
事实上,许多现代数据库被设计为支持多种数据模型,以提供更大的灵活性并满足不同应用程序的需求。例如,一些数据库可能同时支持关系型和面向文档的数据模型,允许开发人员选择最适合其数据和应用程序需求的模型。
Therefore, it is important to note that while object-oriented databases can store data in the form of objects, they are not limited to just that model, and can support a variety of different data models depending on the specific requirements of the application.
因此,需要注意的是,虽然面向对象数据库可以以对象的形式存储数据,但它们并不仅限于该模型,并且可以根据应用程序的具体需求支持多种不同的数据模型。
Some databases are designed to support specific applications, such as financial systems or inventory management, while others are more general-purpose and can be used for a wide range of applications.
一些数据库被设计为支持特定应用程序,例如金融系统或库存管理,而另一些则更为通用,可用于广泛的应用程序。
In addition to databases designed for specific applications such as financial systems or inventory management, there are several other types of specialized databases designed for specific types of data and applications. Here are some examples: - Time-series databases: These databases are designed for storing and analyzing time-series data, which is data that is collected over time at regular intervals. Examples of time-series data include stock prices, weather data, and website traffic. Time-series databases are optimized for handling large volumes of time-stamped data and for performing time-based queries and analyses.
除了为特定应用(如金融系统或库存管理)设计的数据库之外,还有几种其他类型的专用数据库,专为特定类型的数据和应用而设计。以下是一些示例:- 时间序列数据库:这些数据库专为存储和分析时间序列数据而设计,时间序列数据是按固定时间间隔随时间收集的数据。时间序列数据的示例包括股票价格、天气数据和网站流量。时间序列数据库针对处理大量带有时间戳的数据以及执行基于时间的查询和分析进行了优化。
- Graph databases: Graph databases are designed for storing and querying data that has a graph-like structure, such as social networks, recommendation engines, and knowledge graphs. Graph databases use graph theory to represent and query data, making it easy to navigate complex relationships between entities.
Spatial databases: Spatial databases are designed for storing and querying geospatial data, such as maps, satellite imagery, and location data. Spatial databases use specialized algorithms and data structures to optimize queries that involve spatial data.
Other examples of specialized databases include document databases, which are designed for storing and querying semi-structured and unstructured data such as emails, PDFs, and JSON documents; and columnar databases, which are designed for storing and querying large amounts of structured data such as log files and transaction data.专用数据库的其他示例包括文档数据库,其专为存储和查询半结构化和非结构化数据(如电子邮件、PDF 和 JSON 文档)而设计;以及列式数据库,其专为存储和查询大量结构化数据(如日志文件和事务数据)而设计。
One of the main reasons that databases are important is that they allow for the efficient storage and management of large amounts of data. By organizing data in a structured way, databases make it easy to retrieve, update, and manipulate data as needed. This is especially important for organizations that need to manage large amounts of data, such as customer records, sales data, or inventory information.
数据库之所以重要的主要原因之一是,它们能够高效地存储和管理大量数据。通过以结构化方式组织数据,数据库使得根据需要检索、更新和操作数据变得容易。这对于需要管理大量数据(如客户记录、销售数据或库存信息)的组织尤为重要。
Another reason that databases are important is that they provide a way to ensure the integrity and security of data. Databases can be designed with security measures in place to prevent unauthorized access to data, and can also include features to help ensure that data is accurate and consistent.
数据库之所以重要的另一个原因是,它们提供了一种确保数据完整性和安全性的方式。数据库可以设计有安全措施以防止未经授权访问数据,并且还可以包含有助于确保数据准确和一致的功能。
Databases are an essential tool for storing, managing and accessing large amounts of data in a structured and efficient way. They play a critical role in a wide range of settings and are an important component of many modern computing systems.
数据库是以结构化且高效的方式存储、管理和访问大量数据的重要工具。它们在广泛的场景中发挥着关键作用,并且是许多现代计算系统的重要组成部分。
87. SQL Query to find min, max and average salary from a table?
用于从表中查找最低、最高和平均工资的 SQL 查询?
- 知识点: 数据库 (标签: interviewbit, pwc, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: 普华永道
- id: 69b37c2258d557c902bb7b0d | 官方: 否 | 付费: 否
答案:
Suppose assume the table is in the format shown below,:
假设该表采用如下所示的格式:
Employee table:
员工表:
| Name | Salary |
|---|---|
| Ravi | 25000 |
| Sunil | 12000 |
| Tarak | 95000 |
| Name | Salary |
|---|---|
| Ravi | 25000 |
| Sunil | 12000 |
| Tarak | 95000 |
To find the maximum salary,
要查找最高工资,
SELECT MAX(Salary) from Employee; // To just get the max salary
SELECT MAX(Salary) from Employee; // 仅获取最高工资
SELECT * from Employee where Salary = (SELECT MAX(Salary) from Employee); // Employees with highest salary
SELECT * from Employee where Salary = (SELECT MAX(Salary) from Employee); // 工资最高的员工
To find the average salary,
要查找平均工资,
SELECT AVG(Salary) from Employee;
SELECT AVG(Salary) from Employee;
To find the minimum salary,
要查找最低工资,
SELECT MIN(Salary) from Employee; // To just get the min salary
SELECT MIN(Salary) from Employee; // 仅获取最低工资
SELECT * from Employee where Salary = (SELECT MIN(Salary) from Employee); // Employees with lowest salary
SELECT * from Employee where Salary = (SELECT MIN(Salary) from Employee); // 薪资最低的员工
Useful Interview Resources
有用的面试资源
- Free Mock Coding Interview
- DSA Tutorial
- Coding Interview Questions for Practice
- Technical Interview Questions for Practice
- Interview Preparation
88. Explain Normalization and De-Normalization.
解释规范化和反规范化。
- 知识点: 数据库 (标签: interviewbit, qualcomm, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: 高通
- id: 69b37c2d58d557c902bb819c | 官方: 否 | 付费: 否
答案:
Databases must be normalized in order to structure them efficiently. It involves establishing tables and establishing connections between them based on certain rules. These rules may eliminate or reduce the amount of redundancy and dependency, making it more flexible. 1NF, 2NF, 3NF, BCNF, 4NF, and 5NF are 6 distinct normal forms. Normalization should be done to avoid data loss but not at the expense of integrity.
必须对数据库进行规范化,以便高效地构建其结构。它涉及建立表并根据某些规则建立表之间的连接。这些规则可以消除或减少冗余和依赖性,使其更加灵活。1NF、2NF、3NF、BCNF、4NF和5NF是6种不同的范式。应进行规范化以避免数据丢失,但不能以牺牲完整性为代价。
The procedure of denormalizing a schema is to convert it into one that has redundant information. Redundancy and keeping redundant data consistent are both beneficial. An over-normalised structure is inefficient in query processing because of its overheads.
反规范化模式的流程是将其转换为包含冗余信息的模式。冗余和保持冗余数据的一致性都是有益的。过度规范化的结构由于开销较大,在查询处理方面效率低下。
89. What is the default port for the MySQL server?
MySQL服务器的默认端口是什么?
- 知识点: 数据库 (标签: interviewbit, siemens, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Siemens
- id: 69b37c5158d557c902bc75e4 | 官方: 否 | 付费: 否
答案:
The MySQL client, MySQL Connectors, and utilities like mysqldump and mysqlpump all use port 3306 as the default port for the old MySQL protocol (port).
MySQL客户端、MySQL连接器以及mysqldump和mysqlpump等实用工具都使用端口3306作为旧MySQL协议(端口)的默认端口。
90. What do you mean by SQL Correlated Subqueries?
你说的SQL相关子查询是什么意思?
- 知识点: 数据库 (标签: interviewbit, tcs, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Tata Consultancy Services
- id: 69b37c6a58d557c902bc84bc | 官方: 否 | 付费: 否
答案:
A correlated sub-query is a sub-query that is dependent on another query. Sub-queries that are executed for each row of an outer query are referred to as correlated sub-queries. For each row in the outer query, each sub-query is executed once.
相关子查询是依赖于另一个查询的子查询。对外部查询的每一行执行的子查询称为相关子查询。对于外部查询中的每一行,每个子查询都会执行一次。
Correlated sub-queries can alternatively be thought of as queries that the parent statement uses for row-by-row processing. The parent statement, in this case, might be SELECT, UPDATE, or DELETE.
相关子查询也可以被视为父语句用于逐行处理的查询。在这种情况下,父语句可能是SELECT、UPDATE或DELETE。
91. What is a checkpoint in a database management system, and when does it eventuate?
数据库管理系统中的检查点是什么,它何时发生?
- 知识点: 数据库 (标签: interviewbit, tcs, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Tata Consultancy Services
- id: 69b37c6a58d557c902bc84bf | 官方: 否 | 付费: 否
答案:
A checkpoint is a technique that removes all previous logs from the system and stores them permanently on the storage drive. Checkpoints are those locations in the transaction log record from which all committed data up to the point of the crash can be recovered.
检查点是一种从系统中删除所有先前的日志并将它们永久存储在存储驱动器上的技术。检查点是事务日志记录中的那些位置,从这些位置可以恢复截至崩溃点的所有已提交数据。
- Data Science
- All Events
- My Events
92. In a database management system, what are the two integrity rules?
在数据库管理系统中,有哪两条完整性规则?
- 知识点: 数据库 (标签: interviewbit, tcs, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Tata Consultancy Services
- id: 69b37c6a58d557c902bc84c2 | 官方: 否 | 付费: 否
答案:
Referential integrity rules and entity integrity rules are the two forms of integrity rules.
参照完整性规则和实体完整性规则是完整性规则的两种形式。
According to referential integrity requirements, if a primary key value is used as a foreign key in a child table, it cannot be changed. Let R and S be two different relations. Assume that R relates to the relation S through a set of attributes that serve as the Primary Key of S and as a Foreign Key in the relation R. The Foreign Key in a tuple in R must then be either equal to the Primary Key in a tuple in S or completely NULL.
根据参照完整性要求,如果一个主键值在子表中被用作外键,则它不能被更改。设R和S是两个不同的关系。假设R通过一组属性与关系S相关联,这些属性充当S的主键并在关系R中充当外键。那么,R中元组的外键必须要么等于S中元组的主键,要么完全为NULL。
The main key value cannot be null due to entity integrity. An attribute X of a relation R(R) cannot take null values if it is a Prime Attribute of R(R). A Prime Attribute is an attribute that is a part of a relation's Candidate Key.
由于实体完整性,主键值不能为空。如果关系R(R)的属性X是R(R)的主属性,则该属性X不能取空值。主属性是作为关系候选键一部分的属性。
93. What does a database schema imply? What are its types?
数据库模式意味着什么?它有哪些类型?
- 知识点: 数据库 (标签: interviewbit, tcs, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Tata Consultancy Services
- id: 69b37c6a58d557c902bc84ef | 官方: 否 | 付费: 否
答案:
A "database schema" is a plan for how a database is built that describes how data is organized (divided into database tables in the case of relational databases). A database schema is formally defined as a series of formulas (sentences) known as integrity constraints that are imposed on a database.
“数据库模式”是构建数据库的计划,描述了数据如何组织(在关系数据库的情况下分为数据库表)。数据库模式被正式定义为一组称为完整性约束的公式(语句),这些约束被施加在数据库上。
Physical schema, logical schema, and view schema are the three types of schema.
物理模式、逻辑模式和视图模式是模式的三种类型。
The physical schema describes how the data contained in blocks of storage is characterized at the physical level of a database.
物理模式描述了存储在存储块中的数据在数据库物理层面上的特征。
The logical schema is the design of a database at the logical level; programmers and database administrators work at this level; data can be characterized as certain types of data records that are stored in data structures; however, internal details such as data structure implementation are obscured at this level (available at the physical level).
逻辑模式是数据库在逻辑层面上的设计;程序员和数据库管理员在这一层面工作;数据可以被描述为存储在数据结构中的某些类型的数据记录;然而,数据结构实现等内部细节在这一层面上被隐藏(在物理层面上可用)。
View schema is the design of a database at the view level. This term refers to how end-users interact with database systems.
视图模式是数据库在视图层面上的设计。这个术语指的是最终用户如何与数据库系统交互。
94. How do you optimize the performance of a database?
如何优化数据库的性能?
- 知识点: 数据库 (标签: interviewbit, tcs-digital, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Tata Consultancy Services
- id: 69b37c6d58d557c902bc862e | 官方: 否 | 付费: 否
答案:
There are several techniques that you can use to optimize the performance of a database: - Indexing: Indexing is the process of creating a data structure that allows the database to access and retrieve data quickly thereby avoiding the need for searching and matching every row in the database. Indexes can be created on specific columns in a table to improve the performance of queries that filter or sort data based on those columns.
你可以使用几种技术来优化数据库的性能:- 索引:索引是创建一种数据结构的过程,使数据库能够快速访问和检索数据,从而避免搜索和匹配数据库中的每一行。可以在表中的特定列上创建索引,以提高基于这些列过滤或排序数据的查询性能。
- Partitioning: Partitioning is the process of dividing a table into smaller, more manageable pieces, called partitions. Partitioning can improve the performance of queries that access large amounts of data, as it allows the database to access the data in smaller, more efficient chunks.Partitioning can be done in two ways - vertical and horizontal. Vertical partitioning involves splitting a table into smaller parts based on columns, while horizontal partitioning involves splitting a table into smaller parts based on rows. Vertical partitioning can be useful for tables with many columns that are rarely accessed together, while horizontal partitioning can be useful for tables with a large number of rows that can be grouped based on specific criteria, such as date ranges or geographic regions.
In the above image, we see Vertical and Horizontal Partitioning. In Vertical Partitioning, we are distributing the table columns that separate the Customer Details with their favorite color.
在上面的图像中,我们看到垂直分区和水平分区。在垂直分区中,我们分布表列,将客户详情与其最喜欢的颜色分开。
And, in Horizontal Partitioning, we are minimizing the table size by removing entries from the table and creating a new table with that entry. - Caching: Caching is a technique used to improve the performance of accessing data by storing frequently accessed data in a cache. When a request is made for the data, the system first checks the cache to see if the data is already available. If it is, the system retrieves the data from the cache, rather than from the original source, which can be slower to access.
并且,在水平分区中,我们通过从表中移除条目并创建一个包含该条目的新表来最小化表大小。- 缓存:缓存是一种通过将频繁访问的数据存储在缓存中来提高访问数据性能的技术。当请求数据时,系统首先检查缓存以查看数据是否已经可用。如果是,系统从缓存中检索数据,而不是从原始源检索,原始源的访问可能更慢。
In the above image, we can see that the application is using the database to fetch some data. The application first searches the data into the cache, if the data is not present then it will request the database to provide the data. Once the data is returned by the database, the data is stored in the cache so that in the future, if the data is required, then it can be fetched directly from here.
在上面的图像中,我们可以看到应用程序正在使用数据库获取一些数据。应用程序首先在缓存中搜索数据,如果数据不存在,那么它将请求数据库提供数据。一旦数据库返回数据,数据就被存储在缓存中,以便将来如果需要数据,可以直接从这里获取。
By using caching, the system can access frequently used data more quickly, reducing the overall time it takes to retrieve and process the data. Caching can be particularly useful for large or complex data sets, as well as for systems that require frequent access to the same data. However, it's important to keep in mind that caching can also consume system resources and that the cache must be managed to ensure that it remains accurate and up-to-date.
通过使用缓存,系统可以更快地访问频繁使用的数据,减少检索和处理数据所需的总时间。缓存对于大型或复杂的数据集以及需要频繁访问相同数据的系统特别有用。然而,重要的是要记住,缓存也会消耗系统资源,并且必须管理缓存以确保其保持准确和最新。
Normalization: Normalization is the process of organizing data in a database in a way that minimizes redundancy and dependency. Normalization can improve the performance of the database by reducing the size of the data and improving the efficiency of queries. 2. Optimizing queries: Optimizing queries is the process of improving the performance of SQL statements by minimizing the amount of data that is accessed and processed. This can be done by writing efficient queries, using appropriate indexes, and minimizing the use of expensive operations such as sorts and joins. 3. Monitoring and tuning: Monitoring and tuning is the process of continuously monitoring the performance of the database and making adjustments to improve it. This can involve identifying and addressing bottlenecks, adjusting the configuration of the database, and optimizing the schema and queries.
- 规范化:规范化是在数据库中组织数据的过程,以最小化冗余和依赖性。规范化可以通过减少数据大小和提高查询效率来改善数据库的性能。 2. 优化查询:优化查询是通过最小化访问和处理的数据量来改善SQL语句性能的过程。这可以通过编写高效的查询、使用适当的索引以及最小化使用排序和连接等昂贵操作来实现。 3. 监控和调优:监控和调优是持续监控数据库性能并进行调整以改进它的过程。这可能涉及识别和解决瓶颈、调整数据库配置以及优化模式和查询。
There are several tools available to monitor and tune the performance of a database. Here are a few examples:
有多种工具可用于监控和调优数据库性能。以下是一些示例:
Profiling Tools: These tools can help identify performance bottlenecks by analyzing query execution times and resource usage. Examples include pgBadger, Query Profiler, and pgFouine. 2. Resource Monitoring Tools: These tools can help track resource usages, such as CPU, memory, and disk I/O, to identify performance issues. Examples include top, htop, and sar. 3. Database Administration Tools: These help monitor and tune database performance, including configuration management, query analysis, and schema optimization. Examples include pgAdmin, Oracle Enterprise Manager, and SQL Server Management Studio. 4. Load Testing Tools: These tools can simulate heavy loads on the database to measure its performance and identify bottlenecks. Examples include Apache JMeter, LoadRunner, and Gatling.
- 性能分析工具:这些工具可以通过分析查询执行时间和资源使用情况来帮助识别性能瓶颈。示例包括 pgBadger、Query Profiler 和 pgFouine。 2. 资源监控工具:这些工具可以帮助跟踪资源使用情况,如 CPU、内存和磁盘 I/O,以识别性能问题。示例包括 top、htop 和 sar。 3. 数据库管理工具:这些工具有助于监控和调优数据库性能,包括配置管理、查询分析和架构优化。示例包括 pgAdmin、Oracle Enterprise Manager 和 SQL Server Management Studio。 4. 负载测试工具:这些工具可以模拟数据库上的重负载,以衡量其性能并识别瓶颈。示例包括 Apache JMeter、LoadRunner 和 Gatling。
By using these techniques, database administrators can identify performance issues and make informed decisions on how to optimize the database to ensure it runs smoothly and efficiently.
通过使用这些技术,数据库管理员可以识别性能问题,并就如何优化数据库做出明智的决策,以确保其平稳高效地运行。
Successful Tech Career for FREE!
免费开启成功的科技职业生涯!
Successful Tech Career!
成功的技术职业生涯!
Interview Process
面试流程
CTC & Designation
CTC与职位级别
Projects on the Job
工作项目
Referral System
推荐系统
Try It Out
试试看
2 Lakh+ Roadmaps Created
已生成20万+职业规划
95. What is a database and how does it store and retrieve data?
什么是数据库,它如何存储和检索数据?
- 知识点: 数据库 (标签: interviewbit, tcs-digital, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Tata Consultancy Services
- id: 69b37c6e58d557c902bc8686 | 官方: 否 | 付费: 否
答案:
A database is a collection of structured data that is stored and accessed electronically. Databases are used to store, organize, and retrieve data efficiently, and are an essential part of many computer systems and applications. - Relational Databases: These databases organize data into one or more tables with a predefined schema. They use SQL to query and manipulate data, and enforce ACID properties to ensure data consistency.
数据库是以电子方式存储和访问的结构化数据的集合。数据库用于高效地存储、组织和检索数据,是许多计算机系统和应用程序的重要组成部分。 - 关系型数据库:这些数据库将数据组织到一个或多个具有预定义模式的表中。它们使用 SQL 来查询和操作数据,并强制执行 ACID 属性以确保数据一致性。
- NoSQL databases: NoSQL databases are non-relational databases that store and retrieve data differently than traditional relational databases. Unlike relational databases, which use tables with rows and columns to organize and store data, NoSQL databases use different data models, such as document-based, key-value, column-family, and graph models, to store data in flexible, scalable, and distributed ways.NoSQL databases are designed to handle large amounts of unstructured, semi-structured, and even structured data that cannot be easily managed by traditional relational databases. They offer high availability, scalability, and performance, making them suitable for modern web applications and big data analytics.
- Document Databases: Document databases are a type of NoSQL database that stores data in the form of semi-structured documents, typically in JSON or BSON format. Each document can have its own unique structure and can include fields with varying data types.Document databases are flexible and scalable, allowing for easy data modelling and schema changes. They are well-suited for applications that require complex data structures, such as social media platforms, content management systems, and e-commerce websites.MongoDB is one of the most popular document databases, widely used in web applications for its ease of use, scalability, and high performance.
- Key-value stores: Key-value stores are a type of NoSQL database that stores data as a collection of key-value pairs, where each key is a unique identifier for a particular value. Key-value stores are typically used for caching and session management, as they can store large amounts of data in memory and retrieve it quickly.Key-value stores are simple and scalable, making them ideal for high-traffic web applications that require fast data access. They are also well-suited for distributed systems, as they can be easily partitioned and replicated across multiple nodes.Redis is a popular open-source key-value store, known for its high performance, support for multiple data types, and advanced features such as pub/sub messaging, Lua scripting, and transactions.
96. How do you design and implement database?
你如何设计和实现数据库?
- 知识点: 数据库 (标签: interviewbit, tcs-digital, company-specific)
- 类型: technical | 难度: easy | 子类型: coding
- 分类: general
- 公司: Tata Consultancy Services
- id: 69b37c6e58d557c902bc8689 | 官方: 否 | 付费: 否
答案:
Databases are an essential part of many applications and are used to store and manage large amounts of data efficiently and effectively.
数据库是许多应用程序的重要组成部分,用于高效且有效地存储和管理大量数据。
To design a database, you need to determine the data that needs to be stored and the relationships between the data. This involves creating a schema, which is a blueprint for the structure of the database. The schema defines the tables, fields, and relationships in the database.
要设计数据库,你需要确定需要存储的数据以及数据之间的关系。这涉及创建模式,模式是数据库结构的蓝图。模式定义了数据库中的表、字段和关系。
Once the database design is complete, the next step is to implement the database. This involves creating the tables and fields in the database and populating the tables with data.
一旦数据库设计完成,下一步就是实现数据库。这涉及在数据库中创建表和字段,并向表中填充数据。
To implement a database, you can use a database management system (DBMS) such as MySQL, Oracle, or MongoDB. A DBMS is a software program that allows you to create and manage a database. It provides a set of tools and interfaces for creating, querying, and updating the database.
要实现数据库,你可以使用数据库管理系统(DBMS),例如 MySQL、Oracle 或 MongoDB。DBMS 是一个软件程序,允许你创建和管理数据库。它提供了一组用于创建、查询和更新数据库的工具和接口。
97. What is Normalization?
什么是规范化?
- 知识点: 数据库 (标签: interviewbit, tcs-digital, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Tata Consultancy Services
- id: 69b37c6e58d557c902bc8691 | 官方: 否 | 付费: 否
答案:
Normalization is the process of organizing a database in a way that minimizes redundancy and dependency, and that allows data to be stored and accessed efficiently. It is a design technique that is used to ensure that a database is structured in a way that reduces the risk of data inconsistencies and ensures the integrity of the data.
规范化是组织数据库的过程,以最大限度地减少冗余和依赖,并允许高效地存储和访问数据。它是一种设计技术,用于确保数据库的结构方式能够降低数据不一致的风险并确保数据的完整性。
There are several normal forms that can be used to normalize a database, ranging from the first normal form (1NF) to the fifth normal form (5NF). Each normal form has a set of rules that must be followed to ensure that the database is properly normalized.
有多种范式可用于规范化数据库,从第一范式(1NF)到第五范式(5NF)。每种范式都有一套必须遵循的规则,以确保数据库得到正确规范化。
The most common normal form is the third normal form (3NF), which is defined as follows: - A database is in 3NF if it is in the second normal form (2NF) and all the attributes in the database are dependent on the primary key (i.e., there are no transitive dependencies).
最常见的范式是第三范式(3NF),其定义如下: - 如果数据库处于第二范式(2NF),并且数据库中的所有属性都依赖于主键(即没有传递依赖),则该数据库处于 3NF。
- A database is in 2NF if it is in first normal form (1NF) and all the non-key attributes in the database are fully dependent on the primary key.
A database is in 1NF if all the attributes in the database are atomic (i.e., they cannot be further divided into smaller pieces of data).
Example table and its normalization up to 3NF:示例表及其规范化至 3NF:
Original table:
原始表:
| Order_ID | Customer_ID | Customer_Name | Product_ID | Product_Name | Quantity | Price |
|---|---|---|---|---|---|---|
| 1 | 1001 | John Smith | 001 | Phone | 2 | $300 |
| 1 | 1001 | John Smith | 002 | Laptop | 1 | $1200 |
| 2 | 1002 | Jane Doe | 001 | Phone | 1 | $300 |
| 3 | 1003 | Bob Johnson | 002 | Laptop | 3 | $1200 |
| - First normal form (1NF): The table is already in 1NF as all attributes are atomic because it doesn’t have any repeated rows. So we can use Order_id and Product_id to uniquely define rows / make it the primary key. - 第一范式(1NF):该表已经处于 1NF,因为所有属性都是原子的,因为它没有任何重复行。因此我们可以使用 Order_id 和 Product_id 来唯一定义行 / 使其成为主键。 |
Second Normal Form (2NF): The Order Details table is not in 2NF because the Product Name is dependent on the Product ID, and not on the Order ID. To bring it to 2NF, we can create a separate Products table. We will also have a new Customer table just for storing customer details.
Orders table:Orders 表:
| Order_ID | Customer_ID |
|---|---|
| 1 | 1001 |
| 2 | 1002 |
| 3 | 1003 |
| Order_ID | Customer_ID |
|---|---|
| 1 | 1001 |
| 2 | 1002 |
| 3 | 1003 |
Customer table:
Customer 表:
| Customer_ID | Customer_Name |
|---|---|
| 1001 | John Smith |
| 1002 | Jane Doe |
| 1003 | Bob Johnson |
| Customer_ID | Customer_Name |
|---|---|
| 1001 | John Smith |
| 1002 | Jane Doe |
| 1003 | Bob Johnson |
Order Details table:
订单详情表:
| Order_ID | Product_ID | Quantity | Price |
|---|---|---|---|
| 1 | 001 | 2 | $300 |
| 1 | 002 | 1 | $1200 |
| 2 | 001 | 1 | $300 |
| 3 | 002 | 3 | $1200 |
| Order_ID | Product_ID | Quantity | Price |
|---|---|---|---|
| 1 | 001 | 2 | $300 |
| 1 | 002 | 1 | $1200 |
| 2 | 001 | 1 | $300 |
| 3 | 002 | 3 | $1200 |
Products table:
产品表:
| Product_ID | Product_Name |
|---|---|
| 001 | Phone |
| 002 | Laptop |
| - Third Normal Form (3NF): The Order Details table is not in 3NF because the Price is dependent on the Product ID, and not on the Order ID. To bring it to 3NF, we can create a separate Product Prices table: - 第三范式(3NF):订单详情表不满足第三范式,因为价格依赖于产品 ID,而不是订单 ID。为了使其满足第三范式,我们可以创建一个单独的产品价格表: |
Orders table:
Orders 表:
| Order_ID | Customer_ID |
|---|---|
| 1 | 1001 |
| 2 | 1002 |
| 3 | 1003 |
| Order_ID | Customer_ID |
|---|---|
| 1 | 1001 |
| 2 | 1002 |
| 3 | 1003 |
Order Details table:
订单详情表:
| Order_ID | Product_ID | Quantity |
|---|---|---|
| 1 | 001 | 2 |
| 1 | 002 | 1 |
| 2 | 001 | 1 |
| 3 | 002 | 3 |
| Order_ID | Product_ID | Quantity |
|---|---|---|
| 1 | 001 | 2 |
| 1 | 002 | 1 |
| 2 | 001 | 1 |
| 3 | 002 | 3 |
Products table:
产品表:
| Product_ID | Product_Name |
|---|---|
| 001 | Phone |
| 002 | Laptop |
| Product_ID | Product_Name |
|---|---|
| 001 | Phone |
| 002 | Laptop |
Product Prices table:
产品价格表:
| Product_ID | Price |
|---|---|
| 001 | $300 |
| 002 | $1200 |
| Product_ID | Price |
|---|---|
| 001 | $300 |
| 002 | $1200 |
Now the table is in 3NF, and all the attributes are dependent on the primary key. For every table, the primary key can be -
现在该表已满足第三范式,所有属性都依赖于主键。对于每个表,主键可以是——
| Table Name 表名 | Primary Key 主键 |
|---|---|
| Orders Table 订单表 | Order_ID |
| Customer Table 客户表 | Customer_ID |
| Order Details Table 订单详情表 | (Order_ID, Product_ID) |
| Products Table 产品表 | Product_ID |
| Products Prices Table 产品价格表 | Product_ID |
This means that the table is now properly normalized, which will help to prevent data redundancy and inconsistencies.
这意味着该表现在已正确规范化,这将有助于防止数据冗余和不一致。
In conclusion, by breaking down the original table into three separate tables and following the normalization process, we have achieved 3NF.
总之,通过将原始表分解为三个独立的表并遵循规范化过程,我们实现了3NF。
98. Explain ACID properties in DBMS?
解释DBMS中的ACID属性?
- 知识点: 数据库 (标签: interviewbit, tcs-ninja, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Tata Consultancy Services
- id: 69b37c7258d557c902bc8838 | 官方: 否 | 付费: 否
答案:
In order for a database to maintain its integrity, all transactions must adhere to the ACID standard. The ACID acronym refers to atomicity, consistency, isolation, and durability, so let's discuss each of them in turn. - Atomicity: An atomic transaction data remains unchanged even after an operation is executed. This means that if an operation is undertaken on the data, either the operation must be completed or it must not be executed at all. A transaction operation should not be split between different parts or executed in stages. It must be completed entirely and not partially.
为了使数据库保持其完整性,所有事务都必须遵循ACID标准。ACID这一缩写指的是原子性、一致性、隔离性和持久性,因此让我们依次讨论它们。- 原子性:即使在执行操作之后,原子事务数据也保持不变。这意味着如果对数据执行了操作,那么该操作要么必须完成,要么根本不执行。事务操作不应被拆分到不同部分或分阶段执行。它必须完全完成,而不能只完成一部分。
- Consistency: The consistency property defines the level of how the data should be kept unchanged. By keeping the data consistent, the DBMS is not allowing any inconsistency in the data. An example of a level of consistency would be when one table contains the data on which the operation is performed while another table should contain the data before performing the operation.
- Isolation: When the transactions are running concurrently, the outcome should be the same as if the transactions were running serially; that is, the result should be the same as if there were no transactions at all.
- Durability: The data after an operation is successfully executed is permanent in a DBMS. To ensure the durability of data, the term durability is used. Even if the system fails or crashes, the database may survive. However, if it is lost, the responsibility of the recovery manager is to ensure its durability. Whenever we make changes to values, the COMMIT command must be used.
99. What is the DDL command in MySql explain Create and Alter command?
MySql中的DDL命令是什么,请解释Create和Alter命令?
- 知识点: 数据库 (标签: interviewbit, tcs-ninja, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Tata Consultancy Services
- id: 69b37c7258d557c902bc883b | 官方: 否 | 付费: 否
答案:
The Data Definition Language is a set of SQL commands designed to structure databases. It handles database schema descriptions and constructs and modifies database objects' structures in databases. In addition to data, DDL refers to a set of SQL instructions for creating, modifying, and deleting database structures. It does not handle data. Database structures are created, modified, and deleted using DDL commands. All DDL commands are auto-committed, saving all database changes permanently. DDL commands that construct the database structure include: - CREATE: A database or one of its objects is created using this command (like tables, indexes, functions, views, stored procedures, and triggers). You can issue two kinds of SQL statements: one that creates a database and another that creates a table.
数据定义语言是一组用于构建数据库结构的SQL命令。它处理数据库模式描述,并在数据库中构造和修改数据库对象的结构。除了数据之外,DDL还指一组用于创建、修改和删除数据库结构的SQL指令。它不处理数据。数据库结构是通过DDL命令创建、修改和删除的。所有DDL命令都会自动提交,从而永久保存所有数据库更改。用于构造数据库结构的DDL命令包括:- CREATE:使用此命令创建数据库或其某个对象(如表、索引、函数、视图、存储过程和触发器)。你可以发出两种SQL语句:一种创建数据库,另一种创建表。
Syntax:
语法:
To create Database: CREATE DATABASE db_name;
创建数据库:CREATE DATABASE db_name;
Example: CREATE DATABASE store;
示例:CREATE DATABASE store;
To create Table:
创建表:
CREATE TABLE table_name(
CREATE TABLE table_name(
Column_name1 data_type(size),
Column_name1 data_type(size),
Column_name2 data_type(size),
Column_name2 data_type(size),
Column_name3 data_type(size),
Column_name3 data_type(size),
…..
);
Example:
示例:
CREATE TABLE product(
CREATE TABLE product(
Id int(10),
Id int(10),
Name varchar(100),
Name varchar(100),
Price varchar(10)
Price varchar(10)
);
- ALTER: The ALTER command in SQL lets us add, delete, and modify items in a table, view, or the whole database. We can also modify, add, and delete constraints, columns, and indexes using the ALTER command.
Command to add new Column:
添加新列的命令:
Syntax: ALTER TABLE table_name ADD column_name column-definition;
语法:ALTER TABLE table_name ADD column_name column-definition;
Example: ALTER TABLE product ADD category varchar(50);
示例:ALTER TABLE product ADD category varchar(50);
Command to modify a Column:
修改列的命令:
Syntax: ALTER TABLE table_name MODIFY (column-definition);
语法:ALTER TABLE table_name MODIFY (column-definition);
Example: ALTER TABLE product MODIFY (category varchar2(100));
示例:ALTER TABLE product MODIFY (category varchar2(100));
100. What is the Drop and Truncate command in SQL?
SQL 中的 Drop 和 Truncate 命令是什么?
- 知识点: 数据库 (标签: interviewbit, tcs-ninja, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Tata Consultancy Services
- id: 69b37c7258d557c902bc883e | 官方: 否 | 付费: 否
答案:
- DROP: You may drop a whole database or a table by using the DROP statement. Existing objects such as databases, tables, indexes, and views are destroyed with the DROP command.
Syntax: To drop a table: DROP TABLE table_name;
语法:删除表:DROP TABLE table_name;
To drop a database: DROP DATABASE db_name;
删除数据库:DROP DATABASE db_name;
Example: To drop a table: DROP TABLE product;
示例:删除表:DROP TABLE product;
To drop a database: DROP DATABASE store; - TRUNCATE: Used to indicate the table’s extents for deallocation (empty for reuse). This method is quicker than the usual integrity checking procedures to remove all data from a table. This procedure was introduced in the SQL:2008 standard for the first time. It is somewhat equivalent to the delete command.
删除数据库:DROP DATABASE store; - TRUNCATE:用于指示表的区段进行释放(清空以供重用)。此方法比通常的完整性检查过程更快地从表中移除所有数据。此过程首次在 SQL:2008 标准中引入。它在某种程度上相当于 delete 命令。
Syntax: TRUNCATE TABLE table_name;
语法:TRUNCATE TABLE table_name;
Example: TRUNCATE TABLE product;
示例:TRUNCATE TABLE product;
101. Write an SQL Query to select all those entries from the table STUDENTS, whose name is “Rahul”.
编写一个 SQL 查询,从表 STUDENTS 中选择所有 name 为 “Rahul” 的条目。
- 知识点: 数据库 (标签: interviewbit, tcs-nqt, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Tata Consultancy Services
- id: 69b37c7458d557c902bc8947 | 官方: 否 | 付费: 否
答案:
The SQL Query to do so is
执行此操作的 SQL 查询是
SELECT * FROM STUDENTS WHERE NAME = “Rahul”
SELECT * FROM STUDENTS WHERE NAME = “Rahul”
102. Write an SQL query to print the current date.
编写一个 SQL 查询来打印当前日期。
- 知识点: 数据库 (标签: interviewbit, tcs-nqt, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Tata Consultancy Services
- id: 69b37c7458d557c902bc894a | 官方: 否 | 付费: 否
答案:
The SQL Query to print the current date is: GetDate()
打印当前日期的 SQL 查询是:GetDate()
103. State some of the advantages of a DataBase Management System.
列举数据库管理系统的一些优点。
- 知识点: 数据库 (标签: interviewbit, tech-mahindra, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Tech Mahindra
- id: 69b37c7758d557c902bc8b1f | 官方: 否 | 付费: 否
答案:
Some of the advantages of a DataBase Management System are as follows:
数据库管理系统的一些优点如下:
- It helps in controlling redundancy in the database.
- Unauthorized access is restricted by it.
- Multiple user interfaces are available.
- Backup and recovery services are available.
- Integrity limitations are enforced.
- Ensure that data is consistent.
- Easily accessible.
- Due to the usage of queries, data extraction and processing are simple.
104. What are ACID properties in Database Management Systems?
数据库管理系统中的 ACID 属性是什么?
- 知识点: 数据库 (标签: interviewbit, tech-mahindra, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Tech Mahindra
- id: 69b37c7758d557c902bc8b22 | 官方: 否 | 付费: 否
答案:
The term "ACID" is an acronym for Atomicity, Consistency, Isolation and Durability. A transaction is a logical unit of work that accesses and, in certain cases, updates the contents of a database. Read and write operations are used by transactions to access data. Certain properties are followed before and after a transaction in order to preserve consistency in a database. ACID characteristics are what they are called. Let us take a look at each of these characteristics in detail: - Atomicity: Atomicity means that either the complete transaction occurs at once or it does not occur at all. There is no middle ground, which means that transactions do not take place in stages. Each transaction is treated as a single entity that is either completed or not conducted at all. It entails the following two procedures.
术语"ACID"是原子性(Atomicity)、一致性(Consistency)、隔离性(Isolation)和持久性(Durability)的首字母缩写。事务是访问并在某些情况下更新数据库内容的逻辑工作单元。事务使用读和写操作来访问数据。为了保持数据库中的一致性,事务前后需要遵循某些属性。这些属性就被称为 ACID 特性。让我们详细看看每一个特性: - 原子性:原子性意味着要么整个事务一次性发生,要么根本不发生。没有中间状态,这意味着事务不会分阶段进行。每个事务被视为一个单一实体,要么完成,要么根本不执行。它包含以下两个过程。
Abort: If a transaction aborts, any database modifications are lost. Commit: When a transaction commits, the changes it contains become visible.
中止:如果事务中止,任何数据库修改都会丢失。提交:当事务提交时,其所包含的更改变得可见。
The 'All or nothing rule' is another name for atomicity.
"全有或全无规则"是原子性的另一个名称。
Consider the following transaction T, which consists of two transactions: T1 and T2. 100 dollars transferred from account X to account Y.
考虑以下事务 T,它由两个事务组成:T1 和 T2。从账户 X 向账户 Y 转移 100 美元。
If a transaction fails after T1 but before T2 (for example, after write(X) but before write(Y)), the amount deducted from X but not added to Y is deducted. As a result, the database is in an inconsistent condition. As a result, the transaction must be completed in its entirety to guarantee that the database state is valid. - Consistency: This means that integrity constraints must be maintained before and after the transaction to ensure that the database is consistent. It refers to a database's correctness. The entire amount before and after the transaction must be maintained, as shown in the example above.
如果事务在 T1 之后但在 T2 之前失败(例如,在 write(X) 之后但在 write(Y) 之前),则从 X 扣除的金额没有被添加到 Y。因此,数据库处于不一致状态。因此,事务必须完整完成以保证数据库状态有效。 - 一致性:这意味着在事务前后必须维护完整性约束,以确保数据库是一致的。它指的是数据库的正确性。如上面的例子所示,事务前后的总金额必须保持不变。
Before T, the total is 500 + 200 = 700. After T, the total is 400 + 300 = 700.
在 T 之前,总额是 500 + 200 = 700。在 T 之后,总额是 400 + 300 = 700。
As a result, the database is consistent. When T1 succeeds but T2 fails, there is inconsistency. As a result, T is not complete. - Isolation: This attribute assures that several transactions can take place at the same time without causing database state inconsistencies. Transactions take place in a non-interfering manner. Changes made in one transaction are not visible to other transactions until that transaction's update is written to memory or committed. This feature assures that concurrently executing transactions results in a state that is identical to the one attained if they were executed sequentially in some order.
因此,数据库是一致的。当 T1 成功但 T2 失败时,就存在不一致。因此,T 不完整。 - 隔离性:此属性确保多个事务可以同时发生而不会导致数据库状态不一致。事务以互不干扰的方式发生。在一个事务中所做的更改对其他事务不可见,直到该事务的更新被写入内存或提交。此特性确保并发执行的事务所产生的结果状态与按某种顺序顺序执行时所达到的状态相同。
Let us take an example to understand Isolation. Let X = 500 and Y = 500 and let there be two transactions T and T".
让我们举一个例子来理解隔离性。设 X = 500,Y = 500,并且有两个事务 T 和 T"。
Assume T has been running until Read (Y), at which point T" begins. As a result of this interleaving, T" reads the right value of X but the wrong value of Y, and the sum computed by T": (X+Y = 50, 000+500=50, 500) is inconsistent with the sum at the end of the transaction:
假设 T 一直运行到 Read (Y),此时 T" 开始。由于这种交错,T" 读取了 X 的正确值但读取了 Y 的错误值,并且 T" 计算的总和:(X+Y = 50, 000+500=50, 500) 与事务结束时的总和
T = 50, 000 + 450 = 50, 450 (X+Y = 50, 000 + 450 = 50, 450).
T = 50, 000 + 450 = 50, 450 (X+Y = 50, 000 + 450 = 50, 450)。
Due to the loss of 50 units, this causes database discrepancy. As a result, transactions must be performed in isolation, and changes should only be seen after they have been written to the main memory. - Durability: This attribute ensures that after the transaction has been completed, the database updates and modifications are saved and written to disc and that they survive even if the system fails. These changes are now saved in non-volatile memory and are permanent. The transaction's effects are never lost as a result of this.
由于丢失了 50 个单位,这导致数据库不一致。因此,事务必须隔离执行,并且只有在更改被写入主内存后才能看到这些更改。- 持久性:此属性确保在事务完成后,数据库的更新和修改会被保存并写入磁盘,即使系统发生故障也能存留下来。这些更改现在保存在非易失性内存中,并且是永久性的。因此,事务的影响永远不会丢失。
The ACID properties , taken together, provide a mechanism for ensuring the correctness and consistency of a database in such a way that each transaction is a group of operations that acts as a single unit, produces consistent results, is isolated from other operations, and the updates it makes are durably stored.
ACID 属性结合在一起,提供了一种确保数据库正确性和一致性的机制,使得每个事务都是一组作为单个单元运作的操作,产生一致的结果,与其他操作隔离,并且其所做的更新被持久存储。
105. What do you understand by a checkpoint in Database Management Systems?
在数据库管理系统中,你对检查点是如何理解的?
- 知识点: 数据库 (标签: interviewbit, tech-mahindra, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Tech Mahindra
- id: 69b37c7758d557c902bc8b25 | 官方: 否 | 付费: 否
答案:
The Checkpoint in Database Management Systems (DBMS) is a technique that removes all previous logs from the system and stores them permanently on the storage drive. Preserving the log of each transaction and maintaining shadow pages are two methods that can assist the DBMS in recovering and maintaining the ACID properties. When it comes to a log-based recovery system, checkpoints are necessary. Checkpoints are the minimal points from which the database engine can recover after a crash as a specified minimal point from which the transaction log record can be utilised to recover all committed data up to the moment of the crash.
数据库管理系统(DBMS)中的检查点是一种从系统中移除所有先前的日志并将它们永久存储在存储驱动器上的技术。保留每个事务的日志和维护影子页面是两种可以帮助 DBMS 恢复和维护 ACID 属性的方法。在基于日志的恢复系统中,检查点是必要的。检查点是数据库引擎在崩溃后可以恢复的最小点,作为指定的最小点,从该点可以使用事务日志记录来恢复直到崩溃时刻的所有已提交数据。
106. What are transparent Distributed Database Management Systems?
什么是透明分布式数据库管理系统?
- 知识点: 数据库 (标签: interviewbit, tech-mahindra, company-specific)
- 类型: technical | 难度: easy | 子类型: system-design
- 分类: general
- 公司: Tech Mahindra
- id: 69b37c7758d557c902bc8b28 | 官方: 否 | 付费: 否
答案:
The transparent Distributed Database Management System is a form of a database management system that conceals its physical structure from users. Physical structure, also known as physical storage structure, refers to the DDBMS's memory manager and explains how data is saved on a disc. Because of this, there is less abstraction. There are four types of transparencies in Distributed Database Management Systems (or DDBMS): - Transaction transparency
透明分布式数据库管理系统是一种向用户隐藏其物理结构的数据库管理系统形式。物理结构,也称为物理存储结构,指的是 DDBMS 的内存管理器,并解释了数据如何保存在磁盘上。因此,抽象程度较低。分布式数据库管理系统(或 DDBMS)中有四种透明性类型:- 事务透明性
- Performance transparency
- DBMS transparency
- Distribution transparency.
107. Explain ACID Property in DBMS.
解释 DBMS 中的 ACID 属性。
- 知识点: 数据库 (标签: interviewbit, virtusa, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Virtusa
- id: 69b37c8a58d557c902bc9448 | 官方: 否 | 付费: 否
答案:
ACID stands for the acronym "Atomicity, Consistency, Isolation, and Durability". Property of a database system that ensures consistency between the internal data of the database and the external data sources such as a file system. If a property is missing in one area, the data in all areas must be consistent. The ACID property can be expressed as
ACID 是“原子性、一致性、隔离性和持久性”的首字母缩写。数据库系统的一种属性,确保数据库内部数据与外部数据源(如文件系统)之间的一致性。如果某个区域缺少某个属性,所有区域中的数据必须保持一致。ACID 属性可以表示为
Atomicity - No changes are allowed to take place in the database system except those that are explicitly allowed by a transaction. 2. Consistency - The internal data of the database and the external data sources must be consistent. This is achieved by ensuring that no transactions attempt to update the same records at different times. 3. Isolation - Transactions should not interfere with each other. For example, if one transaction updates a record that another transaction is updating, both transactions are likely to fail. 4. Durability - All records must remain intact when they are written back to their original location after completion of a transaction.
- 原子性——数据库系统中不允许发生更改,除非这些更改是事务明确允许的。 2. 一致性——数据库的内部数据和外部数据源必须保持一致。这是通过确保没有事务尝试在不同时间更新相同记录来实现的。 3. 隔离性——事务之间不应相互干扰。例如,如果一个事务更新了另一个事务正在更新的记录,两个事务都可能失败。 4. 持久性——在事务完成后,所有记录在被写回其原始位置时必须保持完整。
108. Consider an SQL table which has name of employees and their salaries as an entry in each tuple. Find the employees who have the second highest salary.
考虑一个 SQL 表,其中每个元组都有一个条目包含员工姓名及其工资。找出工资第二高的员工。
- 知识点: 数据库 (标签: interviewbit, walmart, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: 沃尔玛
- id: 69b37c8f58d557c902bc96ab | 官方: 否 | 付费: 否
答案:
There can be several approaches while writing an SQL query to a particular problem. Be sure that you explain your thinking as and when you are thinking about your approach. This will keep the interviewer engaged and present to him a clearer image of your thinking process.
在针对特定问题编写 SQL 查询时,可以有多种方法。请务必在思考你的方法时解释你的思路。这将使面试官保持参与,并向他更清晰地展示你的思考过程。
Approach 1:
方法一:
SELECT name, MAX(salary) AS salary
SELECT name, MAX(salary) AS salary
FROM employee
FROM employee
WHERE salary IN
WHERE salary IN
(SELECT salary FROM employee MINUS SELECT MAX(salary)
(SELECT salary FROM employee MINUS SELECT MAX(salary)
FROM employee);
FROM employee);
Here, we first find all the salaries which are not equal to the highest salary. Thus, the highest salary is eliminated by this process. Now, we need to find the employees having the highest salary in the remaining salaries.
这里,我们首先找出所有不等于最高工资的工资。因此,最高工资在这个流程中被排除。现在,我们需要在剩余的工资中找出拥有最高工资的员工。
Approach 2:
方法 2:
SELECT name, MAX(salary) AS salary
SELECT name, MAX(salary) AS salary
FROM employee
FROM employee
WHERE salary <> (SELECT MAX(salary)
WHERE salary <> (SELECT MAX(salary)
FROM employee);
FROM employee);
Here, we use the NOT operator. We run a nested query to first find the highest salary. Then, we find the highest salary in the outer query subject to the condition that it is not equal to the highest salary returned by the inner query.
这里,我们使用 NOT 运算符。我们运行一个嵌套查询来首先找出最高工资。然后,我们在外部查询中找出最高工资,条件是它不等于内部查询返回的最高工资。
Approach 3:
方法 3:
select * from employee
select * from employee
group by salary
group by salary
order by salary desc limit 1,1;
order by salary desc limit 1,1;
Here, we use the LIMIT operator. First of all, we order the tuples in the descending order of the salaries. Then we use the LIMIT operator and provide it with an offset value of 1. It implies that we will skip the first entry of the sorted order and limit our results to 1 entry of the remaining result. Here, we make an assumption that all the employees have unique salaries.
这里,我们使用 LIMIT 运算符。首先,我们按工资降序对元组进行排序。然后我们使用 LIMIT 运算符并为其提供偏移值 1。这意味着我们将跳过排序顺序中的第一条记录,并将结果限制为剩余结果中的 1 条记录。这里,我们假设所有员工都有唯一的工资。
109. What do you understand about the following in the context of DBMS: Primary key, Super key, Candidate key and Foreign key.
在 DBMS 的上下文中,你对以下内容有何理解:主键、超键、候选键和外键。
- 知识点: 数据库 (标签: interviewbit, walmart, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: 沃尔玛
- id: 69b37c9058d557c902bc96ba | 官方: 否 | 付费: 否
答案:
- Super Key: The Super Key is a collection of all the keys that help to uniquely identify rows in a table. This means that all columns in a table that are capable of uniquely identifying the table's other columns are called super keys.
- Candidate Key: An attribute or group of attributes that can uniquely identify a tuple such that no subset of it can uniquely identify a tuple, is known as a candidate key. A candidate key can be referred to as a subset of super keys. Among all the candidate keys, one key is chosen and referred to as the primary key.
- Primary Key: A primary key is basically one of the candidate keys. A primary key is a column or group of columns in a table that helps to uniquely identify each record in that table, such that no subset of it can uniquely identify each tuple. In a table, there can only be one primary key. In addition, the primary Key cannot have identical values in any two rows. A PRIMARY KEY (PK) constraint on a column or set of columns prevents null values or duplicates from appearing. There can only be one primary key constraint per table.
- Foreign key: The column in a table that points to the primary key of another table is known as a foreign key. For example - Every employee in a corporation is assigned to a specific department, and employee and department are two distinct entities. As a result, the department's information cannot be stored in the personnel table. That's why the primary key of one table is used to connect these two tables.
110. How do the commands DROP, TRUNCATE, and DELETE differ in SQL?
在 SQL 中,命令 DROP、TRUNCATE 和 DELETE 有何不同?
- 知识点: 数据库 (标签: interviewbit, wipro, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Wipro
- id: 69b37c9758d557c902bc9b59 | 官方: 否 | 付费: 否
答案:
| DROP | TRUNCATE | DELETE |
|---|---|---|
| DROP is used for deleting a database, table, or a view DROP 用于删除数据库、表或视图 | TRUNCATE is used for deleting all rows of a table TRUNCATE 用于删除表中的所有行 | DELETE can either delete all of the rows at once or one by one. i.e., we can use it according to our needs. DELETE 可以一次性删除所有行,也可以逐行删除。也就是说,我们可以根据需要使用它。 |
| No data can be rollbacked 数据无法回滚 | No data can be rollbacked 数据无法回滚 | Data can be rollbacked 数据可以回滚 |
| It is a Data Definition Language (DDL) command 它是数据定义语言(DDL)命令 | It is a Data Definition Language (DDL) command 它是数据定义语言(DDL)命令 | It is a Data Manipulation Language (DML) command. 它是数据操纵语言(DML)命令。 |
| It deletes the entire structure of the table. 它删除表的整个结构。 | It preserves the structure of the table. 它保留表的结构。 | It does not affect the structure of the table. 它不影响表的结构。 |
111. What is SQL Profiler?
什么是 SQL Profiler?
- 知识点: 数据库 (标签: interviewbit, wipro, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Wipro
- id: 69b37c9758d557c902bc9b5c | 官方: 否 | 付费: 否
答案:
SQL Server Profiler is a graphical user interface for SQL Trace (SQL Trace is a built-in SQL Server application that monitors and records database activity in SQL Server 6.5. This tool can show server activity, set filters to focus on the operations of specific users, applications, or workstations, and filter SQL commands) that helps in monitoring a Database Engine or Analysis Services instance. You can record and store information about each event to a file or table for subsequent analysis.
SQL Server Profiler 是 SQL Trace(SQL Trace 是 SQL Server 6.5 中内置的 SQL Server 应用程序,用于监视和记录数据库活动。此工具可以显示服务器活动、设置筛选器以聚焦特定用户、应用程序或工作站的操作,并筛选 SQL 命令)的图形用户界面,有助于监视数据库引擎或 Analysis Services 实例。你可以将每个事件的信息记录并存储到文件或表中,以便后续分析。
The SQL Profiler software allows us to track SQL Server connections and determine actions such as which SQL Scripts are executing, unsuccessful jobs, and so on. SQL databases and their environments are monitored, analyzed, troubleshooted, and tuned with this tool.
SQL Profiler 软件允许我们跟踪 SQL Server 连接并确定诸如正在执行哪些 SQL 脚本、失败的作业等操作。此工具用于监视、分析、排查和调优 SQL 数据库及其环境。
112. What are the advantages and disadvantages of indexing in DBMS?
在 DBMS 中索引的优缺点是什么?
- 知识点: 数据库 (标签: interviewbit, wipro, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Wipro
- id: 69b37c9858d557c902bc9b73 | 官方: 否 | 付费: 否
答案:
Indexing is a technique for improving the database performance by reducing the number of disc accesses needed when a query is run. It's a data structure strategy for finding and accessing data in a database rapidly.
索引是一种通过减少运行查询时所需的磁盘访问次数来提高数据库性能的技术。它是一种用于快速查找和访问数据库中数据的数据结构策略。
The following are some of the benefits of indexes: - An index allows data to be retrieved quickly.
以下是索引的一些优点: - 索引允许快速检索数据。
- When an index is used in a query, the performance usually improves dramatically.
- They're good for sorting. It is possible to eliminate the need for a post-fetch-sort procedure.
The index ensures that each record in the database is uniquely identified.
The cons of indexing are: - Inserts, updates, and deletes are all slowed down by indexes.索引的缺点如下: - 索引会减慢插入、更新和删除操作。
- Indexes take up a lot of space (this increases with the number of fields used and the length of the fields).
113. What is normalization, and why is it important in database design?
什么是规范化,为什么它在数据库设计中很重要?
- 知识点: 数据库 / 系统设计/架构 / UI/UX 设计 (主题: sql, system-design;标签: normalization, 1NF, 2NF, 3NF, data-integrity)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695b63eb2873cad90baba6d9 | 官方: 是 | 付费: 否
答案:
TL;DRNormalization organizes data to reduce redundancy and improve integrity by splitting tables and enforcing proper dependencies.
简而言之规范化通过拆分表并强制实施适当的依赖关系来组织数据,以减少冗余并提高完整性。
Why it matters- Reduces duplicate data
为什么重要 - 减少重复数据
- Improves data consistency
- Reduces update anomalies
Makes schema more maintainable
Common normal forms- 1NF: atomic columns, no repeating groups常见范式 - 1NF:原子列,无重复组
- 2NF: no partial dependency on composite key
- 3NF: no transitive dependency
114. 数据库索引(Database Indexing) 是如何工作的?
- 知识点: 数据库 (主题: sql;标签: database, index, where-clause, performance)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695ccbc31da5537956248f8f | 官方: 是 | 付费: 否
答案:
TL;DR数据库索引类似书本目录,能更快定位数据,减少扫描行/列数量,尤其在执行带 WHERE 条件查询时提升性能。
数据库索引类似于书本索引。就像书本索引能让我们快速找到某章节或信息,数据库索引也能帮助快速定位数据。当执行带有 WHERE 子句的查询时,它能减少需要检查的行或列数量,从而更快找到所需信息。这就是数据库索引的工作方式。
115. JDBC(Java数据库连接) 和 Hibernate(对象关系映射框架) 有什么区别?
- 知识点: 数据库 / 编程语言基础 (主题: java;标签: jdbc, hibernate, orm, java)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695ccbc41da5537956248fab | 官方: 是 | 付费: 否
答案:
TL;DR题目原文仅提供了对比图示。
116. 请根据提供的表结构(Table Schema),说明 Games / Players / Leaderboards / Friends 四张表(Tables)分别承担什么角色(Role),以及它们之间的关系(Relationship)是什么?
- 知识点: 数据库 / 系统设计/架构 / UI/UX 设计 (主题: sql, system-design;标签: sql-schema, foreign-key, relationships)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695df6661da553795635b2ba | 官方: 是 | 付费: 否
答案:
TL;DR这四张表分别用于存储游戏信息(Game Information)、玩家信息(Player Information)、玩家分数记录(排行榜记录)(Leaderboard Records)以及玩家之间的关注/好友关系(Follow/Friend Relationship),并通过外键(Foreign Key)形成关联。
表的职责(Table Responsibilities)- Games:存储游戏基础信息(game_id、name、created_at)。
- Players:存储玩家信息(player_id、name、email、profile_image、location等),并通过 game_id 外键关联到 Games。
- Leaderboards:存储排行榜分数记录(leaderboard_id、score、created_at、game_id、player_id),用于计算排名、Top N 等。
- Friends:存储玩家之间的关系(player_id ↔ player_id),用于好友圈排行榜。
关键关系(Key Relationships)- Games : Players = 1-to-many(一个游戏有多个玩家) - Games : Leaderboards = 1-to-many(一个游戏有多个榜单/记录)
- Players : Leaderboards = 1-to-many(一个玩家会产生多条分数记录)
- Friends 是关联实体,用于表达 follower-followee 或双向好友关系
117. 写一条 SQL(Structured Query Language)语句:查询某个玩家当月累计得分(示例:player_id=42)。
- 知识点: 数据库 (主题: sql;标签: sum, date-filter, sql)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695df6661da553795635b2c3 | 官方: 是 | 付费: 否
答案:
TL;DR使用 SUM(Summation Function)(score)聚合(Aggregation),并用时间条件(Time Condition)过滤当月数据。
SELECT sum(score)
SELECT sum(score)
FROM leaderboards
FROM leaderboards
WHERE player_id = '42' and created_at >= "2025-03-10";
WHERE player_id = '42' and created_at >= "2025-03-10";
118. 写一条 SQL(Structured Query Language)语句:计算并返回排行榜(Leaderboard)Top 10 玩家(按总分降序)。
- 知识点: 数据库 (主题: sql;标签: group-by, order-by, top-n)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695df6661da553795635b2c6 | 官方: 是 | 付费: 否
答案:
TL;DR通过 GROUP BY(Group By Clause)player_id 聚合总分,排序(Sorting)并限制 Top 10。
SELECT player_id, SUM(score) AS total
SELECT player_id, SUM(score) AS total
FROM leaderboards
FROM leaderboards
GROUP BY player_id
GROUP BY player_id
ORDER BY total DESC
ORDER BY total DESC
LIMIT 10;
LIMIT 10;
119. 如何使用 Redis(Remote Dictionary Server)Sorted Set(有序集合)查询排行榜(Leaderboard)Top 10(绝对排行榜)?请说明命令(Command)、参数含义(Parameter Meaning)以及排序方向(Sorting Direction)。
- 知识点: 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: data-structures, system-design;标签: zrevrange, top-n, descending, sorted-set)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695df7bb1da553795635d80f | 官方: 是 | 付费: 否
答案:
TL;DRTop 10 查询通常使用 ZREVRANGE,因为榜单按分数从高到低(descending)排列。start=0 表示第一名,stop=9 表示第十名。
核心命令(Core Command)redis> ZREVRANGE leaderboard 0 9参数解释(Parameter Explanation)- key:排行榜标识(Leaderboard Identifier),例如 leaderboard
- start:起始下标(0-based)
- stop:结束下标(包含)
排序方向(Sorting Direction)ZREVRANGE 中的 REV 表示反向(Reverse),即按 score(分数)从高到低返回成员列表(Member List),适合排行榜 Top N。
获取玩家元数据(Player Metadata)Top 10 的 player_id 取出后,可用 Redis Hash(哈希)的 HMGET 一次性获取多个玩家的名称、头像等 metadata(元数据)。
120. 如何从 Redis(Remote Dictionary Server)中查询某个玩家的分数(Score)和排名(Rank)?请写出相关命令(Command)并说明排名是如何计算的。
- 知识点: 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: data-structures, system-design;标签: zscore, zrevrank, rank, sorted-set)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695df7bb1da553795635d812 | 官方: 是 | 付费: 否
答案:
TL;DR玩家分数用 ZSCORE 获取,玩家排名用 ZREVRANK 获取。ZREVRANK 返回的是0-based(零基)排名:分数最高的玩家 rank=0。
获取分数(Get Score)ZSCOREredis> ZSCORE leaderboard "one"
"3"返回值:该 member(成员)的 score(分数)(字符串)。
获取排名:ZREVRANK(反向排名命令)redis> ZREVRANK leaderboard "one"
(integer) 2返回值:该 member(成员)在降序榜单中的排名(0-based)。
排名含义- rank(排名)=0 表示第一名(最高分)
- rank=1 表示第二名
- 以此类推
补充:元数据查询如需玩家姓名、头像等,可配合 Redis Hash(哈希)或关系型数据库查询 player metadata(玩家元数据)。
121. 排行榜系统中如果出现分数相同(tie,平局),应该如何决定胜出者?如何获取 tie-breaker(决胜规则)所需的时间戳?
- 知识点: 数据库 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: tie-breaker, timestamp, ranking, redis-hash)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695df7bb1da553795635d818 | 官方: 是 | 付费: 否
答案:
TL;DR当分数相同,常见规则是时间戳更早者排名更高(先达到该分数的人胜)。时间戳可以存储在 Redis Hash(哈希)(player metadata,玩家元数据)或关系型数据库中,并在展示排行榜时进行二次排序/比较。
常见 Tie-breaker(决胜规则)规则- Older timestamp wins(较早时间戳胜出):先达到该分数的人排名更高。
- 其他可选规则:玩家等级、胜场数、最近活跃时间等(取决于业务)。
时间戳来源- Redis Hash(哈希):存储玩家最近一次分数更新时间 updated_at(更新时间戳) - Relational DB:存储每次得分记录或最新更新时间
实现建议- Sorted Set(有序集合)用 score(分数)排序;tie(平局)时额外读取 timestamp(时间戳)做二次比较。 - 避免每次查询都大量读 DB:可将 timestamp 缓存在 Redis Hash 中。
122. 为什么历史排行榜适合使用 Redis Streams(流)存储?它支持哪些查询能力?
- 知识点: 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: data-structures, system-design;标签: redis-streams, historical-data, pagination, range-query)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695dfa151da5537956361dbd | 官方: 是 | 付费: 否
答案:
TL;DRRedis Streams(流)可以以较低内存开销存储历史排行榜事件/快照,并支持范围查询(range queries)用于分页或回溯某个时间点的游戏记录。
为什么适合历史榜单- 低内存开销:相比完整复制 Sorted Set(有序集合),Streams(流)更适合事件流或历史快照。
- 顺序追加:天然适合记录“某时刻的榜单变化/结果”。
- 可分页:支持按 ID 范围读取。
支持的查询- Range Query(范围查询):根据 stream entry id(流条目标识)范围查询,便于分页历史榜单。 - 时间回溯:检查“过去某个时间点”发生的比赛/榜单变化。
123. 请解释 Redis Sorted Set(有序集合)的原理与在排行榜中的应用:它的 key(键)、member(成员)、score(分数)分别是什么?常见命令的时间复杂度如何?
- 知识点: 数据库 / 算法与数据结构 (主题: data-structures;标签: sorted-set, leaderboard, time-complexity, zadd, zrevrange, zrevrank)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695dfa151da5537956361dde | 官方: 是 | 付费: 否
答案:
TL;DRRedis Sorted Set(有序集合)是 member(成员)→ score(分数)的映射结构,系统按 score(分数)自动排序,非常适合做排行榜。排行榜中常见:key(键)表示榜单 ID,member(成员)是 player_id(玩家标识),score(分数)是玩家总分。大多数操作具备 O(log(n)) 级别复杂度。
核心概念- key:排行榜(Leaderboard)标识(例如某个游戏/周期的榜单)。
- member:唯一成员(通常是 player_id)。
- score:用于排序的数值(玩家分数)。
常见命令与复杂度- ZADD:新增玩家,O(log(n)) - ZINCRBY:加分,O(log(n))
- ZSCORE:查分数,O(1)
- ZREVRANK:查排名,O(log(n))
- ZREVRANGE:取 Top m,O(log(n)+m)
- ZREM:移除成员,O(k*log(n))
其中 n 是集合元素数,k 是移除数量,m 是返回数量。
124. 请总结:为什么小规模排行榜可以使用关系型数据库,但互联网规模的实时排行榜通常需要 Redis Sorted Set?
- 知识点: 数据库 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: summary, rdbms-vs-redis, real-time, sorted-set)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695dfa151da5537956361e5a | 官方: 是 | 付费: 否
答案:
TL;DR小规模实时榜单可以用关系型数据库实现,但当玩家规模达到互联网级别,关系型数据库在实时排序、排名计算与高并发更新上会遇到性能与扩展瓶颈;Redis Sorted Set 由于内存存储 + 自动排序 + 低复杂度排名查询,更适合大规模实时 leaderboard。
关系型数据库适用场景- 并发较低(例如 <100k 同时在线)。
- 更需要复杂分析查询、强一致事务。
互联网规模的挑战- 实时 rank 计算成本高。 - 高频写入 + 排序负担大。
- 查询延迟显著上升。
Redis Sorted Set 的优势- 内存存储,延迟低。 - 按 score 自动排序,TopN/rank 查询快速。
- 主要操作具备 O(log(n)) 或 O(1) 复杂度。
125. Scheduling Service 如何从 JobSchedulesTable 选取到期任务并推入队列?为什么需要按 next_run_time 分区或索引?
- 知识点: 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: system-design, sql;标签: scheduler, next_run_time, partitioning, indexing, job-queue)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695dfcb71da553795636538e | 官方: 是 | 付费: 否
答案:
TL;DRScheduling Service 会周期性(例如每分钟)查询 schedules 表中 next_run_time 等于当前时间片的记录,将到期任务推入分布式队列(Distributed Queue),并将 Job Table 状态更新为 SCHEDULED。由于查询的过滤条件是 next_run_time,应按该列进行分区或建立索引,以便高效检索某一分钟内的所有任务。
示例查询SELECT * FROM JobSchedulesTable WHERE next_run_time = 1726110000;为什么按 next_run_time 分区/索引- 调度器核心读路径是按 next_run_time 精确过滤。
- 分区或索引可以避免全表扫描,提升吞吐与降低延迟。
- 在高峰期(例如某分钟 50,000 jobs)尤其关键。
后续动作- 将 due jobs 推送到 Distributed Job Queue(Kafka/RabbitMQ)。 - 更新 Job Table 状态为 SCHEDULED。
126. 在任务调度系统中如何选择 SQL vs NoSQL?在“百万级任务/天、读写接近、固定 schema、不需要 ACID 和复杂 join”的前提下,为什么 NoSQL(DynamoDB/Cassandra)可能更合适?
- 知识点: 数据库 / DevOps/云 / 系统设计/架构 / UI/UX 设计 (主题: system-design, sql, aws;标签: sql-vs-nosql, dynamodb, cassandra, high-throughput, structured-data)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695dfcb71da55379563653a1 | 官方: 是 | 付费: 否
答案:
TL;DR在百万级 jobs/day、读写吞吐都很高且 schema 固定的情况下,如果不需要 ACID 或复杂 join,那么 NoSQL(如 DynamoDB/Cassandra)通常在水平扩展与高吞吐读写方面更有优势,更适合承载大规模任务元数据与状态更新。
关键条件- 每天存储百万级 jobs
- 读写量接近,吞吐高
- 数据结构固定
- 不需要 ACID 或复杂 join
为什么 NoSQL 更适合- 高吞吐:更擅长支撑大量写入与状态更新。 - 易扩展:通过分区实现水平扩展。
- 更匹配访问模式:以 key-based 读写为主的状态查询和更新。
示例选择- DynamoDB:托管、可扩展、适合高并发 key-value(键值)模型。 - Cassandra:分布式、高吞吐写入能力强。
127. 通知系统为什么需要混合存储(SQL + NoSQL + Blob Storage(对象存储))?不同数据分别适合存在哪里?
- 知识点: 数据库 / DevOps/云 / 系统设计/架构 / UI/UX 设计 (主题: system-design, sql, aws;标签: hybrid-storage, sql, nosql, s3, notification-logs, user-preferences, attachments)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695dfe121da5537956367912 | 官方: 是 | 付费: 否
答案:
TL;DR通知系统的数据类型多样:偏好数据量大、按 userId(用户标识)访问;日志需要结构化查询与审计;附件是大文件。通常采用混合存储:SQL 存日志/投递状态,NoSQL 存用户偏好/限流计数,S3(对象存储服务)存附件和大对象。
数据分类与推荐存储- Transactional Data(事务型数据)(SQL):通知日志、投递状态、审计与报表查询(PostgreSQL/MySQL)。
- User Preferences(NoSQL):用户偏好、opt-out、限流计数等(DynamoDB/MongoDB)。
- Blob Storage(Object Store):附件、图片、PDF 等大对象(Amazon S3)。
为什么要混合- 访问模式不同:偏好是高频 key-based(基于键的)访问;日志是分析/审计查询;附件是大文件。 - 成本与性能更优:大对象不适合塞进数据库。
128. 微服务(Microservices)中一个常见错误是服务之间直接访问彼此的数据库,为什么这是问题?正确做法是什么?
- 知识点: 数据库 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: database-per-service, api-boundary, encapsulation, schema-change)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695e02941da553795636f50f | 官方: 是 | 付费: 否
答案:
TL;DR微服务之间直接访问他人数据库会导致边界失控:谁依赖了哪些数据无法追踪,数据库 schema(模式)变更会引发级联破坏,并阻碍服务独立演进。正确做法是通过服务 API(应用程序接口)获取数据,由数据拥有者负责封装与演进。
为什么直接访问数据库是问题- 失去封装:数据库细节暴露,服务边界被打穿。
- 变更风险大:schema 变化可能悄悄破坏其他服务。
- 难以独立部署:数据依赖耦合导致必须协调发布。
- 测试与治理困难:无法通过 API contract 验证依赖关系。
正确做法- Service 2(服务2)通过 Service 1(服务1)的 API 获取数据,而不是读 Service 1 的 DB(数据库)。 - 由数据拥有服务负责对外 contract,其他服务只依赖 API。
- 保证 API 测试通过即可安全演进 schema。
129. 对比 Couchbase 和 MongoDB 的区别
- 知识点: 数据库 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design;标签: Couchbase, MongoDB, scalability, consistency, uptime)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695f6c1ad6221b0fef04c70e | 官方: 是 | 付费: 否
答案:
核心答案Couchbase 和 MongoDB 都是 NoSQL(非关系型)数据库,但在扩展方式、一致性策略和可用性维护上存在差异。
对比维度- Scalability(可扩展性):Couchbase 支持更无缝的扩展;MongoDB 扩展通常需要更多步骤(如分片规划、迁移与维护)。
- Consistency(一致性):Couchbase 强一致性能力更突出;MongoDB 默认配置下通常更偏最终一致性或可调一致性策略。
- Uptime(持续在线):Couchbase 主打持续在线、减少停机维护;MongoDB 在某些运维/升级场景可能需要维护窗口。
130. 什么是 Azure SQL 数据库(SQL Azure database)?它有哪些特性?
- 知识点: 数据库 / DevOps/云 / 系统设计/架构 / UI/UX 设计 (主题: sql, system-design;标签: Azure SQL, PaaS, Backup, RPO)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 6960b0520e32007ea0d0d202 | 官方: 是 | 付费: 否
答案:
核心答案Azure SQL 数据库(原文称 SQL Azure database)是一种把数据库托管在云端的方式,属于 Azure 的 PaaS(平台即服务)数据库服务。它具备类似 SQL Server 的能力特性(原文提到):高可用性、可扩展性与安全性。
备份与恢复(原文要点)- 对每个活动数据库进行自动备份。
- 持续执行备份并进行异地复制(geo-replication),以支持约 1 小时 RPO(恢复点目标,原文表述)。
补充:面试中可进一步说明 Azure SQL 还常见提供自动补丁、弹性伸缩、监控告警、以及多种高可用方案(如主动异地复制等)。
131. Azure Table Storage 与 Azure SQL Service(Azure SQL Database)有什么区别?
- 知识点: 数据库 / DevOps/云 / 系统设计/架构 / UI/UX 设计 (主题: sql, system-design;标签: Table Storage, Azure SQL, NoSQL vs Relational)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 6960b0520e32007ea0d0d2d3 | 官方: 是 | 付费: 否
答案:
核心答案原文给出的核心差异:
- Azure SQL:使用关系型(relational)存储结构,适合需要 SQL、关系、事务、复杂查询的场景。
- Azure Table Storage:属于非关系/键值(NoSQL key-value)与“集中式结构化数据”存储(原文描述),不强调关系模型。
补充:Table Storage 通常更适合海量、schema(模式) 灵活、按 key(键) 快速读写的场景;Azure SQL 更适合强一致事务(Transaction)、复杂查询与报表分析等场景。
132. 如果你的 RDS(Relational Database Service) 是 Multi-AZ(多可用区) 部署,standby DB(备用数据库) 实例能和 primary(主实例) 一起对外提供读写吗?
- 知识点: 数据库 / DevOps/云 (主题: aws;标签: rds, multi-az, standby, read-replica)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 6960bd800e32007ea0d20b7b | 官方: 是 | 付费: 否
答案:
核心答案不能。Multi-AZ 的 standby 是用于故障切换(Failover)的,被设计为不可直接用作读写流量承载。如果你想做读扩展,应使用 Read Replica(只读副本)。
133. Explain the difference between a SQL index and a primary key.
解释 SQL 索引和主键之间的区别。
- 知识点: 数据库 (主题: sql, database)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: backend
- id: 6964bf99a9243c30c8767be6 | 官方: 是 | 付费: 否
答案:
A primary key uniquely identifies a row, while an index is a data structure to speed up lookups. A primary key creates a unique index by default, but you can have many non-unique indexes on a table.
主键唯一标识一行,而索引是一种用于加速查找的数据结构。主键默认会创建一个唯一索引,但一个表上可以有多个非唯一索引。
134. 解释什么是数据库管理系统(DBMS,Database Management System)?与传统文件系统相比有什么优势?
- 知识点: 数据库 / 行为与软技能 (主题: database;标签: DBMS)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: backend
- 公司: IBM
- id: 69703d5d120fcc15912fa69e | 官方: 是 | 付费: 否
答案:
A database management system (or DBMS) is essentially just a computerized data storage system.
数据库管理系统(或 DBMS)本质上只是一个计算机化的数据存储系统。
- Better Data Management
- Data Security
- Reduced Data Inconsistency
- Faster data access
135. 数据库事务(Transaction) 的 ACID(原子性、一致性、隔离性、持久性) 特性是什么?请解释各项含义。
- 知识点: 数据库 / 行为与软技能 (主题: database, sql;标签: ACID)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: backend
- 公司: IBM
- id: 69703d5d120fcc15912fa6a7 | 官方: 是 | 付费: 否
答案:
Every transaction in a SQL Database must adhere to a set of guidelines. ACID attributes relate to these characteristics.
SQL 数据库中的每个事务都必须遵循一组准则。ACID 属性与这些特性相关。
- Atomicity
- Consistency
- Isolation
- Durability
136. 解释 MySQL 索引(Index):主键索引(Primary Key Index) 与二级索引(Secondary Index) 的区别,以及它们在 InnoDB 中如何工作。
- 知识点: 数据库 (主题: mysql, database;标签: MySQL, Index, InnoDB)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: backend
- 公司: IBM
- id: 69704120120fcc1591300c03 | 官方: 是 | 付费: 否
答案:
答案InnoDB 主键索引通常是聚簇索引(Clustered Index):叶子节点存放整行数据;按主键有序。
二级索引叶子节点存主键值(以及索引列),查到后再“回表(Table Lookup)”用主键去聚簇索引取整行。
优化点:尽量让查询走覆盖索引(Covering Index)(只用二级索引就能返回所需列),减少回表;合理选择主键与联合索引(Composite Index) 顺序。
AnswerInnoDB primary key is typically clustered: leaf pages store full rows, ordered by PK.
回答InnoDB 主键通常是聚簇的:叶子页存储完整行,并按主键排序。
Secondary index leaves store the PK (and indexed columns). After locating a match, InnoDB may do a PK lookup (back-to-table) to fetch the full row.
二级索引叶子存储主键(以及被索引的列)。在定位到匹配项之后,InnoDB 可能会进行一次主键查找(回表)以获取完整行。
Optimize by using covering indexes to avoid extra lookups; choose PK and composite index order carefully.
通过使用覆盖索引来避免额外查找以进行优化;请谨慎选择主键和复合索引顺序。
137. 如何用 Redis 解决缓存穿透(Cache Penetration)?请给出至少 2 种方案并说明优缺点。
- 知识点: 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 (主题: redis, database, system-design;标签: Redis, Cache Penetration, Bloom Filter)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: backend
- 公司: IBM
- id: 69704120120fcc1591300c07 | 官方: 是 | 付费: 否
答案:
答案缓存穿透:大量请求查询“必定不存在”的 key(键),绕过缓存直打 DB(数据库)。
方案 1:缓存空值(Negative Caching),为不存在结果设置短 TTL(Time To Live,生存时间)。优点简单;缺点要注意空值缓存雪崩与误缓存。
方案 2:布隆过滤器(Bloom Filter)前置拦截。优点减压明显;缺点有误判率、需要维护/重建。
方案 3:参数校验 + 限流/熔断(保护 DB)。
AnswerCache penetration: many requests for non-existent keys bypass cache and hit DB.
回答缓存穿透:大量针对不存在键的请求绕过缓存并打到数据库。
Approach 1: cache null/negative results with short TTL. Simple, but watch TTL tuning and misuse.
方法 1:缓存空值/负结果,并设置较短 TTL。简单,但要注意 TTL 调优和误用。
Approach 2: Bloom filter in front. Big DB relief, but has false positives and needs maintenance.
方法 2:在前面加布隆过滤器。能大幅减轻数据库压力,但存在误报且需要维护。
Approach 3: validation + rate limiting/circuit breaker to protect DB.
方法 3:校验 + 限流/熔断以保护数据库。
138. 什么是布隆过滤器(Bloom Filter)?它适合解决什么问题?有什么局限?
- 知识点: 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: algorithms, system-design, redis;标签: Bloom Filter, Probabilistic)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: backend
- 公司: IBM
- id: 69704120120fcc1591300c0b | 官方: 是 | 付费: 否
答案:
答案布隆过滤器是一种概率型数据结构(Probabilistic Data Structure),用多个哈希函数(Hash Function)把元素映射到位数组(Bit Array),判断“可能存在/一定不存在”。
适合:去重、快速判定不存在(如缓存穿透前置过滤、海量 URL/用户判重)。
局限:有误判(False Positive)但无漏判(False Negative);标准 Bloom 不支持删除(可用 Counting Bloom 变体)。
AnswerA Bloom filter is a probabilistic structure using multiple hashes over a bit array to answer “possibly present” or “definitely not present”.
回答布隆过滤器是一种概率性结构,在位数组上使用多个哈希来回答“可能存在”或“肯定不存在”。
Good for deduplication and fast negative checks (e.g., cache penetration filtering, massive membership tests).
适用于去重和快速否定检查(例如,缓存穿透过滤、海量成员测试)。
Limitations: false positives exist; no false negatives. Standard Bloom doesn’t support deletion (Counting Bloom can).
局限性:存在假阳性;无假阴性。标准布隆过滤器不支持删除(计数布隆过滤器可以)。
139. Spark 在 Databricks 中是如何被使用的?
- 知识点: 数据库 / 数据工程与数据科学/AI (主题: databricks, spark, sql, streaming, mllib;标签: Databricks, Spark)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 69708ce1120fcc15913766b6 | 官方: 否 | 付费: 否
答案:
答案Databricks 以 Apache Spark 为核心计算引擎,负责分布式 ETL(Extract, Transform, Load)、批处理与交互式分析。
常见用法包括:用 DataFrame/Spark SQL 做结构化数据处理;用 Structured Streaming 做流处理;用 MLlib/第三方库训练模型;并通过作业调度(Job Scheduling)把这些计算工作流产品化。
140. 你能解释 Spark SQL 和 DataFrame API 之间的区别吗?
- 知识点: 数据库 / 数据工程与数据科学/AI (主题: sql, spark, databricks;标签: Databricks, Evaluation)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 69708ce3120fcc159137692f | 官方: 否 | 付费: 否
答案:
答案两者都受 Catalyst 优化:Spark SQL 用 SQL 语法表达;DataFrame 用编程 API 表达,便于模块化与复用。
SQL 更适合分析型查询;DataFrame 更适合复杂工程流程;实际项目常混合使用。
141. 在分布式数据处理环境中,您将如何处理倾斜数据?
- 知识点: 数据库 / 数据工程与数据科学/AI (主题: sql, spark, databricks;标签: Databricks, Evaluation)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 69708ce8120fcc15913772fd | 官方: 否 | 付费: 否
答案:
答案先识别热点 key(统计+Spark UI),再用 salting、拆分热点 key、两阶段聚合、广播 join 或 AQE skew join 优化。
最后用基准测试验证是否减少长尾 task 与 shuffle 开销。
142. 您能否描述一下您编写的复杂 SQL 查询并解释其用途?
- 知识点: 数据库 / 数据工程与数据科学/AI (主题: sql, spark, databricks;标签: Databricks, Evaluation)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 69708ce8120fcc159137733b | 官方: 否 | 付费: 否
答案:
答案示例:多表 join + 窗口函数(Window Function)计算用户 30 天滚动留存与 cohort,并将结果写入分区表供仪表盘使用。
关键在于:清晰的 CTE(Common Table Expression)结构、去重逻辑、执行计划(Execution Plan)验证(避免过度 shuffle),以及对输出的回归校验。
143. What are DDL and DML commands in SQL?
SQL 中的 DDL 和 DML 命令是什么?
- 知识点: 数据库 (标签: interviewbit, infosys, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Infosys
- id: 69b37b5758d557c902baf35e | 官方: 否 | 付费: 否
答案:
- DDL refers to Data Definition Language. DDL commands are used to define database schema i.e., to create and modify the database object structure in the database. Examples are CREATE, ALTER, DROP, TRUNCATE, etc.
- DML refers to Data Manipulation Language. DML commands are used to manipulate the data within the database. Examples are: INSERT, UPDATE, DELETE.
144. Why indexing in SQL is useful ?
为什么 SQL 中的索引很有用?
- 知识点: 数据库 (标签: interviewbit, infosys, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Infosys
- id: 69b37b5758d557c902baf368 | 官方: 否 | 付费: 否
答案:
A SQL index is a quick lookup table that helps to find records that are frequently searched by a user. An index is fast, small, and optimized for quick look-ups. It is useful for establishing a connection between the relational tables, searching large tables, and fast retrieval of data from a database.
SQL 索引是一种快速查找表,有助于查找用户经常搜索的记录。索引快速、小巧,并针对快速查找进行了优化。它对于建立关系表之间的连接、搜索大型表以及从数据库中快速检索数据非常有用。
145. What is the left outer join and the right outer join in SQL?
SQL 中的左外连接和右外连接是什么?
- 知识点: 数据库 (标签: interviewbit, infosys, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Infosys
- id: 69b37b5858d557c902baf383 | 官方: 否 | 付费: 否
答案:
- Left outer join: It returns an entire set of records from the left table along with the matched records from the right table.
- Right outer join: It returns an entire set of records from the right table along with the matched records from the left table.
146. Write a query to find out the student with the 2nd rank from the table STUDENTS_DETAILS.
编写一个查询,从表 STUDENTS_DETAILS 中找出排名第 2 的学生。
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0958d557c902bb6c26 | 官方: 否 | 付费: 否
答案:
Written below is a query to find out the student with the 2nd rank from the table STUDENTS_DETAILS:-
下面编写的是一个查询,用于从表 STUDENTS_DETAILS 中找出排名第 2 的学生:-
SELECT TOP 1 rank FROM (SELECT TOP 2 rank FROM STUDENT_DETAILS ORDER BY rank DESC) AS STUDENT ORDER BY rank ASC;
SELECT TOP 1 rank FROM (SELECT TOP 2 rank FROM STUDENT_DETAILS ORDER BY rank DESC) AS STUDENT ORDER BY rank ASC;
147. State the usage of the ROWS option in the IMP command.
说明 IMP 命令中 ROWS 选项的用法。
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0958d557c902bb6c29 | 官方: 否 | 付费: 否
答案:
The ROWS option in the IMP command can be used to indicate whether the table rows should be imported or not.
IMP 命令中的 ROWS 选项可用于指示是否应导入表行。
148. State the usage of the IGNORE option in the IMP command.
说明 IMP 命令中 IGNORE 选项的用法。
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0958d557c902bb6c30 | 官方: 否 | 付费: 否
答案:
The IGNORE option in the IMP command can be used to understand how object creation errors should be handled.
IMP 命令中的 IGNORE 选项可用于理解应如何处理对象创建错误。
- Data Science
- All Events
- My Events
149. State the usage of the INDEXES option in the IMP command.
说明 IMP 命令中 INDEXES 选项的用法。
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0958d557c902bb6c33 | 官方: 否 | 付费: 否
答案:
The INDEXES option in the IMP command can be used to determine whether indexes are imported or not.
IMP 命令中的 INDEXES 选项可用于确定是否导入索引。
150. Give an example to convert a date to a char in Oracle.
给出一个在 Oracle 中将日期转换为字符的示例。
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0958d557c902bb6c36 | 官方: 否 | 付费: 否
答案:
The INDEXES option in the IMP command can be used to determine whether indexes are imported or not.
IMP 命令中的 INDEXES 选项可用于确定是否导入索引。
151. Give an example to convert a string to a date in Oracle
举一个在 Oracle 中将字符串转换为日期的例子
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0958d557c902bb6c3d | 官方: 否 | 付费: 否
答案:
SELECT to_date ('2021-07-12', 'YYYY/MM/DD') FROM dual;
SELECT to_date ('2021-07-12', 'YYYY/MM/DD') FROM dual;
As we can see from the above example, the to_date() function can be used to convert a string to a date in Oracle.
从上面的例子可以看出,to_date() 函数可用于在 Oracle 中将字符串转换为日期。
152. Which function can be used to find the current date and time of the operating system on which the Oracle database is running?
哪个函数可用于查找运行 Oracle 数据库的操作系统的当前日期和时间?
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: coding
- 分类: general
- 公司: Oracle
- id: 69b37c0958d557c902bb6c40 | 官方: 否 | 付费: 否
答案:
The SYSDATE() function can be used to find the current date and time of the operating system on which the Oracle database is running. The example given below shows how to do the same:-
SYSDATE() 函数可用于查找运行 Oracle 数据库的操作系统的当前日期和时间。下面给出的示例展示了如何做到这一点:-
SELECT TO_CHAR (SYSDATE, 'YYYY-MM-DD HH24:MI:SS') "Current Date:" FROM DUAL;
SELECT TO_CHAR (SYSDATE, 'YYYY-MM-DD HH24:MI:SS') "Current Date:" FROM DUAL;
153. Explain actual parameters with an example.
举例说明实际参数。
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0958d557c902bb6c43 | 官方: 否 | 付费: 否
答案:
Actual parameters are defined as the variables or expressions referenced in the parameter list of a subprogram. An example of a procedure call that lists two actual parameters named empNumber and amount is as follows:-
实际参数被定义为在子程序的参数列表中引用的变量或表达式。一个过程调用的示例列出了两个名为 empNumber 和 amount 的实际参数,如下所示:-
updateSalary(empNumber,amount);
updateSalary(empNumber,amount);
154. Explain formal parameters with an example.
举例说明形式参数。
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0958d557c902bb6c46 | 官方: 否 | 付费: 否
答案:
Formal parameters can be defined as variables declared in a subprogram specification and referenced in the subprogram body. An example of a procedure that declares two formal parameters named empID and amount: is as follows:-
形式参数可以定义为在子程序规范中声明并在子程序体中引用的变量。一个声明了两个名为 empID 和 amount 的形式参数的过程示例如下:-
PROCEDURE updateSalary(empID INTEGER, amount REAL) IS currentSalary REAL;
PROCEDURE updateSalary(empID INTEGER, amount REAL) IS currentSalary REAL;
Successful Tech Career for FREE!
免费开启成功的科技职业生涯!
Successful Tech Career!
成功的技术职业生涯!
Interview Process
面试流程
CTC & Designation
CTC与职位级别
Projects on the Job
工作项目
Referral System
推荐系统
Try It Out
试试看
2 Lakh+ Roadmaps Created
已生成20万+职业规划
155. Write a query to find the average salary of employees from the Emp Oracle Table.
编写一个查询,从Emp Oracle表中找出员工的平均工资。
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0958d557c902bb6c49 | 官方: 否 | 付费: 否
答案:
A query to find the average salary of employees from the Emp Oracle Table is given below:-
下面给出了一个从Emp Oracle表中找出员工平均工资的查询:-
SELECT AVG(SALARY) FROM EMP GROUP BY SALARY;
SELECT AVG(SALARY) FROM EMP GROUP BY SALARY;
156. Write a query to list the duplicate values in an Oracle table.
编写一个查询,列出Oracle表中的重复值。
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0958d557c902bb6c4c | 官方: 否 | 付费: 否
答案:
Written below is a query to list the duplicate values in an Oracle table:-
下面写的是一个列出Oracle表中重复值的查询:-
SELECT NAME, COUNT (NAME) FROM EMPLOYEE GROUP BY NAME HAVING COUNT (NAME) > 1;
SELECT NAME, COUNT (NAME) FROM EMPLOYEE GROUP BY NAME HAVING COUNT (NAME) > 1;
157. State the usage of the GRANT option in the IMP command.
说明IMP命令中GRANT选项的用途。
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0958d557c902bb6c4f | 官方: 否 | 付费: 否
答案:
The GRANT option in the IMP command can be used to import object grants.
IMP命令中的GRANT选项可用于导入对象授权。
158. Illustrate the use of the TRANSLATE function with an example.
用一个示例说明 TRANSLATE 函数的用法。
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: coding
- 分类: general
- 公司: Oracle
- id: 69b37c0958d557c902bb6c52 | 官方: 否 | 付费: 否
答案:
The TRANSLATE function of Oracle is used for replacing a sequence of characters in a string with some other set of characters. The TRANSLATE function replaces a single character at a time. Let us take a look at an example of translating the string "ROLL41" to "RAMM42" with the help of the TRANSLATE function.
Oracle 的 TRANSLATE 函数用于将字符串中的一系列字符替换为另一组字符。TRANSLATE 函数每次替换一个字符。让我们看一个借助 TRANSLATE 函数将字符串 "ROLL41" 转换为 "RAMM42" 的示例。
TRANSLATE("ROLL41", "OL1", "AM2");
TRANSLATE("ROLL41", "OL1", "AM2");
159. Illustrate the use of the REPLACE function with an example.
用一个示例说明 REPLACE 函数的用法。
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: coding
- 分类: general
- 公司: Oracle
- id: 69b37c0958d557c902bb6c56 | 官方: 否 | 付费: 否
答案:
The REPLACE function of Oracle is used for replacing a sequence of characters in a string with some other set of characters. Let us take a look at an example to translate the string "R12S121" to "R34S341" with the help of the REPLACE function.
Oracle 的 REPLACE 函数用于将字符串中的一系列字符替换为另一组字符。让我们看一个借助 REPLACE 函数将字符串 "R12S121" 转换为 "R34S341" 的示例。
REPLACE("R12S121", "12", "34");
REPLACE("R12S121", "12", "34");
Note that every occurrence of the substring "12" is replaced by the substring "34".
注意,子字符串 "12" 的每一次出现都会被替换为子字符串 "34"。
Recommended Resources
推荐资源
- SQL Interview Questions
- DBMS Interview Questions
160. What do you understand about the memory layers that are in the Oracle shared pool?
你对 Oracle 共享池中的内存层了解多少?
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6c5a | 官方: 否 | 付费: 否
答案:
There are two memory layers in the Oracle shared pool:- - Library Cache - The information about the SQL statements that were parsed, data about cursors, and any plan data that might be present is present in the Library Cache.
Oracle 共享池中有两个内存层:- - 库缓存 - 已解析的 SQL 语句信息、游标数据以及可能存在的任何计划数据都存在于库缓存中。
- Data Dictionary Cache - The Data Dictionary Cache layer contains information about the accounts of the users, their privileges, and information about segments.
161. List the various components of the physical database structure of an Oracle database.
列出 Oracle 数据库物理数据库结构的各个组件。
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6c5d | 官方: 否 | 付费: 否
答案:
The different components of the physical database structure of an Oracle database are listed below:- - Greater than equal to two redo log files.
Oracle 数据库物理数据库结构的各个组件如下所示:- - 大于等于两个重做日志文件。
- Greater than equal to one data file.
- Greater than equal to one control file.
162. The Oracle database has been developed using which language?
Oracle 数据库是使用哪种语言开发的?
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6c61 | 官方: 否 | 付费: 否
答案:
The C language was used to develop the Oracle database.
Oracle 数据库是使用 C 语言开发的。
163. What is the logical storage structure of Oracle? List the main components of the logical database structure in the Oracle database.
Oracle 的逻辑存储结构是什么?列出 Oracle 数据库中逻辑数据库结构的主要组件。
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6c67 | 官方: 否 | 付费: 否
答案:
The Oracle Database allocates logical space for all data in the database in addition to the physical files. The logical units of database space allocation are data blocks, extents, segments, and tablespaces. At a physical level, the data is stored in data files on a disk. The data in the data files are stored in operating system blocks.
除了物理文件之外,Oracle 数据库还为数据库中的所有数据分配逻辑空间。数据库空间分配的逻辑单元是数据块、区、段和表空间。在物理层面上,数据存储在磁盘上的数据文件中。数据文件中的数据存储在操作系统块中。
There are two main components in the logical database structure of the Oracle database:-
Oracle 数据库的逻辑数据库结构中有两个主要组件:-
Tablespaces: The basic storage allocation in an Oracle database is a tablespace. Each tablespace is composed of one or more physical (operating system) files. The SYSTEM tablespace is used to create each and every database. Other tablespaces are created by the Database Administrator. 2. Database's schema objects: A schema in Oracle is similar to an account or a username. Each object in the database is owned by a schema. Every Oracle database is created with two initial schemas: SYS, which is used to store the data dictionary, and SYSTEM, which often stores some data dictionary extensions as well as critical tables for other tools. Other schemas are created by the DBA. Each schema can be granted quotas in any tablespace.
- 表空间:Oracle 数据库中的基本存储分配是表空间。每个表空间由一个或多个物理(操作系统)文件组成。SYSTEM 表空间用于创建每一个数据库。其他表空间由数据库管理员创建。 2. 数据库的模式对象:Oracle 中的模式类似于账户或用户名。数据库中的每个对象都归某个模式所有。每个 Oracle 数据库在创建时都会有两个初始模式:SYS,用于存储数据字典;以及 SYSTEM,通常存储一些数据字典扩展以及其他工具所需的关键表。其他模式由 DBA 创建。每个模式都可以在任何表空间中被授予配额。
164. Define a tablespace in context with the Oracle database.
结合 Oracle 数据库的上下文定义表空间。
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6c6a | 官方: 否 | 付费: 否
答案:
The Logical Storage Unit of an Oracle database is called a tablespace. It is nothing but a set of related logical structures. Tablespace groups relate the logical structures of the database together. Logically, the data is stored in the tablespaces in Oracle and physically, the data is stored in the datafiles associated with the respective tablespaces.
Oracle 数据库的逻辑存储单元称为表空间。它不过是一组相关的逻辑结构。表空间组将数据库的逻辑结构关联在一起。在逻辑上,数据在 Oracle 中存储在表空间中;在物理上,数据存储在与其各自表空间关联的数据文件中。
165. List the default tablespaces of Oracle.
列出 Oracle 的默认表空间。
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6c6d | 官方: 否 | 付费: 否
答案:
The default tablespaces of Oracle are as follows:-
Oracle 的默认表空间如下:-
The SYSTEM and SYSAUX tablespaces - These store system-generated objects such as data dictionary tables in them. One should not store any object in these tablespaces. 2. The USERS tablespace - It is used for ad-hoc users. 3. The UNDOTBS1 tablespace - Is used for holding the undo data. 4. The TEMP tablespace - It is the temporary tablespace that is used for storing intermediate results of sorting, hashing, and large object processing operations.
- SYSTEM 和 SYSAUX 表空间 - 这些表空间存储系统生成的对象,例如其中的数据字典表。不应在这些表空间中存储任何对象。 2. USERS 表空间 - 它用于临时用户。 3. UNDOTBS1 表空间 - 用于保存撤销数据。 4. TEMP 表空间 - 它是临时表空间,用于存储排序、哈希和大对象处理操作的中间结果。
166. What is the fundamental difference between an online and an offline tablespace?
在线表空间和离线表空间之间的根本区别是什么?
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6c70 | 官方: 否 | 付费: 否
答案:
If a tablespace is offline, we cannot access data stored in it. In contrast to that, if a tablespace is online, the data of the tablespace is available for reading as well as writing.
如果表空间处于离线状态,我们就无法访问存储在其中数据。与此相反,如果表空间处于在线状态,那么该表空间的数据可供读取和写入。
167. Define a SYSTEM tablespace. When it is created?
定义 SYSTEM 表空间。它何时被创建?
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6c73 | 官方: 否 | 付费: 否
答案:
When any database is created in the Oracle database system, a SYSTEM tablespace is automatically generated. The Data dictionary tables for the entire database are present in The SYSTEM tablespace. It is important that the SYSTEM tablespace remains online always as it contains the data dictionary that must be available to Oracle.
在 Oracle 数据库系统中创建任何数据库时,都会自动生成一个 SYSTEM 表空间。整个数据库的数据字典表都存在于 SYSTEM 表空间中。SYSTEM 表空间始终保持在线非常重要,因为它包含 Oracle 必须可用的数据字典。
168. Define an Oracle table.
定义 Oracle 表。
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6c76 | 官方: 否 | 付费: 否
答案:
An Oracle table is a basic unit of data storage in an Oracle database. Every accessible information of any user is present in rows and columns of an Oracle table.
Oracle 表是 Oracle 数据库中数据存储的基本单元。任何用户可访问的每条信息都存在于 Oracle 表的行和列中。
169. Define a snapshot in the context of an Oracle database.
结合 Oracle 数据库的上下文定义快照。
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6c79 | 官方: 否 | 付费: 否
答案:
Oracle uses snapshots, which are also known as materialized views, in order to replicate data to the non-master sites in a replicated environment. Snapshots are also used to cache the "expensive" queries in a data warehouse environment. So in short, a snapshot is nothing but a copy of the target master table from a single point in time.
Oracle 使用快照(也称为物化视图)将数据复制到复制环境中的非主站点。快照也用于在数据仓库环境中缓存“昂贵”的查询。简而言之,快照不过是从单个时间点对目标主表的副本。
170. What do you understand by the RAW datatype?
你对 RAW 数据类型了解多少?
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6c7c | 官方: 否 | 付费: 否
答案:
The RAW datatype is used to store values in binary data format in an Oracle Database. The maximum size for a RAW datatype in a table is 32767 bytes.
RAW 数据类型用于在 Oracle 数据库中以二进制数据格式存储值。表中 RAW 数据类型的最大大小为 32767 字节。
171. What do you understand by a savepoint in the Oracle database?
你对 Oracle 数据库中的保存点有何理解?
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6c7f | 官方: 否 | 付费: 否
答案:
Savepoints can be used to break a transaction into smaller parts. It also allows the rolling back of a transaction. At any given time, at most five save points are allowed. Savepoints save our data, and therefore, whenever we encounter an error, we can roll back to the point where we had saved our SAVEPOINT.
保存点可用于将事务分解为更小的部分。它还允许回滚事务。在任何给定时间,最多允许五个保存点。保存点保存我们的数据,因此,每当我们遇到错误时,我们都可以回滚到我们保存 SAVEPOINT 的位置。
172. Describe the various Oracle database objects in brief.
简要描述各种 Oracle 数据库对象。
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6c82 | 官方: 否 | 付费: 否
答案:
The description of various Oracle database objects is as follows:- - Tables: Tables are a set of elements organized in a vertical and horizontal fashion.
各种 Oracle 数据库对象的描述如下:- - 表:表是以垂直和水平方式组织的一组元素。
- Tablespaces: Tablespaces are the logical storage unit in Oracle.
- Views: A view can be defined as a virtual table that has been derived from one or multiple tables.
- Indexes: Indexes are a performance-tuning method to process the records.
- Synonyms: Synonyms are names for tables.
173. State the usage of the ANALYZE command in Oracle.
说明 Oracle 中 ANALYZE 命令的用法。
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6c85 | 官方: 否 | 付费: 否
答案:
The ANALYZE command in Oracle can be used to perform a number of functions on indexes, tables, or clusters. Some of the use cases of the ANALYZE command in Oracle are as follows:- - The ANALYZE command can be used to find out migrated and chained rows of the table or cluster. Also, it can be used to validate the structure of the object.
Oracle 中的 ANALYZE 命令可用于对索引、表或簇执行多种功能。Oracle 中 ANALYZE 命令的一些用例如下:- - ANALYZE 命令可用于找出表或簇中迁移和链接的行。此外,它还可用于验证对象的结构。
- It helps in collecting the statistics about objects which the optimizer is using. After that, they are stored in the data dictionary.
- It helps in deleting statistics used by objects from the data dictionary.
174. Define hash clusters in Oracle.
定义 Oracle 中的哈希簇。
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6c88 | 官方: 否 | 付费: 否
答案:
A hash cluster provides an alternative to a non-clustered table with an index or an index cluster. Using indexed tables or index clusters, the Oracle Database is able to locate the rows in a table using key values that the database stores in a separate index.
哈希簇为带索引的非簇表或索引簇提供了一种替代方案。使用索引表或索引簇,Oracle 数据库能够使用数据库存储在单独索引中的键值来定位表中的行。
175. State the most common types of modules in Oracle forms.
说明 Oracle 表单中最常见的模块类型。
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6c8b | 官方: 否 | 付费: 否
答案:
The most common types of modules in Oracle forms are as follows:- - Form module.
Oracle 表单中最常见的模块类型如下:- - 表单模块。
- Menu module.
- Pl/SQL Library module.
- Object Library module.
176. Define a synonym in the Oracle database and state its types.
定义 Oracle 数据库中的同义词并说明其类型。
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6c8e | 官方: 否 | 付费: 否
答案:
Synonyms are defined as aliases for tables, views, sequences or program units. There are two types of synonyms in the Oracle database:- - Private Synonyms: These synonyms are only accessible to the owner.
同义词被定义为表、视图、序列或程序单元的别名。Oracle 数据库中有两种类型的同义词:- - 私有同义词:这些同义词仅所有者可访问。
- Public Synonyms: These synonyms are accessible to any database user.
177. Which data type in the Oracle database has a varying length binary string?
Oracle 数据库中哪种数据类型具有可变长度的二进制字符串?
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6c91 | 官方: 否 | 付费: 否
答案:
The BLOB data type in the Oracle database has a varying length binary string. It is used to store two gigabytes of memory and for it, the length needs to be specified in bytes. An example to illustrate the usage of the BLOB data type is given below:-
Oracle 数据库中的 BLOB 数据类型具有可变长度的二进制字符串。它用于存储两千兆字节的内存,并且需要以字节为单位指定长度。下面给出了一个说明 BLOB 数据类型用法的示例:-
Creating a table:-
创建表:-
create table photos(name varchar(32) not null primary key, picture blob(10M));
create table photos(name varchar(32) not null primary key, picture blob(10M));
Querying for all logotype pictures:-
查询所有标志图片:-
select name,length(picture) from photos where name like '%logo%';
select name,length(picture) from photos where name like '%logo%';
178. Describe Logical backup in Oracle.
描述 Oracle 中的逻辑备份。
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6c94 | 官方: 否 | 付费: 否
答案:
The Logical backup mechanism is for reading a set of database records and writing them into a file. We can use an Export utility to take the backup while an Import utility can be used to recover from the backup.
逻辑备份机制用于读取一组数据库记录并将其写入文件。我们可以使用导出实用程序进行备份,而导入实用程序可用于从备份中恢复。
179. What do you understand by recursive hints in Oracle.
你对 Oracle 中的递归提示了解多少?
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6c97 | 官方: 否 | 付费: 否
答案:
We can define a recursive hint as to the number of times a dictionary table is continuously called by various processes. Recursive hints occur because of the small size of the data dictionary cache.
我们可以将递归提示定义为字典表被各种进程连续调用的次数。递归提示的产生是由于数据字典缓存的大小较小。
180. State the limitations of the CHECK constraint.
陈述 CHECK 约束的局限性。
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6c9a | 官方: 否 | 付费: 否
答案:
The biggest limitation of the CHECK constraint is as follows:- The condition needs to be a boolean expression that is being evaluated using the values in the row being inserted or updated. It can also not contain any subqueries whatsoever.
CHECK 约束的最大局限性如下:- 条件必须是一个布尔表达式,使用正在插入或更新的行中的值进行评估。它也不能包含任何子查询。
Oracle Interview Preparation
181. How many rounds are conducted in an Oracle interview for a Software Engineer?
Oracle 软件工程师面试要进行几轮?
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6ccb | 官方: 否 | 付费: 否
答案:
There are around 3-4 Interview Rounds: Online Coding Round(One Round), Technical Round (2 Rounds), and HR Round.
大约有 3-4 轮面试:在线编码轮(一轮)、技术轮(2 轮)和 HR 轮。
182. Why do you want to join Oracle?
你为什么想加入 Oracle?
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6cce | 官方: 否 | 付费: 否
答案:
There are a lot of high-quality products which Oracle employees work on every day and the amount of opportunity that Oracle presents its employees is humongous. Also, the work culture is really good over there and the compensation offered to Oracle employees is on the higher end of the standards of the Information Technology or Software Industry.
Oracle 员工每天处理大量高质量产品,Oracle 为其员工提供的机会是巨大的。此外,那里的工作文化非常好,Oracle 员工获得的薪酬处于信息技术或软件行业标准的高端。
183. Are Oracle interviews hard?
Oracle 面试难吗?
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6cd1 | 官方: 否 | 付费: 否
答案:
The toughness of an interview depends upon the amount of hard work you have put in to prepare for them. Usually, the questions asked in a standard Oracle interview are of Easy to Medium Level but it varies from person to person. Since the number of interview rounds range anywhere from four to seven, it can be intimidating at times for a candidate. But if you are in, it is going to be worth the effort.
面试的难度取决于你为准备面试所付出的努力。通常,标准 Oracle 面试中提出的问题属于简单到中等水平,但因人而异。由于面试轮数从四到七轮不等,有时对候选人来说可能令人生畏。但如果你被录取了,这些努力都是值得的。
184. What are some of the questions which one should ask the interviewer at Oracle?
在 Oracle 面试时应该问面试官哪些问题?
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6cd6 | 官方: 否 | 付费: 否
答案:
It is always nice to ask questions about the company’s culture and what is the current technology using which the company makes its products. Asking about the future innovations at Oracle also might be a good idea as it might make the interviewer believe that you are looking forward to joining Oracle for a long time. You can also ask about the interviewer’s personal experience at Oracle and what skills you must develop before you join the job.
询问公司文化以及公司目前使用哪些技术来制造产品总是好的。询问 Oracle 未来的创新也可能是个好主意,因为这可能会让面试官相信你希望长期加入 Oracle。你还可以询问面试官在 Oracle 的个人经历,以及你在入职前必须培养哪些技能。
185. What are some of the famous products of Oracle?
Oracle 有哪些著名产品?
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6cdb | 官方: 否 | 付费: 否
答案:
Some of the famous products of Oracle are as follows:-
Oracle 的一些著名产品如下:
Oracle Database 2. Oracle E-Business Suite 3. PeopleSoft Enterprise 4. Siebel 5. Oracle JDeveloper, a freeware IDE
- Oracle Database 2. Oracle E-Business Suite 3. PeopleSoft Enterprise 4. Siebel 5. Oracle JDeveloper,一个免费软件 IDE
186. What are the skills required for an Oracle developer?
Oracle 开发者需要哪些技能?
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6cde | 官方: 否 | 付费: 否
答案:
As mentioned previously in this article, having a good knowledge of Java will definitely prove to be helpful to an Oracle developer. Also, having a thorough knowledge of SQL databases, cloud technologies and various models of software engineering, for instance, Agile Method, Waterfall Method, etc. might prove to be useful.
如本文前面所述,具备良好的 Java 知识肯定会对 Oracle 开发者有所帮助。此外,全面了解 SQL 数据库、云技术和各种软件工程模型,例如 Agile Method、Waterfall Method 等,也可能会有用。
187. How do I get hired in Oracle?
我如何被 Oracle 录用?
- 知识点: 数据库 (标签: interviewbit, oracle, company-specific)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: general
- 公司: Oracle
- id: 69b37c0a58d557c902bb6ce1 | 官方: 否 | 付费: 否
答案:
As is the case with any other software company, Oracle also looks forward to hiring people with extremely good problem-solving skills. Someone who is well-versed in Data Structures and Algorithms and can apply them in real-world problems will definitely have a good chance of getting hired at Oracle. Also, having a few good projects, preferably using Java and its frameworks like Spring, etc. also might increase the chance of one getting hired at Oracle.
与其他任何软件公司一样,Oracle 也期待招聘具有极强问题解决能力的人。精通数据结构与算法,并能将其应用于现实世界问题的人,肯定有很好的机会被 Oracle 录用。此外,拥有一些优秀的项目,最好使用 Java 及其框架如 Spring 等,也可能增加被 Oracle 录用的机会。
Coding Problems
0/3
Easy Problems
简单问题
Arrays
数组
Puzzles
谜题
Tree Data Structure
树数据结构
Set Matrix Zeros
矩阵置零
Easy
简单
48.4 Mins
48.4 分钟
Solve
解答
Make a Statement
发表声明
Easy
简单
4.35 Mins
4.35 分钟
Solve
解答
Diameter of Binary Tree
二叉树的直径
Easy
简单
18.25 Mins
18.25 分钟
Solve
解答
0/1
Intermediate Problems
中级问题
Tree Data Structure
树数据结构
Max Depth of Binary Tree
二叉树的最大深度
Medium
中等
6.57 Mins
6.57 分钟
Solve
解答
188. What is denormalization, and when should we use it in database design?
什么是反规范化,在数据库设计中何时应该使用它?
- 知识点: 数据库 / 系统设计/架构 / UI/UX 设计 (主题: sql, system-design;标签: denormalization, performance, joins, tradeoffs)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695b63eb2873cad90baba6dc | 官方: 是 | 付费: 否
答案:
TL;DRDenormalization intentionally adds redundancy to improve read/query performance by reducing joins, at the cost of consistency complexity.
简而言之:反规范化通过减少连接,有意添加冗余以提高读取/查询性能,代价是一致性复杂度的增加。
When to denormalize- Query performance is critical (high-traffic, low latency requirements)
何时进行反规范化——查询性能至关重要(高流量、低延迟要求)
- Read-heavy workloads (data read far more than updated)
- Acceptable consistency tradeoff (eventual consistency or controlled updates)
Very large/complex schemas where joins become expensive
Tradeoffs- Faster reads权衡——更快的读取
- More complex writes and consistency management
189. 你如何优化 SQL(Structured Query Language)查询?
- 知识点: 数据库 / UI/UX 设计 (主题: sql;标签: sql, query-optimization, index, join, select, schema-design)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695ccbc31da5537956248f2b | 官方: 是 | 付费: 否
答案:
TL;DRSQL(Structured Query Language)优化的核心是减少扫描与不必要的计算:合理建索引(Index)、避免 SELECT *、控制 JOIN(连接)数量、用子查询(Subquery)/别名(Alias)提升效率与可读性,并通过良好的表设计(Table Design)减少冗余与提升查询性能。
优化 SQL(Structured Query Language)查询意味着识别最有效的技术来提升 SQL(Structured Query Language)查询性能。以下是常见且有效的方法:
Indexing(索引(Index)):通过索引(Index)加快定位相关数据的速度。
使用 SELECT(查询)指定列而不是 SELECT*:用 SELECT(查询)指定所需列,避免不必要的 I/O(输入/输出)操作导致查询变慢。
避免过多 JOIN(连接):选择合适的 JOIN(连接)类型,确保结果正确并减少不必要的处理。
使用子查询(Subquery):在某些情况下,用子查询(Subquery)代替 JOIN(连接)可能更高效,尤其是仅需基于另一张表数据筛选一张表时。
使用表别名(Alias):别名(Alias)让 SQL(Structured Query Language)更易读、更易写,可用于表和列。
优化数据库设计(Database Design):避免冗余数据并使用合适的数据类型(Data Type),良好设计的数据库(Database)能提高查询性能。
使用通配符(Wildcard):通配符(Wildcard)帮助在数据库中搜索匹配结果。
190. 谈谈 Java(Java)中的连接泄漏(Connection Leaks)以及如何修复。
- 知识点: 数据库 / 编程语言基础 (主题: java;标签: java, connection-leak, database, resource-management)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695ccbc41da5537956248fcb | 官方: 是 | 付费: 否
答案:
TL;DR连接泄漏(Connection Leak)是数据库(Database)连接使用后未关闭导致连接池(Connection Pool)逐渐耗尽的问题。修复方式是始终在使用后显式关闭连接,最好放在 finally(最终)块中保证异常情况下也能关闭。
在 Java(Java)中,连接泄漏(Connection Leak)指数据库(Database)连接在使用后未正确关闭,导致连接无法被复用,最终造成可用连接逐渐耗尽,使应用因资源不足而失败。
修复连接泄漏(Connection Leak)的方式是:使用后始终显式关闭数据库(Database)连接,最好在 finally(最终)块中关闭,以确保无论是否发生异常连接都能被释放。
191. 写一条 SQL(Structured Query Language)语句:计算某个玩家在排行榜(Leaderboard)中的名次(Rank)(示例:player_id=42)。
- 知识点: 数据库 (主题: sql;标签: rank, subquery, leaderboard)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695df6661da553795635b2ca | 官方: 是 | 付费: 否
答案:
TL;DR使用嵌套查询(Nested Query)统计分数不小于该玩家分数的记录数,作为 rank(名次)计算逻辑。
SELECT _,
SELECT _,
(
SELECT COUNT(_)
SELECT COUNT(_)
FROM leaderboards AS l2
FROM leaderboards AS l2
WHERE l2.score >= l1.score
WHERE l2.score >= l1.score
)
AS RANK
AS RANK
FROM leaderboards AS l1
FROM leaderboards AS l1
WHERE l1.player_id = '42';
WHERE l1.player_id = '42';
192. 为什么使用关系型数据库(Relational Database)实现实时排行榜(Real-time Leaderboard)可能会遇到性能与扩展性问题?Redis Sorted Set(有序集合)如何改进这些问题?
- 知识点: 数据库 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design;标签: redis, sorted-set, scalability, latency)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695df6661da553795635b2cd | 官方: 是 | 付费: 否
答案:
TL;DR关系型数据库在百万级玩家实时排名场景下需要频繁排序(Sorting)与全表扫描(Full Table Scan)/复杂聚合(Complex Aggregation),延迟高且难扩展;Redis Sorted Set 通过内存存储(In-Memory Storage)与自动按 score(分数)排序,将排名与 TopN 查询降到 O(log n),显著提升性能。
关系型数据库的痛点- 计算排名(Ranking)可能需要全表扫描或复杂嵌套查询(Nested Query)
- 排行榜数据不断变化,缓存容易变成 stale
- 百万级数据排序/聚合开销大,查询慢
- 需要 join 多张表来展示榜单,增加复杂度
- 磁盘 IO(disk seeks)导致实时更新性能差
Redis Sorted Set 的优势- 内存数据结构(In-Memory Data Structure),读取延迟(Read Latency)低 - 写入/upsert 时自动按 score 排序
- 获取 rank / TopN 为 O(log n)
- 数据库压力下降,成本更可控
补充:玩家元数据(Player Metadata)Sorted Set 存 player_id 与 score;玩家名称等 metadata 可来自关系型数据库或 Redis Hash(哈希)缓存(Cache)。
193. 当你使用 DynamoDB(NoSQL)设计排行榜时,如何通过 GSI + Scatter-Gather 模式实现 Top N 查询?它的优缺点是什么?
- 知识点: 数据库 / DevOps/云 / 系统设计/架构 / UI/UX 设计 (主题: system-design, aws;标签: dynamodb, gsi, scatter-gather, ranking)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695df6661da553795635b2d3 | 官方: 是 | 付费: 否
答案:
TL;DRDynamoDB 可用 GSI(全局二级索引)以 score 作为 sort key(排序键)来支持按分数排序查询;当数据被分区(Partitioning)后,需要对各分区分别查询(scatter),在应用层合并排序(gather)得到 Top N。优点是托管(Managed)、可扩展(Scalable);缺点是模式复杂、合并排序成本高。
实现思路- 使用 DynamoDB 存储玩家分数记录
- 建立 GSI:score 作为 sort key,player_id 或其他字段作为 partition key
- 如果数据被分区(多 partition),Top 10 请求需要:- 对每个 partition 执行 TopK 查询(scatter)
- 服务端汇总并二次排序(gather)
- 通过 DynamoDB Streams 捕获分数变化用于异步更新/通知
优点- Fully managed(全托管)、Serverless(无服务器) - 可通过分区实现高性能扩展
- 支持数据变更捕获(Streams)
缺点- Scatter-Gather 增加系统复杂度 - 跨分区的排序与合并开销较大
- 写入与索引维护(如B-Tree结构)可能带来成本与性能影响
194. 如何实现相对排行榜(Relative Leaderboard),即获取某个玩家周围的排名玩家?请说明流程与 Redis 查询方式。
- 知识点: 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: system-design, data-structures;标签: relative-leaderboard, zrevrank, zrevrange, surrounding-players)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695df7bb1da553795635d815 | 官方: 是 | 付费: 否
答案:
TL;DR相对排行榜的核心是:先用 ZREVRANK 获取玩家 rank(排名),然后用 ZREVRANGE 取 rank±N 的区间返回周边玩家。例如要取前后 5 名,则区间为 [rank-5, rank+5]。
实现流程- 调用 ZREVRANK 获取目标玩家的排名(0-based(从0开始))。
- 根据排名计算上下区间(例如 rank-5 到 rank+5)。
调用 ZREVRANGE 获取该区间内玩家列表(按分数从高到低)。
示例:获取某玩家周围 10 名(前后各 5 名)redis> ZREVRANK leaderboard "eleven"
(integer) 11(integer) 11
redis> ZREVRANGE leaderboard 8 14
redis> ZREVRANGE leaderboard 8 14
"eight"
- "eight"
"nine"
- "nine"
"ten"
- "ten"
"eleven"
- "eleven"
"twelve"
- "twelve"
"thirteen"
- "thirteen"
- "fourteen"边界处理- 当 rank-N 小于 0 时,start 取 0。
- 当 rank+N 超过总长度时,stop 取最后一名。
为什么这种方式高效?Sorted Set 已经按 score 预排序,获取 rank 和区间查询都能在较低复杂度(Complexity)下完成,适合实时显示周边排名。
195. 如何配置一个全局排行榜(Global Leaderboard)以聚合多个游戏场景的分数?请说明 Redis 中的实现方式与关键命令。
- 知识点: 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: system-design, data-structures;标签: global-leaderboard, aggregation, sorted-set, zunionstore)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695dfa151da5537956361db7 | 官方: 是 | 付费: 否
答案:
TL;DR全局排行榜可以通过维护多个 Sorted Sets(不同游戏/模式/区域)并用 ZUNIONSTORE 做并集聚合生成一个 global-level Sorted Set,实现跨场景总分排行。
实现思路- 为每个游戏场景维护一个独立的 Sorted Set(如 lb:game1, lb:game2)。
- 建立一个 global Sorted Set(如 lb:global)存储聚合后的总分。
- 使用 ZUNIONSTORE 对多个 Sorted Sets 做 union,并将结果写入 global key。
关键命令:ZUNIONSTOREredis> ZUNIONSTORE lb:global 2 lb:game1 lb:game2解释:将两个榜单并集后写入 lb:global,默认对相同 member 的 score 做求和聚合(可通过参数调整聚合方式)。
196. 如何配置好友圈排行榜(Friend Circles Leaderboard)?请说明使用 Redis Sorted Set 交集的方案以及客户端本地计算的替代方案。
- 知识点: 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: system-design, data-structures;标签: friend-circle, zinterstore, intersection, client-side-merge)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695dfa151da5537956361dc3 | 官方: 是 | 付费: 否
答案:
TL;DR好友圈榜单可通过两种方式实现:服务端 Redis 交集或客户端本地合并。服务端方案用 ZINTERSTORE 将好友列表 Sorted Set 与全球榜单 Sorted Set 做交集生成好友圈榜单;客户端方案则在本地合并好友列表与全球榜单,减少服务端计算压力。
服务端方案:Sorted Set 交集- 用一个 Sorted Set 保存好友列表(score 初始化为 0)。
- 使用 ZINTERSTORE 与 global leaderboard 做交集,得到好友圈 leaderboard。
redis> ZINTERSTORE lb:friends:41 2 friends:41 lb:global客户端替代方案:本地计算- 客户端拉取 friend list 与 global leaderboard 数据后在本地 merge。 - 利用客户端计算与缓存能力,Friend Circle 的扩展性可随玩家规模线性增长。
适用权衡- 服务端交集:一致性更强,但服务器计算压力更大。 - 客户端合并:降低服务端负载,但需要更多客户端逻辑与带宽。
197. 当单个 Redis 节点无法承载热门排行榜 QPS 时,如何对排行榜缓存做分片(sharding)?为什么用 score 作为 shard key 会带来查询困难?
- 知识点: 数据库 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: sharding, redis, score-shard-key, ranking-query)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695dfa151da5537956361dc6 | 官方: 是 | 付费: 否
答案:
TL;DR热门榜单可能使 QPS 超过单个 Redis 节点阈值,需要对缓存进行分片。可以按 score 做 shard key 来优化 TopN 与周边排行查询,但会导致“按 player 查 rank/score”变得困难,因为同一个 player 的位置取决于 score 并可能频繁迁移。
按 score 分片的好处- 适合 Top 10 查询(高分段集中在少数 shard)。
- 适合周边排名查询(按 score 范围读取)。
按 score 分片的困难- 要查询某个 player 的 rank/score,必须先知道该 player 属于哪个 score shard。 - 当 score 变化时,需要将 player 从旧 shard 移除并插入新 shard(迁移成本)。
常见补偿方案- 维护一个 players metadata cache(Redis Hash)存储 player_id → score。 - 查询 player rank 时:先查 metadata cache 得到 score,再到对应 leaderboard shard 查 rank。
198. 排行榜缓存分片有哪些常见方案?它们的主要 trade-off 是什么?
- 知识点: 数据库 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: range-partitioning, modulus-partitioning, redis-cluster, consistent-hashing, tradeoff)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695dfa151da5537956361dcc | 官方: 是 | 付费: 否
答案:
TL;DR常见分片方案包括:范围分片(range)、取模分片(modulus)、Redis Cluster、一致性哈希(consistent hashing)。核心 trade-off 通常围绕:节点变化时的数据迁移量、数据分布是否连续、查询复杂度与运维复杂度。
常见方案- Range partitioning(范围分片):按 score 范围或 key 范围分片。
- Modulus partitioning:按 hash(key) % N 分片。
- Redis Cluster:基于 hash slots 自动分布。
- Consistent hashing:key 非连续分布,减少节点变化时迁移(但仍有复杂度)。
Trade-off(权衡) 总结- Range partitioning(范围分片):节点变化时数据移动大,且运维复杂。 - Modulus partitioning:节点变化时数据移动大;非连续分布导致查询复杂。
- Redis Cluster:节点变化时 hash slots 重分布导致数据移动;运维复杂。
- Consistent hashing:非连续分布使查询复杂;仍存在运维复杂度。
199. Redis Cluster(Redis集群) 如何实现自动分片?什么是 hash slots(哈希槽)?当节点变更时,rebalance(再平衡) 与 reshard(重新分片) 的作用分别是什么?它们带来什么代价?
- 知识点: 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: system-design, data-structures;标签: redis-cluster, hash-slots, rebalance, reshard, operational-complexity)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695dfa151da5537956361dcf | 官方: 是 | 付费: 否
答案:
TL;DRRedis Cluster(Redis集群) 通过算法分片与 hash slots(哈希槽) 自动分配 key 到不同节点。节点增减时,可通过 rebalance(再平衡) 重新分配 slots(槽);通过 reshard(重新分片) 实现更连续的分布,但会导致更多数据移动与更高运维复杂度。
核心概念:Hash Slots(哈希槽)- Redis Cluster(Redis集群) 将 key 映射到固定数量的 hash slots(哈希槽)。
- 每个节点负责一部分 slots,从而实现自动分片。
节点变更时- rebalance(再平衡):当新增/移除节点时重新分配 hash slots(哈希槽),维持负载均衡。 - reshard:追求更连续的 key 分布,但代价是更多数据移动、操作复杂。
代价与风险- 确保 hash slots(哈希槽) 连续分布会增加节点变更时的数据迁移量。 - 数据移动期间可能引发性能下降(degraded performance)。
- 整体运维复杂度提高(需要更谨慎的迁移与监控)。
200. 在一致性哈希分片下,当玩家分数变化时为什么需要“移除并重新插入”到正确的 shard(分片)?如何计算玩家全局排名?如何使用 ZCOUNT(有序集合计数命令) 辅助?
- 知识点: 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: system-design, data-structures;标签: consistent-hashing, score-change, resharding, zcount, global-rank)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695dfa151da5537956361dd5 | 官方: 是 | 付费: 否
答案:
TL;DR一致性哈希分片若按 score(分数) 范围/规则路由,当分数变化时玩家应落到不同 shard(分片),为保持数据在正确 shard(分片) 中,需要将记录从旧 shard(分片) 移除并插入新 shard(分片)。计算全局排名需要结合该玩家在 shard(分片) 内的 rank(排名),以及其它 shard(分片) 的边界排名统计;可用 ZCOUNT(有序集合计数命令) 统计每个 shard(分片) 中高于某 score(分数) 的元素数量来汇总排名。
为什么要移除并重新插入- 分片路由依据 score(分数)(或与 score(分数) 强相关),score(分数) 变化会改变目标 shard(分片)。
- 若不迁移,数据将位于错误 shard,导致 TopN、rank 计算不正确。
如何计算全局 rank(排名)(思路)- 先算玩家在本 shard(分片) 的 rank(排名)。 - 再统计其它 shard 中分数高于该玩家 score 的人数。
- 两者相加得到全局排名。
ZCOUNT(有序集合计数命令) 的作用redis> ZCOUNT shard:1 (score+inf)- ZCOUNT(有序集合计数命令) 可统计某 score(分数) 区间内的元素数量。 - 用于计算“有多少人分数比我高”,从而推导全局排名边界。
201. 排行榜系统如何处理海量并发(massive concurrency)?请说明 collapse forwarding(合并转发)、Redis 单线程执行模型、原子更新以及 Lua 脚本的作用。
- 知识点: 数据库 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: massive-concurrency, collapsed-forwarding, atomic, redis-single-thread, lua)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695dfa151da5537956361ddb | 官方: 是 | 付费: 否
答案:
TL;DR高并发读请求可通过反向代理的 collapse forwarding(合并转发) 合并相同请求减少后端压力;Redis 通过单线程顺序执行命令确保 score(分数) 更新原子性,同时可用 Lua 脚本实现额外排名逻辑与差分更新。Redis 可并发接收网络请求,但命令执行仍是顺序的。
并发读优化:Collapse Forwarding(合并转发)- 反向代理合并并发读请求,避免同一 key 被大量重复请求击穿缓存。
- 提升读性能并降低后端压力。
并发写与原子性- Redis 单线程执行命令,天然避免并发写冲突。 - score 更新必须是原子操作(如 ZINCRBY)。
Lua 脚本(Lua script)作用- 实现额外 ranking 逻辑(例如 tie-break(平局决胜)、差分更新计算(differential update calculation))。 - 将多个 Redis 操作封装成一个原子执行单元。
Redis 并发模型(concurrency model)补充- Redis 使用多线程(multithreading)接收网络连接(network connection)与写缓冲(write buffer)。 - 命令可以并发发起,但执行是串行。
- 延迟通常来自网络而非 CPU。
202. Redis Sorted Set(有序集合)在内部是如何实现的?hash(哈希) + skip list(跳表)的组合分别承担什么作用?Sorted Set 如何进行 tie-break(平局决胜)?
- 知识点: 数据库 / 算法与数据结构 (主题: data-structures;标签: skip-list, internal-implementation, hash, tie-break, lexicographic)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695dfa151da5537956361de1 | 官方: 是 | 付费: 否
答案:
TL;DRRedis Sorted Set(有序集合)内部采用hash + skip list 的双结构:hash 用于快速定位 member → score,skip list 用于按 score 排序并支持 O(log(n)) 范围/排名查询。默认情况下,score 相同时会按 member 字符串的字典序升序(lexicographic ascending)进行 tie-break(平局决胜)。
内部结构- Hash(哈希):映射 player/member 到 score,支持快速查找。
- Skip List:映射 score 到 member 并保持有序,支持排名/范围查询。
性能原因- Skip list(跳表)平均复杂度 O(log(n)),适合 leaderboard(排行榜)的 rank 与 range 操作。 - 小数据集时 Sorted Set 会先用 hash 存储直到超过阈值再启用完整结构优化。
tie-break(平局决胜)规则当 score 相同,Redis 默认按 member 字符串的 lexicographic ascending(字典序升序)排序。
203. 排行榜(leaderboard)系统如何实现可扩展性(Scalability)?读写路径(read/write path)应该如何拆分?Redis 节点的 QPS(每秒查询数)能力与数据反规范化(denormalization)有什么关系?
- 知识点: 数据库 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design;标签: scalability, read-write-separation, denormalization, qps, redis)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695dfa151da5537956361dea | 官方: 是 | 付费: 否
答案:
TL;DR读扩展依赖缓存层(caching layer)(Redis/CDN/客户端缓存(client-side cache))来承载大量 leaderboard view 请求;写扩展依赖数据分片(data sharding)或内存架构(in-memory architecture)(Sorted Set)来支撑高频 score updates。通过拆分读写路径(read path / write path)并在读侧使用反规范化数据,可以显著提高吞吐与降低延迟。文中提到 Redis 节点在峰值可处理约 40k QPS,超过后需要分片(sharding)。
读扩展- 在 view leaderboard 场景使用 Redis/CDN 缓存(cache)。
- 客户端缓存减少重复拉取。
写扩展- 写重系统可通过分片(sharding)或内存存储架构扩展。 - 异步写入 DB 减少阻塞。
读写路径(read/write path)拆分- Write Path(写入路径):ZINCRBY 更新 Redis → 异步落库。 - Read Path:优先从 Redis 获取 TopN/rank,miss 再查 DB。
反规范化(Denormalization)- 将展示所需字段(name、avatar、region)预聚合/冗余到缓存(cache)中,减少 join 和额外查询。 - 提升读性能,但需要处理数据同步与更新策略。
204. Job Store(任务存储)需要哪些核心数据表?每张表存什么信息、解决什么问题?
- 知识点: 数据库 / 系统设计/架构 / UI/UX 设计 (主题: system-design, sql;标签: job-table, job-execution-table, schedules-table, worker-table, state-management)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695dfcb71da553795636538b | 官方: 是 | 付费: 否
答案:
TL;DRJob Store(任务存储)需要至少四张表:Job Table(任务表)(job 元数据与状态)、Job Execution Table(任务执行表)(每次执行 attempt 的日志)、Schedules Table(调度表)(next_run_time/last_run_time)、Worker Table(工作节点表)(worker 健康、容量、负载、心跳(heartbeat))。
核心表设计- Job Table(任务表):job_id、user_id、frequency、payload、execution_time、retry_count、status(pending/running/completed/failed)。用于记录 job 生命周期的主状态。
- Job Execution Table:execution_id、start_time、end_time、worker_id、status、error_message。用于记录 job 的每次执行尝试,支持失败重试可观测。
- Schedules Table:next_run_time、last_run_time。one-time job 的 next_run_time=execution time;recurring job 每次执行后更新 next_run_time。
- Worker Table:ip、status、last_heartbeat、capacity、current_load。用于 coordinator 进行 worker 管理、负载均衡与故障检测。
205. 通知系统(Notification System)如何进行水平扩展(Horizontal Scaling)?哪些组件需要独立扩容?常见的分片(Sharding)/分区(Partitioning)与缓存策略(Caching Strategy)有哪些?
- 知识点: 数据库 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design;标签: horizontal-scaling, sharding, partitioning, caching, redis, memcached, time-based-partitioning)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695dfe121da55379563679ec | 官方: 是 | 付费: 否
答案:
TL;DR系统通过增加实例实现水平扩展:Notification Service、Queue(队列)、Channel Processors 都能独立扩容。数据层可用 user-based sharding(基于用户的分片)、time-based partitioning(基于时间的分区);偏好服务可用 Redis/Memcached 缓存降低读压力;日志按时间分区便于查询与归档(Archiving)。
水平扩展方式- Notification Service:增实例应对高并发请求(Concurrent Request)。
- Notification Queue:Kafka/RabbitMQ 通过分区/集群扩展吞吐。
- Channel Processors:按渠道分别扩容 consumer 数量。
Sharding & Partitioning- User-based Sharding:按 userId(用户ID) 或地域分布用户数据,均衡负载(Load Balancing)。 - Time-based Partitioning:通知日志按日/月分区提升查询性能与管理历史数据。
Caching- 使用 Redis/Memcached 缓存用户偏好,减少数据库访问,提高实时发送性能。
206. 分布式计数器(Distributed Counter)的数据存储方案有哪些?关系型数据库(Relational Database)、Cassandra(NoSQL) 与 Redis 各自的数据模型(Data Model)和权衡(Trade-off)是什么?
- 知识点: 数据库 / 系统设计/架构 / UI/UX 设计 (主题: system-design, sql;标签: sql, nosql, cassandra, redis, normalization, denormalization, performance)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695dff721da55379563694b7 | 官方: 是 | 付费: 否
答案:
TL;DR关系型数据库通常采用规范化模型(Normalized Model)节省存储但读可能需要 JOIN(连接操作) 且写在高并发时容易受锁(Lock)影响;Cassandra 采用去规范化(Denormalization)以提升查询速度但会增加冗余(Redundancy);Redis 用内存 KV(hash)存储计数可获得极低延迟。对于互联网规模、高并发计数器,关系型数据库往往不适合做主存储。
关系型数据库(Normalized)- 实体:users、pages、counter(计数器)。
- 关系:users 与 pages 为 1-to-many;pages 与 counter 为 1-to-many。
- 优点:减少冗余、节省存储。
- 缺点:读可能需要 JOIN;高并发写需锁,扩展困难。
NoSQL(Cassandra, Denormalized)- 按 web page 维度去规范化存储计数。 - 可通过 timestamp 列追加方式记录最近值。
- 优点:读更快、横向扩展好。
- 缺点:数据冗余更高。
Redis(In-memory KV)- 使用 Redis hash(哈希) 存储页面计数。 - 优点:极低延迟、高吞吐。
- 缺点:内存成本高,需要高可用与持久化策略配合。
207. 为什么 Cassandra 作为分布式计数器的方案在理论上可行,但在实践中不推荐?它的核心问题是什么?
- 知识点: 数据库 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: cassandra, nosql, counter, idempotency, gossip, consistent-hashing, lsm-tree)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695e00311da5537956369ee9 | 官方: 是 | 付费: 否
答案:
TL;DRCassandra 作为分布式 NoSQL 数据库具备去中心化(leaderless replication,无主复制) 与一致性哈希分区(Consistent Hashing Partitioning)能力,写性能也很强(LSM Tree),理论上可以用它的 counter 类型实现分布式计数器。但在实践中 Cassandra counter(计数器) 存在结构限制与更新非幂等(Non-idempotent Update) 等致命问题,因此不适合作为可扩展分布式计数器的实现。
为什么理论可行- Cassandra 支持gossip 节点通信,天然分布式(Distributed)。
- 支持consistent hashing 自动分区,易扩展。
- leaderless replication 提高可用性。
- LSM Tree 写入快,适合写多场景。
实践中的关键问题(Cassandra Counter)- counter column 只能存在于全是 counter 的独立表:无法混合普通字段(Field),数据模型受限(Data Model Constraint)。 - 包含 counter 的表无法删除:运维与生命周期管理复杂。
- counter 更新操作非幂等:网络重试/重复提交会导致计数错误(这在分布式系统里是致命的)。
结论更新非幂等是直接阻断(showstopper)问题,再叠加 Cassandra 运维复杂度高,因此总结为:不要用 Cassandra 构建可扩展的分布式计数器。
208. 为什么“原生 Redis 数据类型 + INCR”并不适合作为跨数据中心(Cross-Data Center)分布式计数器的最终方案?幂等性(Idempotency) 与网络故障(Network Failure) 会带来什么问题?
- 知识点: 数据库 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: redis, incr, idempotency, network-failure, active-active, lua, write-behind)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695e00311da5537956369ef2 | 官方: 是 | 付费: 否
答案:
TL;DRRedis 原生 INCR(increment)可以原子自增,性能极高,并可通过 leader-follower(主从复制)或 active-active(双活)部署增强可用性。但如果要实现跨数据中心的正确同步,计数更新必须幂等(idempotent)。Redis 原生命令在网络失败下难以确认是否执行成功,且更新操作本身不是幂等的,重试会导致计数错误,因此文章结论是:不要用原生 Redis 数据类型来构建分布式计数器(distributed counter)。
Redis 为什么看起来可行- 内存型数据结构(in-memory data structure),吞吐极高。
- INCR 原子操作,避免锁。
- 可用 leader-follower + proxy 做读写分离与分片。
- 可用 write-behind 异步落库提高 durability。
致命问题:幂等性(idempotency) + 网络故障- 更新非幂等:重复执行 INCR 会重复累加,直接造成计数偏大。 - 网络失败下无法确认执行状态:客户端超时并不代表 Redis 未执行,重试可能重复加一。
- 多数据中心同步需要幂等:否则跨 DC 冲突/重放会导致计数不准确。
可选 workaround(但复杂)- 使用 Lua script 记录 userId 或把 userId 放入 Redis set 来辅助去重。
结论如果目标是“高性能 + 跨 DC 准确一致”,原生 Redis 计数需要大量补丁逻辑,最终不推荐作为核心实现。
209. SQL Azure 中的 federation(联邦)是什么?为什么需要它?
- 知识点: 数据库 / DevOps/云 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: sql, system-design;标签: SQL Azure, Federation, Sharding, Repartitioning)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 6960b2b30e32007ea0d10533 | 官方: 是 | 付费: 否
答案:
核心答案SQL Azure 的 federation(原文)是为可扩展性(scalability)引入的机制,用于帮助管理者与开发者扩展数据规模。
它带来的价值(原文要点)- 对管理者:更容易进行数据重新分区(repartitioning)与再分发(redistributing)。
- 对开发者:支持数据路由与共享层的实现。
- 支持在路由过程中做到无应用停机(原文)。
补充:在现代语境中可以把它理解为一种分片/水平拆分思路(类似 sharding),用来把数据按键分布到多个分区以提升吞吐与容量。
210. 当流量上涨时,你的 RDS 关系型数据库引擎(relational database engine)经常崩溃,而且副本没有自动提升为主库。你会如何处理?
- 知识点: 数据库 / DevOps/云 / 系统设计/架构 / UI/UX 设计 / 行为与软技能 (主题: aws, system-design;标签: rds, scaling, failover, performance)
- 类型: situational | 难度: hard | 子类型:
- 分类: backend
- id: 6960bd800e32007ea0d20b88 | 官方: 是 | 付费: 否
答案:
核心答案从容量与高可用(high availability)配置两条线同时处理。
建议措施- 纵向扩容(vertical scaling):升级到更大的 RDS 实例规格,或优化存储/IO。
- 优化数据库:索引、慢查询、连接池、参数组调优。
- 高可用:确认是否为 Multi-AZ(而不是 Read Replica),Multi-AZ 才是自动故障切换路径。
- 数据保护:开启自动备份与快照(手动/自动),并做恢复演练。
- 读扩展:如果读压力大,用 Read Replica 分担读请求。
211. 你在多个可用区部署了 EC2,数据库用 Multi-AZ 的 RDS MySQL,读写都很频繁。发现 RDS 出现读争用(read contention),你会怎么优化?
- 知识点: 数据库 / DevOps/云 / 系统设计/架构 / UI/UX 设计 / 行为与软技能 (主题: aws, system-design;标签: rds, read-replica, db-tuning, elasticache, performance)
- 类型: situational | 难度: hard | 子类型:
- 分类: backend
- id: 6960bebb0e32007ea0d22a82 | 官方: 是 | 付费: 否
答案:
核心答案从 读扩展、数据库优化、缓存 三层入手。
1) 读扩展:Read Replicas- 增加 Read Replica 承接读流量,把写请求保留在主库。
- 应用侧做读写分离(读走副本,写走主库)。
2) 数据库优化- 索引优化(index optimization):覆盖索引/联合索引,减少全表扫描。 - 查询优化:减少不必要 join、避免 N+1、控制返回列。
- 参数/配置调优:连接数、缓存、buffer pool 等(按引擎)。
3) 缓存层(Cache Layer):ElastiCache- 用 Amazon ElastiCache (Redis/Memcached) 缓存热点数据(Hot Data)与常用查询结果,减少对 RDS 的读压力。
212. 订单“延时取消(Delayed Cancellation)”你会怎么实现?请至少给出 2 种实现方案。
- 知识点: 数据库 / 系统设计/架构 / UI/UX 设计 (主题: system-design, messaging, redis, database;标签: Delayed Job, Order System)
- 类型: technical | 难度: hard | 子类型: system-design
- 分类: backend
- 公司: IBM
- id: 69704120120fcc1591300c0f | 官方: 是 | 付费: 否
答案:
答案方案 1:消息队列延时消息/死信队列(Message Queue Delayed Message/Dead Letter Queue,DLQ)(RabbitMQ DLX、RocketMQ 延时等):下单后投递延时消息,到期触发取消。优点解耦、可扩展;缺点依赖 MQ 能力与幂等处理(Idempotency)。
方案 2:定时任务扫描(Scheduled Task Scan)(DB 状态 + 到期时间):周期性查找超时订单并取消。优点简单;缺点对 DB 压力大、延迟粒度受限。
方案 3:时间轮/延时队列(Time Wheel/Delayed Queue)(如 Redis ZSET + 消费者轮询):控制精度与吞吐。
关键:取消操作要幂等(Idempotent);与支付/库存要做一致性处理(Consistency Handling)(补偿/事务消息)。
AnswerOption 1: MQ delayed messages/dead-letter queues: publish a delayed event at order creation; consume on expiry to cancel. Scalable but requires idempotency and MQ support.
选项 1:MQ 延迟消息/死信队列:在订单创建时发布延迟事件;到期时消费以取消。可扩展,但需要幂等性和 MQ 支持。
Option 2: scheduled scanning: periodically query expired orders and cancel. Simple but can load the DB and has coarse granularity.
选项 2:定时扫描:定期查询过期订单并取消。简单,但可能给数据库带来负载且粒度较粗。
Option 3: timing wheel/delay queue (e.g., Redis ZSET + workers). Good control over precision/throughput.
选项 3:时间轮/延迟队列(例如 Redis ZSET + worker)。可良好控制精度/吞吐量。
Key: make cancellation idempotent and handle consistency with payment/inventory via compensation/transactional messaging.
关键:使取消具备幂等性,并通过补偿/事务消息处理与支付/库存的一致性。
213. 在 Databricks 中如何做复杂分析(Complex Analytics)?
- 知识点: 数据库 / 数据工程与数据科学/AI (主题: databricks, spark, analytics, mlflow, mllib, sql;标签: Databricks, Analytics)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 69708ce1120fcc15913766d1 | 官方: 否 | 付费: 否
答案:
答案复杂分析通常是“批/流 + 多维聚合(Multi-dimensional Aggregation) + 特征工程(Feature Engineering) + 建模/可视化”的组合。可用 Spark SQL/DataFrame 做清洗与特征构建,用窗口函数(Window Functions)/高级聚合完成指标。
需要机器学习时用 MLlib 或第三方库;实验管理与可复现用 MLflow;可视化在 Notebook 中完成;结果可写入 Delta/数仓或通过服务接口输出。
214. In the CommServe database, how are keys stored?
在 CommServe 数据库中,密钥是如何存储的?
- 知识点: 数据库 (标签: interviewbit, commvault, company-specific)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: general
- 公司: Commvault
- id: 69b37a4d58d557c902ba50f8 | 官方: 否 | 付费: 否
答案:
Data encryption keys are encrypted with the client's RSA public key and stored in the database. Depending on the settings, the client's RSA private key is encrypted with either a built-in passphrase or a passphrase provided by the user.
数据加密密钥使用客户端的 RSA 公钥加密后存储在数据库中。根据设置,客户端的 RSA 私钥使用内置口令或用户提供的口令加密。
215. What events are triggered during a Deduplication Database (DDB) backup process?
在重复数据删除数据库(DDB)备份过程中会触发哪些事件?
- 知识点: 数据库 (标签: interviewbit, commvault, company-specific)
- 类型: technical | 难度: hard | 子类型: concept
- 分类: general
- 公司: Commvault
- id: 69b37a4d58d557c902ba510b | 官方: 否 | 付费: 否
答案:
The following events occur when the DDB backup job starts: - For a few seconds, all communication with the active DDB is halted. To ensure that the DDB is in a dormant stage, the information in memory is committed to memory.
当DDB备份作业启动时,会发生以下事件: - 在几秒钟内,与活动DDB的所有通信都会暂停。为确保DDB处于休眠阶段,内存中的信息会被提交到内存中。
- The DDB process uses VSS (Windows) or LVM (Linux) snapshots to make a snapshot of the volume.
- The file systems Extended 3 File System (ext3) and VERITAS Volume Manager (VxVM) are also supported on the Linux platform.
- All communication with the DDB is resumed when the snapshot is created, and the DDB is automatically backed up from that snapshot.
- If a VSS (Windows) or LVM (Linux) snapshot fails, the DDB backup falls back on a live volume backup.
- The snapshot is erased after a successful DDB backup. The Job Controller displays the DDB Backup job in a running condition at this point.
- If the DDB MediaAgent restarts during a DDB backup job, the job is marked as Pending. The DDB backup job resumes from the beginning after the restart.
- The DDB backup jobs for the auxiliary copy operation are disabled by default, and these jobs appear as unavailable when viewed from the primary copy.
- Allowing DDB Backup Tasks from Being Copied to Secondary Copy describes how to enable or prohibit DDB backup jobs from being copied to secondary copy during the auxiliary copy procedure.
评论