F
F
FRANZEE2019-07-08 01:00:19
SQL
FRANZEE, 2019-07-08 01:00:19

How to name the data structure, in Russian, due to which the query in sqlite will be executed faster?

Hello, I'm going through an online quest for android developers https://contest.yandex.ru/droid_mission
I can't solve the problem :)
Task: On a
quiet Friday evening, two agents stay late and have an insoluble argument. They were instructed to store a large amount of secret data in a Sqlite database with an integer key key.
Agent A creates a table with a query like:

CREATE TABLE t(key INT PRIMARY KEY, secret_value_1, secret_value_2)
, and agent B - with a request of the form
CREATE TABLE t(key INTEGER PRIMARY KEY ASC, secret_value_1, secret_value_2)
.
Agent A is absolutely sure that there is no error in his request, but agent B has an argument against this: he claims that data integrity may be violated when agent A approaches.
Separate by commas: a column or columns that are responsible for the integrity of agent B, but not responsible for agent A; as well as the data structure, in Russian, due to which the request of agent B will be executed faster.
Question:
I don’t understand what’s the matter, I already googled that INTEGER (alias ROWID) is faster instead of INT. The second thing that seems to me I don’t understand is to write a data structure in Russian, in Russian, due to which the request of agent B will be executed faster. I think it's an index.
I answered key, index but this is not the correct answer.
What do you think about this task?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Boris Korobkov, 2019-07-08
@BorisKorobkov

1. "ROWID"
https://sqlite.org/lang_createtable.html#rowid
2. "auto-increment"
https://www.sqlite.org/datatypes.html

One exception to the typelessness of SQLite is a column whose type is INTEGER PRIMARY KEY. (And you must use "INTEGER" not "INT". A column of type INT PRIMARY KEY is typeless just like any other.)
INTEGER PRIMARY KEY columns can be used to implement the equivalent of AUTOINCREMENT. If you try to insert a NULL into an INTEGER PRIMARY KEY column, the column will actually be filled with an integer that is one greater than the largest key already in the table.

Before inserting, agent B will automatically be prompted for the primary key
, while agent A has a complete search of the table
SELECT MAX(key) + 1 FROM t

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question