database-design

Continuous queries in Influxdb ignoring where clause?

无人久伴 提交于 2020-01-17 05:15:42
问题 I'm having a bit of a trouble with the continuous queries in influxdb 0.8.8. I'm trying to create a continuous query but it seems that the where clauses are ignored. I'm aware about the restrictions mentioned here: http://influxdb.com/docs/v0.8/api/continuous_queries.html but I don't consider that this would be the case here. One row in the time series would contain data like this: {"hex":"06a0b6", "squawk":"3421", "flight":"QTR028 ", "lat":99.867630, "lon":66.447365, "validposition":1,

How to update fields based on value of other record

风格不统一 提交于 2020-01-17 04:59:25
问题 I have a table resembling the following structure: City start_date end_date Paris 1995-01-01 00:00:00 1997-10-01 23:59:59 Paris 1997-10-02 00:00:00 0001-01-01 00:00:00 Paris 2013-01-25 00:00:00 0001-01-01 00:00:00 Paris 2015-04-25 00:00:00 0001-01-01 00:00:00 Berlin 2014-11-01 00:00:00 0001-01-01 00:00:00 Berlin 2014-06-01 00:00:00 0001-01-01 00:00:00 Berlin 2015-09-11 00:00:00 0001-01-01 00:00:00 Berlin 2015-10-01 00:00:00 0001-01-01 00:00:00 Milan 2001-01-01 00:00:00 0001-01-01 00:00:00

Inventory Database Design

混江龙づ霸主 提交于 2020-01-17 02:55:35
问题 I got 2 tables User and Company . These two have a inventory. DataTables Item ItemId | Name ================ 1 | Glass 4 | Wood User UId | Name ============ 1 | Max Company CId | Name ================== 1 | EvilCorp Inventory RowId | UId | CId | ItemId | amount ================================================= 1 | 2 | Null | 4 | 10 2 | 23 | Null | 4 | 5 3 | Null | 1 | 1 | 7 4 | Null | 1 | 4 | 70 Let say I have 500 users and 300 companys and every one has 20 inventory slots, I will have 16000

SQL join - one column serving as ID for two columns in another table

旧巷老猫 提交于 2020-01-17 02:50:27
问题 Okay, maybe I've absolutely goofed on the thought process behind this and I need put in my place, or maybe I'm not far off. I have one table called TEAMS with two columns: teamID and teamName. I then have another table called WEEK12 with three columns: gameID, homeID and awayID. I thought maybe I could use the teamID in the homeID and awayID columns for the WEEK12 table and then join that with the TEAMS table to match those two columns up with the team names. Unfortunately, I'm not having any

How to design the database schema to link two tables via lots of other tables

本小妞迷上赌 提交于 2020-01-16 19:14:06
问题 Although I'm using Rails, this question is more about database design. I have several entities in my database, with the schema a bit like this: http://fishwebby.posterous.com/40423840 If I want to get a list of people and order it by surname, that's no problem. However, if I want to get a list of people, ordered by surname, enrolled in a particular group, I have to use an SQL statement that includes several joins across four tables, something like this: SELECT group_enrolment.*, person.* FROM

Many to Many relationships in Django

五迷三道 提交于 2020-01-16 19:13:08
问题 I am working on a design for some models in Django and wanted to get some advice. I have a model for teams, of which many users can be a part of. The users can also be members of many teams, but they cannot be members of the same team twice. There is also separate information I want to track for each team/user combo. On top of that, there will be a user who is an "admin" for each team, but each team may have only a single admin. I have some condensed data model definitions as follows: class

Many to Many relationships in Django

喜欢而已 提交于 2020-01-16 19:12:26
问题 I am working on a design for some models in Django and wanted to get some advice. I have a model for teams, of which many users can be a part of. The users can also be members of many teams, but they cannot be members of the same team twice. There is also separate information I want to track for each team/user combo. On top of that, there will be a user who is an "admin" for each team, but each team may have only a single admin. I have some condensed data model definitions as follows: class

How to lock a specific row that doesn't exist yet in SQL Server

a 夏天 提交于 2020-01-16 12:06:27
问题 I have an API rate limit table that I'm managing for one of our applications. Here's the definition of it. CREATE TABLE [dbo].[RateLimit] ( [UserId] [int] NOT NULL, [EndPointId] [smallint] NOT NULL, [AllowedRequests] [smallint] NOT NULL, [ResetDateUtc] [datetime2](0) NOT NULL, CONSTRAINT [PK_RateLimit] PRIMARY KEY CLUSTERED ([UserId] ASC, [EndPointId] ASC) ) ON [PRIMARY] The process that performs CRUD operations on this table is multi-threaded, and therefore careful consideration needs to be

Better way to add extra attributes in RBAC (Role Based Access Control) tables?

断了今生、忘了曾经 提交于 2020-01-16 08:33:33
问题 I have implemented RBAC (Role Based Access Control) tables. I have a requirement to add extra attribute on some roles, like 2nd_pwd attribute in Admin role, address attribute in Customer role. I have done this design, but it violates data integrity. When you removed (let's say) Admin role, you also need to remove admin data from Admin table. So I decided to add trigger for this job. Question: Is there a design for this requirement without trigger but still doesn't violate data integrity? What

Perform Joins in O(n) time?

左心房为你撑大大i 提交于 2020-01-16 06:13:28
问题 is there a way to Join 2 tables in linear time? I heard this can be done by having another data structure (Hashtable), but I'm not sure how this can be done. I was always wondering a Join will involve a cross-product and hence it is O(n^2). 回答1: Algorithm: Loop through table A. Hash all Items, Add them to the Join array. Loop through table B, check each item if it's in the hash table (Check - O(1)), if not, add to the Join table. 回答2: If there are indexes available on columns used in the join