Classic Redis database of assessment exercises

Classic Redis database of appraisal exercise - topic

 

 

A, Redis database installation

Ask each student to first install the database, and ultimately can be used to log off the production end database.

Second, the database startup file parameter adjustment

Assume that the database server default port 6379 is already in use, require re-adjustment port 6380, and the client connection timeout set to 300 seconds automatically disconnected.

Third, a distributed master database from commissioning mode (using a stand-alone simulation)

It requires students to master database port to 6379, from the database port is set to 6380, after a successful configuration requirements can be accessed data between two databases, the requirements can not be falsified data in the main database from the database, and do the appropriate test.

Fourth, the program title.

Redis database connection requires the use of Java program to achieve the hash table type structure designed to students' personal information on file, for example.

① increase logging: student records to the hash table insert fields: Student ID, name, age, class, professional, course name, score, and the assignment of each field according to the actual circumstances of each person.

  ② Delete record: professional fields delete, delete all keys to show the current is still in the database.

  ③ Change History: original score by 10 points, the value of the changed print display.

  ④ inquiry record: style queries appear as: XXX participated NOSQL database test scores are XX.

 

Reference - answer

Scoring rules:

A, the Redis database installation (the big problem in 2 small problems, each of 10 points, 20 points)

  1. Database icon will be displayed below the installation is successful: (10 minutes)

 

 


  1. Add the following statement in glogin.sql file: ALTER SE (10 points)

Second, the database adjustment parameter the startup file (the big problem in 2 small problems, each of 10 points, 20 points)

  1. Using notepad ++ or Notepad open redis.windows.conf start control port parameter to locate files 6380; (10 minutes)
  2. Using notepad ++ or Notepad open the control file redis.windows.conf startup timeout parameter to find 300; (10 minutes)

Third, a distributed master database from the debug mode of operation (the big issue a total of 1 small problems, each of 20 points, 20 points)

1. Create and modify database from the port to 6380. (5 points)

2.  搭建好主从数据库关系后(5分),进行写值与读值验证(5分),还有从数据库中尝试删除键值对,因为从数据库只有可读权限所以正常情况是无法进行修改的。(5分)

  具体操作如下:

 

 

 

 

 

 

 

 

 

 

 

 

四、程序题(本大题共4小题,每小题10分,共40分)

 ①增加记录功能:往学生档案哈希表中插入字段:学号、姓名、年龄、班级、专业、联系方式、课程号、课程名称,分数,课时并且根据每个人的实际情况对每个字段赋值。(10分)答案只列出核心部分代码如下:

        System.out.println("学生档案中添加学号和value键值对:"+shardedJedis.hset("学生档案", "学号", "201654545656"));;(1分)

        System.out.println("学生档案中添加姓名和value键值对:"+shardedJedis.hset("学生档案", "姓名", "XXXX")); (1分)

        System.out.println("学生档案中年龄和value键值对:"+shardedJedis.hset("学生档案", "年龄", "19"));(1分)

        System.out.println("学生档案中班级和value键值对;"+shardedJedis.hset("学生档案", "班级", "16科计3班"))(1分)

        System.out.println("学生档案中专业和value键值对;"+shardedJedis.hset("学生档案", "专业", "计算机科学与技术"))(1分)

System.out.println("学生档案中专业和value键值对;"+shardedJedis.hset("学生档案", "联系方式", "计算机科学与技术"))(1分)

System.out.println("学生档案中课程号和value键值对;

"+shardedJedis.hset("学生档案", "课程号", "3452345"))(1分)

System.out.println("学生档案中课程名称和value键值对;"+shardedJedis.hset("学生档案", "课程名称", "NOSQL"))(1分)

System.out.println("学生档案中课程名称和value键值对;"+shardedJedis.hset("学生档案", "课时", "16"))(1分)

        System.out.println("学生档案中分数和value键值对;"+shardedJedis.hset("学生档案", "分数", "90"))(1分)

 

  ②删除记录功能:对专业的字段进行删除,删除后要显示出当前还在数据库中的健值。(10分)

 System.out.println("学生档案中删除专业键值对:"+shardedJedis.hdel("学生档案","专业"));(5分)

 System.out.println("学生档案中的所有值"+shardedJedis.hvals("学生档案"))(5分)

 

  ③更改记录功能:对原分数增加10分,将更改后的值进行打印显示。(10分)

      System.out.println("分数整型键值的值增加10"+shardedJedis.hincrBy("学生案档", "10", ));(5分)

        System.out.println("学生档案中的所有值:"+shardedJedis.hvals("学生档案"));(5分)

 

  ④查询记录功能:查询内容样式显示为:XXX参加了NOSQL数据库考试,分数是XX。

      System.out.println(shardedJedis.hget("学生档案", "姓名")+"参加了NOSQL数据库考试,分数是”+ shardedJedis.hget("学生档案", "分数"));(显示姓名得5分,显示分数得5分)

 

Guess you like

Origin www.cnblogs.com/Raodi/p/11590171.html