Create GUIDs online Global Unique Primary Key Author: QQ 14588019 WonderfulLife In this example, the guid number cannot be used as the id of the details. If you do this, the details will not be queried, let alone paging. https://www.guidgen.com/ Baidu Pickup Coordinate System http://api.map.baidu.com/lbsapi/getpoint/index.html webmaster tools time to unix timestamp http://tool.chinaz.com/Tools/unixtime.aspx If there is such a master-slave watch, it records the trajectory of everyone in the country in their lifetime, and records the latitude and longitude coordinates every 1 second. In this way, we can analyze the user's living habits based on this basic data. T95 Wuchang-Shenzhen train timetable 114.324393, 30.534197 Wuchang Railway Station 17:40 114.295448, 29.885403 Xianning Railway Station 18:28 113.936372,29.727576 Chibi Railway Station 18:56 113.019455, 28.200103 Changsha Railway Station 21:17 113.520746, 24.756814 Shaoguan East Railway Station 02:11 113.262337, 23.153768 Guangzhou Railway Station 04:32 114.123611, 22.537961 Shenzhen Railway Station 06:13 Yang Fan's ride time 2018-04-25 17:40:00 In one day, the location table locations will generate 86400 records. The schedule will generate 2592000 records in 1 month (approximately 2.6 million records), and 946080000 records in 1 year (approximately 950 million records) So such a master-slave table is a one-to-many data model. If this tracking system for recording life moments starts from Yang Fan's 18-year-old ride on the T95 Wuchang-Shenzhen train to record his moving route, Skip the serial number 18 years ago 946080000 x 18 = 17029440000 (pieces), then the first serial number assigned to him by the system It should be 1017029440001. This digit integer is enough for a long-lived person. Give Yang Fan an ID number 430523198612060001 in Shaoyang County, Hunan users table (main table) userid username mobile 430523198612060001 Yang Fan13500135000 430523198612060002 Field 13800138000 locations table (from table) unixtime longitude latitude userid id 1524649200 114.324393 30.534197 430523198612060001 430523198612060001:1017029440001 1524652080 114.295448 29.885403 430523198612060001 430523198612060001:1017029442881 1524653760 113.936372 29.727576 430523198612060001 430523198612060001:1017029444561 1524662220 113.019455 28.200103 430523198612060001 430523198612060001:1017029453021 1524679860 113.520746 24.756814 430523198612060001 430523198612060001:1017029470661 1524688320 113.262337 23.153768 430523198612060001 430523198612060001:1017029479121 1524694380 114.123611 22.537961 430523198612060001 430523198612060001:1017029485181 Special reminder that the main table records too many births, old age, sickness and death. Every 100,000 ID card numbers are stored as a group in a queue or an ordered set. This kind of performance is excellent, and the paging requires the ID card collection number to expand the capacity is also very large, and it can also be queried by paging, for example: The key of the first group ID number collection queue name can be named user:list:100000 430523198612060001 The key of the 2nd group ID number collection queue name can be named user:list:200000 420921198612069999 MULTI INCR user:count # According to the number of users, the ID number of the current user should be stored in that group of queues. # The number of new users has reached 503649, so it should be stored in the queue with the key name user:list:600000 GET user:count SET user:430523198612060001 "{\"username\":\"杨帆\",\"mobile\":\"13500135000\"}" LPUSH user:list:100000 430523198612060001 # The set of ID numbers saved in the queue is used for paging EXEC ======================================================================================================== Add Item 1 details SET user:430523198612060001:start 1017029440001 # The start point of the first track recorded by the system MULTI SET user:430523198612060001:1017029440001 "{\"unixtime\":1524649200,\"longitude\":114.324393,\"latitude\":30.534197}" SET user:430523198612060001:current 1017029440001 # ID number assigned by the system in real time EXEC --------------------------------------------------------------------------------------------------- ... ... ... ... ... ... ... ... ... ... ... ... --------------------------------------------------------------------------------------------------- Added section 2880 details MULTI SET user:430523198612060001:1017029442881 "{\"unixtime\":1524652080,\"longitude\":114.295448,\"latitude\":29.885403}" SET user:430523198612060001:current 1017029442881 # ID number assigned by the system in real time EXEC -------------------------------------------------------------------------------------------------- ... ... ... ... ... ... ... ... ... ... ... ... -------------------------------------------------------------------------------------------------- Added section 4560 details MULTI SET user:430523198612060001:1017029444561 "{\"unixtime\":1524653760,\"longitude\":113.936372,\"latitude\":29.727576}" SET user:430523198612060001:current 1017029444561 # ID number assigned by the system in real time EXEC -------------------------------------------------------------------------------------------------- ... ... ... ... ... ... ... ... ... ... ... ... -------------------------------------------------------------------------------------------------- New section 13020 details MULTI SET user:430523198612060001:1017029453021 "{\"unixtime\":1524662220,\"longitude\":113.019455,\"latitude\":28.200103}" SET user:430523198612060001:current 1017029453021 # ID number assigned by the system in real time EXEC -------------------------------------------------------------------------------------------------- ... ... ... ... ... ... ... ... ... ... ... ... --------------------------------------------------------------------------------------------------- Added section 30660 details MULTI SET user:430523198612060001:1017029470661 "{\"unixtime\":1524679860,\"longitude\":113.520746,\"latitude\":24.756814}" SET user:430523198612060001:current 1017029470661 # The id number assigned by the system in real time EXEC -------------------------------------------------------------------------------------------------- ... ... ... ... ... ... ... ... ... ... ... ... -------------------------------------------------------------------------------------------------- Added details of Article 39120 MULTI SET user:430523198612060001:1017029479121 "{\"unixtime\":1524688320,\"longitude\":113.262337,\"latitude\":23.153768}" SET user:430523198612060001:current 1017029479121 # ID number assigned by the system in real time EXEC -------------------------------------------------------------------------------------------------- ... ... ... ... ... ... ... ... ... ... ... ... ------------------------------------------------------------------------------------------------- Added details of Article 45180 MULTI SET user:430523198612060001:1017029485181 "{\"unixtime\":1524694380,\"longitude\":114.123611,\"latitude\":22.537961}" SET user:430523198612060001:current 1017029485181 # The id number assigned by the system in real time EXEC ******************************************************************************************************************* Main table paging query LLEN user:list:100000 # Returns the total number of records LRANGE user:list:100000 0 20 # This is the primary key of 20 records on page 1 LRANGE user:list:100000 21 40 # This is the primary key of 20 records on page 2 LRANGE user:list:100000 41 60 # This is the primary key of 20 records on page 3 LRANGE user:list:200000 41 60 # This is the primary key of 20 records on page 50003 LRANGE user:list:200000 61 80 # This is the primary key of 20 records on page 50004 Detailed query GET user:430523198612060001:start # First get the primary key suffix serial number of the first active track, and the return value is 1017029440001 It is easy to infer that the primary key numbers of 20 consecutive detail records are as follows: user:430523198612060001:1017029440001 user:430523198612060001:1017029440002 user:430523198612060001:1017029440003 user:430523198612060001:1017029440004 user:430523198612060001:1017029440005 user:430523198612060001:1017029440006 user:430523198612060001:1017029440007 user:430523198612060001:1017029440008 user:430523198612060001:1017029440009 user:430523198612060001:1017029440010 user:430523198612060001:1017029440011 user:430523198612060001:1017029440012 user:430523198612060001:1017029440013 user:430523198612060001:1017029440014 user:430523198612060001:1017029440015 user:430523198612060001:1017029440016 user:430523198612060001:1017029440017 user:430523198612060001:1017029440018 user:430523198612060001:1017029440019 user:430523198612060001:1017029440020 This is the primary key set of latitude and longitude coordinates of Yang Fan's active track on page 1 According to this reasoning, I can choose any one-hour, three-hour, or 10-minute activity track to query separately, but I just need to write a simple algorithm to get the query results.After this article is explained, it may not be published commercially without permission!
Redis key-value database nosql data modeling (4)------ How to store master-slave table data one-to-super-many relationship
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=325865487&siteId=291194637
Recommended
Ranking