1. List common relational databases and non-relational types. 关系型 : MySQL,SQL Server ,Oracle , Sybase, DB2 非关系型 : Redis, MongodDB
2.MySQL Common Database engine and comparison?
Innodb,myisam,ndb,memory, etc.
3. Describe the three main paradigms of data?1.第一范式:确保每列保持原子性 2.第二范式:确保表中的每列都和主键相关3.第三范式:确保表中每一列都和主键列直接相关,而不是间接相关.Details 4. What is a business? How does MySQL support transactions?
A transaction is a logical set of operations that make up the units of this set of operations, or all succeed or fail, a feature that is a transaction
5. Describe a one-to-many and many-to-many scenarios in database design?
One-to-many: a school has multiple teachers.
Many-to-many: a teacher can take multiple classes, a class has a number of teachers
6. How to implement the mall commodity counter based on the database?
Details
7. Common SQL (required)
Details
8. Describe triggers, functions, views, stored procedures?
Details
触发器: 在执行某种操作前后一些自定义的操作函数: 处理参数,返回结果视图: 把需要的数据存放在一张临时表中存储过程: sql语句集,简化了一些操作.与函数不同,他可以返回一个结果集(查询结果)9.MySQL Index Type
Details
10. Under what circumstances does the index follow the rules of the leftmost prefix?
Federated Index
11. What is the difference between a primary key and a foreign key?
Primary key: This column is unique in this table, not null
FOREIGN key: The value in this column must be the associated data in the associated table
12.MySQL a common function?
Details
13. List the 8 scenarios in which the index was created but not hit.
Details
14. How do I turn on slow log queries?
Details
15. Database Import and Export command (structure + data)?
Mysqldump-h127.0.0.1-p3306-uroot-p Password database name >xx.sql
16. Database Optimization program?
Details
What is the difference between 17.char and varchar?
#char类型: Fixed length, simple rough, wasted space, fast access speed
#varchar类型: variable length, precision, space saving, slow access speed
18. Describe the MySQL execution plan?
Details
19. Under the index of the name, describe the following differences:
- SELECT * from TB where name = ' Oldboy-wupeiqi '
- SELECT * from TB where name = ' Oldboy-wupeiqi ' limit 1
Global traversal and fetch only one bar
20.1000w data, when paging with limit offset, what is the more backward and slow? How to solve?
The more you go backwards, the more data you scan.
Solution: According to the requirements of the implementation, can be divided into
- Limit page views,
- Stores the primary key at both ends of the data on this page, and takes the number of bars forward or backward after the primary key is found
- In addition, if the data is not missing, you can also calculate the primary key by the number of pages
21. What is index merging?
Querying with multiple primary keys
22. What is an overlay index?
The contents of the query can be found directly in the primary key.
23. Brief description of database read/write separation?
Establish master-Slave relationships for high availability and reduce stress on the primary server
24. Brief description of database sub-Library sub-table? (Horizontal, vertical)
Level: Too many database fields
Vertical: Too many database rows
25.redis and memcached comparison?
Details
How many DB and function does the database default in 26.redis?
0-15, equivalent to a different library
27.python operating the Redis module?
Redis Module
28. If the amount of data in a list in Redis is very large, what if the implementation loops through each of the values?
def List_iter (name): """ Custom Redis list incremental Iteration :p name in Aram Name:redis, which is the list of iteration name : Return:yield returns the list element " " " = R.llen (name) for in Xrange (list_count): yield r.lindex (name, index)
29.redis How to implement master-slave replication? and the data synchronization mechanism?
在从服务器中配置 SLAVEOF 127.0.0.16380# 主服务器IP,端口
What is the role of Sentinel in 30.redis?
Monitor host status for high availability
31. How do I implement a Redis cluster?
Installing the Cluster software
How many hash slots are default in 32.redis?
16384
33. What are some of the persistence strategies for Redis?
---------RDB: snapshot format is to save the data in memory directly into a dump file, save the policy
---------aof: All the commands that modify the Redis server are stored in a file, a collection of commands
34. List the expiration policies for Redis support.
- VOLTILE-LRU: Pick the least recently used data from the set of data sets (Server.db[i].expires) that have expired time
- Volatile-ttl: Select the data that will expire from the set of expired data sets (Server.db[i].expires)
- Volatile-random: Choose data culling from any data set (Server.db[i].expires) that has an expiration time set
- ALLKEYS-LRU: Pick the least recently used data culling from the dataset (Server.db[i].dict)
- Allkeys-random: Choose data culling from data set (SERVER.DB[I].DICT)
- No-enviction (expulsion): Prohibition of eviction data
35.MySQL in the 2000w data, Redis only 20w of data, how to ensure that the Redis is hot data?
When the Redis memory data level goes up to a certain size, a data-retirement strategy is adopted to select the least recently used data culling from the data set (SERVER.DB[I].DICT)
36. Write code that implements FIFO, LIFO queue columns, priority queue columns based on the Redis column list.
classZhan:def __init__(self,conn): Self.conn=Conndefpush (Self,val): Self.conn.rpush ('AAA', Val)defpop (self):returnSelf.conn.rpop ('AAA') classDui:def __init__(self,conn): Self.conn=Conndefpush (Self,val): Self.conn.rpush ('BBB', Val)defGet (self):returnSelf.conn.lpop ('BBB') classXu:def __init__(self,conn): Self.conn=Conndefpush (Self,val,count): Self.conn.zadd ('CCC', Val,count)defGet (self): a= Self.conn.zrange ('CCC', 0, 0) [0] Self.conn.zrem ('CCC', a)returnA37. How do I implement Message Queuing columns based on Redis?
Maintains the list as a stack, setting the time-out for getting data
38. How can I implement publishing and subscriptions based on Redis? And the difference between a publish subscription and a message queue column?
Send message: Conn.publish (name, message)
Receive message: Conn.sunscribe (name)
Difference: Message Queuing, only one processor is received for the message, and all subscribers receive the message and process it.
39. What is Codis and function?
A distributed Redis solution provided by the Pea pod team
40. What is twemproxy and function?
Twemproxy also known as Nutcracker, is a memcache, the Redis protocol lightweight agent, a sharding for the middleware. With Twemproxy, the client does not directly access the Redis server, but is indirectly accessed through the Twemproxy proxy middleware.
Role: Shard Processing of REDIS data
41. Write code to implement REDIS transaction operations.
ImportRedis Pool= Redis. ConnectionPool (host='10.211.55.4', port=6379) Conn= Redis. Redis (connection_pool=pool)#transaction default is False, can only complete the role of batch submission, save network delay#The transaction function can be implemented after changing to true#pipe = R.pipeline (transaction=false)Pipe = Conn.pipeline (transaction=True)#Start a transactionPipe.multi () pipe.set ('name','Alex') Pipe.set ('role','SB') Pipe.lpush ('roless','SB') #SubmitPipe.execute ()What is the function of the Watch command in 42.redis?
Locking
43. How can I count the number of store items based on Redis??
The decr of the string can implement the self-subtraction operation
44. Brief introduction of Redis distributed lock?
A lock designed for a Redis cluster that prevents multiple tasks from modifying the database at the same time, essentially setting a time-out string for each host in the cluster, and when more than half of the machine settings in the cluster are successful, the locking succeeds until the lock expires or unlocks without a second task lock success
45. What is a consistent hash? Is there a corresponding module in Python?
Details
46. How to efficiently find all keys in Redis that start with Oldboy?
# Command mode # * Represents a wildcard character # Redis Module Import = Redis. Redis () Con.keys (Pattern='celery*'# * Represents a wildcard character
Python Interview Database