primary-key

Java: Merging two json objects together with primary key

我的未来我决定 提交于 2019-12-05 12:33:21
Lets say I have two arrays of JSONObjects in memory and each object has a key that is similar in both arrays: Array 1 [ { "name": "Big Melons Co.", "location": "Inner City Dubai" "id": "1A" }, { "name": "Pear Flavored Juices Ltd", "location": "Seychelles" "id": "2A" }, { "name": "Squeeze My Lemons LLC", "location": "UK" "id": "3A" }, {other JSON Objects...} ] Array 2 [ { "acceptsCard": "true" "id": "1A" }, { "acceptsCard": "false" "id": "2A" }, { "acceptsCard": "false" "id": "3A" }, {other JSON Objects...} ] Now, I want to merge the two arrays together based on the primary key of "id" so they

How predictable is NEWSEQUENTIALID?

时间秒杀一切 提交于 2019-12-05 11:28:38
According to Microsoft's documentation on NEWSEQUENTIALID , the output of NEWSEQUENTIALID is predictable. But how predictable is predictable? Say I have a GUID that was generated by NEWSEQUENTIALID , how hard would it be to: Calculate the next value? Calculate the previous value? Calculate the first value? Calculate the first value, even without knowing any GUID's at all? Calculate the amount of rows? E.g. when using integers, /order?id=842 tells me that there are 842 orders in the application. Below is some background information about what I am doing and what the various tradeoffs are. One

Should I obscure primary key values?

爷,独闯天下 提交于 2019-12-05 11:19:23
问题 I'm building a web application where the front end is a highly-specialized search engine. Searching is handled at the main URL, and the user is passed off to a sub-directory when they click on a search result for a more detailed display. This hand-off is being done as a GET request with the primary key being passed in the query string. I seem to recall reading somewhere that exposing primary keys to the user was not a good idea, so I decided to implement reversible encryption. I'm starting to

Do numerical primary keys of deleted records in a database get reused for future new records?

做~自己de王妃 提交于 2019-12-05 11:03:02
For example if I have an auto-numbered field, I add new records without specifying this field and let DB engine to pick it for me. So, will it pick the number of the deleted record? If yes, when? // SQL Server, MySQL. // Follow-up question: What happens when DB engine runs out of numbers to use for primary keys? NO. numerical primary keys will not reused, except you specify them manually(you should really avoid this!) AFAIK, this could happen in MySQL: How AUTO_INCREMENT Handling Works in InnoDB : InnoDB uses the in-memory auto-increment counter as long as the server runs. When the server is

MySQL Views in Navicat - How to define 'primary key'?

烂漫一生 提交于 2019-12-05 10:49:24
Often when I define a View in Navicat I receive the following message: xxx does not have a primary key. Updates to this table will be done using the following pseudo statement: UPDATE xxx SET ModifiedFieldsAndValues WHERE AllFieldsAndOldValues LIMIT 1 Obviously I only use my Views for viewing data, not updating . But this did make me curious: Is there a way to define a "primary key" or "unique index" on a View? its implied that the view uses the indices and primary keys of its base table. You can change the semantics of how insert and updates occur when using them via views by playing with the

How to set primary key with auto increment in MongoDB? [duplicate]

别等时光非礼了梦想. 提交于 2019-12-05 10:07:18
问题 This question already has answers here : How do you implement an auto-incrementing primary ID in MongoDB? (7 answers) Closed 5 years ago . How to set primary key with auto increment in MongoDB ? Normally MongoDB generates ObjectID. I wanna use my own auto increment primary key like MySQL. Examples would be appreciated :) 回答1: I blogged about this here: http://www.alexjamesbrown.com/blog/development/mongodb-incremental-ids/ I also started a int id generator for the C# driver: https://github

How to manually set entity primary key in Entity Framework code first database?

被刻印的时光 ゝ 提交于 2019-12-05 07:48:09
Well, I have the following model structure: I have one class - DatabaseEntity which is basically public class DatabaseEntity { public int Id { get; set; } } so each entity like product, category etc will inherit DatabaseEntity and have Id property. Also I have typical EntityFramework repository class with InsertOrUpdate method: private readonly DbContext _database; public void InsertOrUpdate<TObject>(TObject entity) where TObject : DatabaseEntity { if(entity.Id == default(int)) { // New entity DbSet<TObject>().Add(entity); } else { // Existing entity _database.Entry(entity).State = EntityState

Finding the height of the B-Tree of a table in SQL Server

旧城冷巷雨未停 提交于 2019-12-05 06:10:23
Since database data is organized in 8k pages in a B-tree, and likewise for PK information information, it should be possible for each table in the database to calculate the height of the B-Tree. Thus revealing how many jumps it takes to reach certain data. Since both row size and PK size is of great importance, it is difficult to calculate since eg varchar(250) need not take up 250 bytes. 1) Is there a way to get the info out of SQL Server? 2) if not, is it possible to give a rough estimate using some code analyzing the tables of the db? YES! Of course! Check out the DMV = dynamic management

Oracle primary keys: NUMBER vs NUMBER(7,0)

核能气质少年 提交于 2019-12-05 05:43:51
Is there any benefit to specifying the precision on the PK? Is 7,0 sufficient, given that there will probably never be more than a few thousand records? Any dangers to not specifying the precision? Quassnoi NUMBER(7, 0) just constrains the domain of values. Their internal represenations do not differ: CREATE TABLE t_pk (col1 NUMBER(7, 0) NOT NULL, col2 NUMBER(38) NOT NULL) INSERT INTO t_pk VALUES (9999999, 9999999) SELECT DUMP(col1), DUMP(col2) FROM t_pk DUMP(col1) DUMP(col2) --- --- Typ=2 Len=5: 196,10,100,100,100 Typ=2 Len=5: 196,10,100,100,100 In Oracle , the NUMBER s are stored as

Turnoff mysql unsafe statement warning

↘锁芯ラ 提交于 2019-12-05 04:33:36
I am using log-error to write warning/errors into a file. When I perform INSERT IGNORE..SELECT statement, it just keep write this warning messages. 120905 3:01:23 [Warning] Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT IGNORE... SELECT is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are ignored. This order cannot be predicted and may differ on master and the slave. I want to stop mysql logwriter keep writing the error above over and over. (I can't see other log because they fillout