aa r X i v : . [ qu a n t - ph ] M a y Database Manipulation on Quantum Computers
Ahmed Younes ∗ Department of Math. & Comp. ScienceFaculty of ScienceAlexandria UniversityAlexandria, EgyptMay 22, 2018
Abstract
Manipulating a database system on a quantum computer is an essential aim to benefit fromthe promising speed-up of quantum computers over classical computers in areas that take a vastamount of storage and processing time such as in databases. In this paper, the basic operations formanipulating the data in a quantum database will be defined, e.g. INSERT, UPDATE, DELETE,SELECT, backing up and restoring a database file. This gives the ability to perform the dataprocessing, that usually takes a long processing time on a classical database system, in a simulta-neous way on a quantum computer. Defining a quantum version of more advanced concepts usedin database systems, e.g. the referential integrity and the relational algebra, is a normal extensionto this work.
Quantum computers promise to do computation more powerfully [26] than classical computers due tothe ability of a quantum computer to be in some states that have no equivalence in a classical computersuch as a superposition of values and/or an entanglement between some particles of a quantum system[14]. A superposition is the ability to have more than one value stored simultaneously over the samephysical space while an entanglement is the existence of a hidden correlation between the particles ofa quantum system [5] so that applying an operation on an entangled particle will apply that operationon all the particles entangled with that particle [7]. A quantum computer exploits a superposition toperform parallel computation on many values simultaneously at the bit level while a classical computercan perform simultaneous operations at the CPU level [22].To extract information from a quantum computer, a system measurement must be used [22]. If thatquantum computer exists in a superposition, the measurement will break the superposition to one ofthe superposed values in a random manner. Otherwise, a quantum computer behaves classically, i.e. ifno superposition exists. Many useful methods are known to increase the probability of a required valueto be found with a probability close to certainty when the measurement is applied [10, 19, 9, 8, 28].Many quantum algorithms exploit a superposition and/or an entanglement to perform computationfaster than it can be done on classical computers [25, 15, 31], where all the possible inputs of a problemare examined simultaneously. A superposition can be understood as a list of values superposed togetheron the same memory location. A database file is a two dimensional data structure (a table) whereevery column represents a field over certain data type and every row represents a record (a collectionof related fields) [21]. A database file is simply a list of unique records. Combining the fields in eachrecord in some fixed binary representation, a list of records can be manipulated as a list of values thatcan exist in a superposition on a quantum computer.Structured Query Language (SQL) is a tool widely used in manipulating the classical databases[21]. Basic operations in SQL include inserting a new record to a database file (INSERT), updating an ∗ [email protected] The quantum bit ( qubit [24]) is the quantum analogue of the classical bit. The basic difference betweenthe qubit and the classical bit is that the qubit can exist in a linear superposition of the two states | i and | i at the same time ( Quantum Parallelism ), a | i + b | i , (1)where a and b are complex numbers called the amplitudes of system and satisfy the condition | a | + | b | = 1. The states | i and | i can be taken as the classical bit values 0 and 1 respectively. | i is calledthe Dirac notation [12] and is considered as the standard notation for describing quantum states. Inquantum circuits shown in this paper, a qubit will be represented as a horizontal line and the timeflow of the circuit will be from left to right.
Consider the case where we have a quantum system (quantum register) with more than one qubit. Inconventional computers, a two-bit register will be able to carry only one value out of the four possiblevalues { , , , } at a time. The corresponding states in a two-qubit quantum register will be {| i , | i , | i , | i} , so its state in a superposition can be represented as, | ψ i = a | i + a | i + a | i + a | i , (2)where a i are complex numbers satisfy the condition P i | a i | = 1. Any measurement applied on thequbits will lead to one of the four possible states | i i with probability | a i | , where i is the integerrepresentation of that state.Before we go further, it is important to review some useful mathematical concepts [20, 22]: Thestate of n -qubit quantum system can be represented as a vector of length 2 n over Hilbert space . Statescan be represented via either the vector/matrix notation, or Dirac Notation (Ket/Bra notation)[12].Dirac Notation is more useful for describing the quantum states and the evolution of the state of thesystem, it can be understood as follows: • Ket | ψ i : denotes a column vector that represents a quantum state. • Bra h ψ | : denotes a row vector that represents the dual of the ket, i.e. the complex conjugatetranspose of | ψ i . • The inner product of two vectors is written as h ψ | | ξ i or shortly h ψ | ξ i . Notice that, since | i isa unit vector, we have h | i = 1 and since | i and | i are orthogonal, we have h | i = 0. • The outer product of two vectors is written as | ψ i h ξ | . A matrix (operator) can be represented inthe outer product form, where it is sometimes called the diagonal representation of that operator.For example, the Identity gate can be represented as follows, I = | i h | + | i h | = (cid:20) (cid:21) . (3)2 The tensor product of two vectors | ψ i and | ξ i is written as | ψ i ⊗ | ξ i and is used to combinesmaller quantum systems in a single larger quantum system. For example, let | ψ i and | ξ i bevectors from a two-dimensional complex vector space spanned by the basis {| i , | i} . The tensorproduct of | ψ i and | ξ i will have the basis,( | i ⊗ | i , | i ⊗ | i , | i ⊗ | i , | i ⊗ | i ) , (4)where the order of the basis is arbitrary as long as it is fixed, which can be re-written shortly as,( | i , | i , | i , | i ) . (5)Similarly, basis for a three-qubit system will be,( | i , | i , | i , | i , | i , | i , | i , | i ) . (6)Now, we can view the state of a single-qubit as a vector in the two-dimensional complex vectorspace spanned by the orthonormal basis {| i , | i} as follows, a | i + b | i = (cid:20) ab (cid:21) , (7)where, | i = (cid:20) (cid:21) , | i = (cid:20) (cid:21) . (8)Similarly, the state of a two-qubit quantum register is a vector in the four-dimensional complexvector space spanned by the orthonormal basis {| i , | i , | i , | i} as follows, a | i + a | i + a | i + a | i = a a a a , (9)where, | i = , | i = , | i = , | i = . (10)For a quantum system of n qubits, the resulting state space is of dimension 2 n . If the qubits ofthis quantum system are all initialised to the same state, for example, state | i , it can be writtenshortly as | . . . i = | i ⊗ n . This exponential growth of the state space with the linear increasein the number of qubits is one of the reasons for the possibility of an exponential increase in thespeed of computation on quantum computers over classical computers [22]. • The tensor product of two operators U and V is written as U ⊗ V and is used to combine smallerquantum operators in a single larger operator. For example, let U and V to be single-qubitoperators (2 × U = (cid:20) u u u u (cid:21) , V = (cid:20) v v v v (cid:21) . (11)Consider a two-qubit system | ψ i ⊗ | ξ i . Applying U on | ψ i and V on | ξ i in parallel can be writtenas follows, 3 ⊗ V ( | ψ i ⊗ | ξ i ) = U | ψ i ⊗ V | ξ i . (12)where U ⊗ V can be combined in a single matrix of size 4 × U ⊗ V = (cid:20) u u u u (cid:21) ⊗ (cid:20) v v v v (cid:21) = u (cid:20) v v v v (cid:21) u (cid:20) v v v v (cid:21) u (cid:20) v v v v (cid:21) u (cid:20) v v v v (cid:21) = u v u v u v u v u v u v u v u v u v u v u v u v u v u v u v u v . (13)If U is, for example, a 2 × n times, so it can be written shortlyas U ⊗ U ⊗ ... ⊗ U = U ⊗ n , where the resulting matrix will be of size 2 n × n . More details ontensor products and their properties can be found in [17, 22, 23]. In general, quantum computation process can be understood as applying a series of quantum gatesfollowed by applying a measurement to obtain the result [20]. Quantum gates used during the com-putation must follow the fundamental laws of quantum physics [12]. To satisfy this condition, usingany matrix U as a quantum gate, it must be unitary, i.e. the inverse of that matrix must be equal toits complex conjugate transpose: U − = U † and U U † = I , where U − denotes the inverse of U , U † denotes the complex conjugate transpose of U and I is the identity matrix. Any gate applied on aquantum register of size n can be understood by its action on the basis vectors and can be representedas a unitary matrix of size 2 n × n .For example, the N OT gate is a single input/output gate that inverts the state | i to | i and visaversa. Its 2 × N OT = (cid:20) (cid:21) . Another important example is the Hadamardgate ( H gate) which produces a completely random output with equal probabilities to be | i or | i at any measurement. Its 2 × H = √ (cid:20) − (cid:21) . Hadamard gate has a specialimportance in setting up a superposition of a quantum register. Consider a three qubits quantumregister | i , applying Hadamard gate on each of them in parallel will set up a superposition of the2 possible states. Applying any operation on that register afterward will be applied on the 2 statessimultaneously.Controlled operations play an important role in building up quantum circuits for any given opera-tion [2]. The Controlled- U gate is a general controlled gate with one or more control qubit(s) as shownin Fig. 1.a. It works as follows: U is applied on the target qubit | t i if and only if all | x k i are set to | i ,i.e. qubits will be transformed as follows, | x k i → | x k i , k : 0 → n − , | t i → | t CU i = U x x ...x n − | t i , (14)where x x ...x n − in the exponent of U denotes the AN D -ing operation of the qubit-values x , x , ..., x n − .If U in the general case is replaced with the N OT gate mentioned above, the resulting gate is called
CN OT gate (shown in Fig. 1.b). It inverts the target qubit if and only if all the control qubits are setto | i as follows, | x k i → | x k i ; k : 0 → n − , | t i → | t CN i = | t ⊕ x x ...x n − i , (15)4 ①① ①①①❤①①❤ ... ... | x i| x i | x i | x i| x i| x i | x i | x i| t CU i| t i | t i | t CN i| x n − i| x n − i | x n − i | x n − i U b. CN OT a. Controlled- U Figure 1: Controlled gates. The back circle • indicates the control qubits, and the symbol ⊕ in part(b.) indicates the target qubit.where ⊕ is the classical XOR operation.
A state of a quantum system of two or more qubits can be represented in terms of the tensor productof each qubit. Sometimes it is not possible to represent the state of the system in terms of the statesof its individual qubits. In such a case, we say that there is a correlation between these components,i.e. each component does not have its own state. This is usually referred to as an entangled state [4, 5, 13, 22].For example [22], the state a | i + b | i cannot be decomposed into the states of two separatequbits, i.e. we cannot find a , a , b and b such that,( a | i + b | i ) ⊗ ( a | i + b | i ) = a | i + b | i . (16)Entangled states are considered as the heart for many quantum algorithms, for example, quantumteleportation [7], dense coding [3] and quantum searching [1, 11]. Two-qubit entangled states (shownin Eqn. 17) are usually referred to as Bell states, EPR states, EPR pairs [20] or
Bell basis [16].( | i ± | i ) √ , ( | i ± | i ) √ . (17) Before defining the operators of the QQL, three basic operations must be defined. Firstly, a simple wayto convert the standard irreversible logic operations, e.g. AND, OR, NOT...etc[6], to reversible logicoperations suitable for quantum computers. This has a special importance in applying an arbitraryoperation based on two or more SELECT operators. Then, a quantum oracle that applies a query on a database file exists in a superposition and returns the result(s) of the query entangled with atemporary qubit dedicated for subspace identification purposes. Finally, an operator that acts only ona certain subspace of the system to be used in the process of backing up and restoring a portion of aquantum database.
CN OT gates)
A logical expression is an expression that has two operands connected with a logical operator from theset { >, ≥ , <, ≤ , = , = } . A logical expression evaluates either to true (1) or to false (0). A relationalexpression is an expression that combines two or more logical expressions with relational operatorssuch as AN D , OR and N OT , e.g. ( x OR ( N OT x )), where x , x ∈ { , } . These sort of relationalexpressions cannot be used directly as quantum relational expressions because thier operations arenot reversible [27]. A relational expression can be understood as a Boolean function while the logicalexpressions are the Boolean inputs to that Boolean function .In building quantum circuits for Boolean functions, an extra temporary qubit will be added to thesystem and will be initialized to state | i , to hold the result of the Boolean function at the end of the5 ①❤ | x i| x i| x i| x i Figure 2:
CN OT ( { x , x } | x ) gate. ①① ① ❤❤❤ | x i| x i| x i Figure 3: Boolean quantum circuit.computation. For clarity purposes, the
CN OT gates will be presented as follows [18]:
CN OT ( C | t ) isa gate where the target qubit | t i is controlled by a set of qubits C such that t / ∈ C , the state of thequbit | t i will be flipped from | i to | i or from | i to | i if and only if all the qubits in C are set to true(state | i ), i.e. the new state of the target qubit | t i will be the result of XOR -ing the old state of | t i with the AN D -ing of the states of the control qubits. For example, consider the
CN OT gate shown inFig. 2, it can be represented as
CN OT ( { x , x } | x ), where • on a qubit means that the condition onthat qubit will evaluate to true if and only if the state of that qubit is | i , while ⊕ denotes the targetqubit which will be flipped if and only if all the control qubits are set to true, which means that thestate of the qubit | x i will be flipped if and only if | x i = | x i = | i with whatever value in | x i ; i.e. | x i will be changed according to the operation x → x ⊕ x x . If C = Φ, i.e. an empty set, then thetarget qubit will be flipped unconditionally ( N OT gate).
A general Boolean quantum circuit U of size m (size of the circuit refers to the total number of CN OT gates in that circuit) over n qubit quantum system with qubits | x i , | x i , . . . , | x n − i can be representedas a sequence of CN OT gates [18] as follows, U g = CN OT ( C | t ) . . . CN OT ( C j | t j ) . . . CN OT ( C m | t m ) , (18)where t j ∈ { x , . . . , x n − } ; C j ⊂ { x , . . . , x n − } ; t j / ∈ C j and j : 1 → m . The BQC that will be usedin this paper can be represented as follows, U = CN OT ( C | t ) ...CN OT ( C j | t ) ...CN OT ( C m | t ) , (19)where t ≡ x n − ; C j ⊆ { x , . . . , x n − } . For example, consider the quantum circuit shown in Fig. 3, itcan be represented as follows, U = CN OT ( { x , x }| x ) .CN OT ( { x }| x ) .CN OT ( x ) , (20)Now, to trace the operations that have been applied on the target qubit | x i , we will trace theoperation of each of the CN OT gates that has been applied: • CN OT ( { x , x }| x ) ⇒ x → x ⊕ x x , • CN OT ( { x }| x ) ⇒ x → x ⊕ x , • CN OT ( x ) ⇒ x → x = x ⊕
1. 6ombining the three operations, we see that the complete operation applied on | x i is representedas follows, x → x ⊕ x x ⊕ x ⊕ . (21)If | x i is initialized to | i , applying the circuit will make | x i carry the result of the operation( x x ⊕ x ⊕ x + x , i.e. ( x OR ( N OT x )). More detialson how to convert more complex canonical Boolean expression (expressions use AN D , OR , N OT ) toquantum circuits using
Reed-Muller expression (expressions use
AN D , XOR , N OT ) can be found in[30].
Consider an unstructured list L of N items. For simplicity and without loss of generality we willassume that N = 2 n for some positive integer n . Suppose the items in the list are labeled with theintegers { , , ..., N − } , and consider a Boolean function f which maps an item i ∈ L to either 0 or1 according to some properties this item should satisfy, i.e. f : L → { , } .It follows directly, from the discussion in the above sections, that the function f can be representedas a unitary matrix U f . U f will be taken as an oracle that applies a query on the database file andreturns the results. U f has the following effect when applied on a quantum register | x, y i , U f : | x, y i → | x, y ⊕ f ( x ) i , (22)where | x i is a quantum register of size n and | y i is a temporary qubit. If | y i is initially set to | i , then U f has the following effect on the quantum register, U f : | x, i → | x, f ( x ) i . (23)This oracle has a special importance in setting up an entanglement on the states that make theoracle evaluates to true as follows: assume that | ψ i is a quantum register of size n + 1 qubits. Thefirst n qubits in a superposition and the last qubit is an extra qubit initialized to state | i . Assumethat U f is a quantum oracle used to identify the states in the superposition that make f evaluates totrue. Applying U f on | ψ i can be understood as follows, U f | ψ i = U f n − P i =0 α i | i i ⊗ | i = n − P i =0 α i | i i ⊗ | f ( i ) i = n − P i =0 ′ α i | i i ⊗ | i + n − P i =0 ′′ α i | i i ⊗ | i , (24)where, P i ′ denotes a sum over i which are desired items, and P i ′′ denotes a sum over i which areundesired items in the list, i.e. the list of desired items are entangled with state | i of the extra qubitand the list of undesired items are entangled with state | i . So far, this can be considered as theSELECT operator since the selected states is entangled with state | i . Applying any operation U based on the condition that the extra qubit is in state | i will be applied only of the subspace of thedesired items as shown in Fig. 4. To apply an arbitrary operation U (2 n × n unitary matrix) only onthe subspace entangled with state | i , U must be transformed to a unitary matrix of size 2 n +1 × n +1 as follows, U → U ⊗ | i h | + I n ⊗ | i h | , (25)where I n is the identity matrix of size 2 n × n . 7 ✇ ... ... UU f n qubitsqubitextra Figure 4: Setting up entanglement on a subspace of the superposition.
The partial diffusion operator , D p , is an operator that performs amplitude alteration only on thesubspace of the system entangled with the extra qubit workspace in state | i [31]. The diagonalrepresentation of D p when applied on n + 1 qubits system can take this form: D p = (cid:0) H ⊗ n ⊗ I (cid:1) (cid:0) (1 − e iϕ ) | i h | − I n +1 (cid:1) (cid:0) H ⊗ n ⊗ I (cid:1) , (26)where the vector | i used in Eqn. 26 is of length 2 N = 2 n +1 , I k is the identity matrix of size 2 k × k and ϕ is an arbitrary angle. Consider a general state | ψ i of n + 1 qubits register: | ψ i = N − P k =0 δ k | k i = N − P j =0 α j ( | j i ⊗ | i ) + N − P j =0 β j ( | j i ⊗ | i ) , (27)where { α j = δ k : k even } and { β j = δ k : k odd } . The effect of applying D p on | ψ i produces, D p | ψ i = ( H ⊗ n ⊗ I ) (cid:0) (1 − e iϕ ) | i h | − I n +1 (cid:1) ( H ⊗ n ⊗ I ) N − P k =0 δ k | k i = N − P j =0 (1 − e iϕ ) h α i ( | j i ⊗ | i ) − N − P k =0 δ k | k i = N − P j =0 (cid:0) (1 − e iϕ ) h α i − α j (cid:1) ( | j i ⊗ | i ) − N − P j =0 β j ( | j i ⊗ | i ) , (28)where h α i = N P N − j =0 α j is the mean of the amplitudes of the subspace α j ( | j i ⊗ | i ), i.e. applyingthe operator D p will only alter the amplitudes of the subspace α j ( | j i ⊗ | i ) and will only change thesign of the amplitudes for the subspace β j ( | j i ⊗ | i ). If ϕ = π , D p will perform the inversion aboutthe mean only on the subspace α j ( | j i ⊗ | i ) [31]. For simplicity and without loss of generality, we willuse D p with ϕ = π throughout the rest of the paper. The architecture of the memory of the quantum system required for the operations of the QQL consistsof a quantum register of size n + t qubits. Initially, the system is set to state | i ⊗ n ⊗| i ⊗ t . The n qubitscan hold up to 2 n records at a time and the t qubits will be used as temporary qubits for processingpurposes. If it is required to store r records in a superposition such that 1 ≤ r ≤ n , then ⌈ log ( r ) ⌉ qubits will be used out of the n qubits.It is important to clearly declare that the following QQL operators care only about the effects tobe applied on the states of the system (values in the list). For simplicity, the effects to be appliedon the amplitudes associated with the states in the superposition have been ignored as long as therequired states exist in the superposition. The QQL operators could be associated with some quantumoperators, to be constructed separately, for amplitude manipulation and to maintain the stability ofthe amplitudes during the processing time in specific situations.8 .1 Inserting Records to the Superposition (INSERT) Suppose that it is required to insert some records to a superposition. To insert 2 r records directly tothe superposition such that r ≤ n , apply H ⊗ r ⊗ I ⊗ n − r on the first r qubits to create a system in asuperposition as follows, r − X i =0 α i | i i ! ⊗ | i ⊗ n − r . (29)If it is required to insert certain number of records r to a superposition such that only one recordis inserted at a time, then controlled Hadamard gates can be used to achieve this goal. For example,assume that there is a quantum register of three qubits that can hold up to eight values. To insertitem-by-item in sequence to the superposition, apply in sequence the set of operators S i , i = 0 , . . . , S = H ⊗ I ⊗ I,S = | i h | ⊗ H ⊗ I + | i h | ⊗ I ⊗ I,S = | i h | ⊗ I ⊗ I + | i h | ⊗ H ⊗ I,S = | i h | ⊗ H + P i =0 ,i =0 | i i h i | ⊗ I,S = | i h | ⊗ H + P i =0 ,i =2 | i i h i | ⊗ I,S = | i h | ⊗ H + P i =0 ,i =1 | i i h i | ⊗ I,S = | i h | ⊗ H + P i =0 ,i =3 | i i h i | ⊗ I. (30)Initially, the system is in state | i , so, the system already contains an item. To insert the 2 nd item, apply S , so the system is transoformed to the following, α | i + α | i , (31)and, to insert the 3 rd item, apply S to get, α | i + α | i + α | i , (32)and so on. If we keep applying S ′ i s up to S , we get, α | i + α | i + α | i + α | i + α | i + α | i + α | i . (33)Finally, applying S will complete the superposition over the whole quantum register. To speedup this process a little bit, assume that it is required to insert five records to the superposition, then,firstly, apply H ⊗ H ⊗ I , to insert four records directly to the superposition in a single step, since H ⊗ H ⊗ I = S S S , then apply S to insert the 5 th record. The natural question that mightarise here is: What if it is required to insert some specific states, not necessarily in sequence, to thesuperposition? The answer might be more obvious after the UPDATE operator is defined in the nextsection. Updating a record is just sending the state that represents that record to another state that representsthe updated record such that the record remains unique within the context of the database file. Forexample, assume that we have some records in a superposition as following, α | i + α | i + α | i + α | i + α | i . (34)9 ❣ ❣❣ ✇❣ ✇ ❣✇✇❣❣✇❣ ✇❣ ❣✇ ✇✇ S S S S S S S | i| i| i H H H H H H H
Figure 5: Sequential insertion of items to a superposition.To update the record | i to be | i , i.e. it is required to tranform the system shown in Eqn.(34)to the following system, α | i + α | i + α | i + α | i + α | i , (35)such that no change in the amplitude of the updated record, then this is a permutation. A permutationoperator is a widely known operator that can be represented as a unitary matrix with 0’s and 1’s asits entries such that each row and column contains a single 1 and 0 everywhere else. So, the UPDATE operator that will transform the superposition in Eqn.(34) to the superposition in Eqn.(35) can bewritten as follows, U | i↔| i = . (36)The UPDATE operator shown in Eqn.(36) is just an identity matrix of size 2 × (3-qubit register)with the 4 th ( | i ) and 8 th ( | i ) columns been swapped together to affect the basis of the system asrequired. Notice that, applying U | i↔| i shown in Eqn.(36) again will undo the update. Moreupdate operations can be achieved using a single UPDATE operator. For example, to update therecords | i and | i to states | i and | i respectively, a single UPDATE operator is requiredas follows, U | i↔| i| i↔| i = . (37)A quantum circuit can be constructed for such permutation matrices using elementary CN OT gates [29]. We may conclude from the INSERT and UPDATE operators that any arbitrary recordscan be included in a superposition. They are not necessarily to be in sequence. This can be done byinserting the required number of states, then apply an UPDATE operator on some states to get thefinal required states in the superposition. 10 .3 Deleting a Set of Records (DELETE)
Assume that we want to delete some specific records from the superposition. This problem is aninteresting problem by itself. How can we remove some items from a superposition in a single step?The answer to this question is still quite open. In this section, we will discuss some key points thatmight be used to solve this problem. Firstly, we need to identify the items to be removed from thesuperposition. Assume that we have a Boolean function f that evaluates to true for the items wewant to delete. Applying a quantum oracle U f on the superposition taking a temporary qubit asthe target qubit will identify these items by entangling the subspace of the items we want to keep inthe superposition with state | i of the temporary qubit, and the subspace of the items we want todelete with state | i of the temporary qubit. The rest is a matter of amplitude amplification to findthe temporary qubit in state | i when a partial measurement is applied on that particular temporaryqubit. This will erase the unnecessary states directly from the system, and will leave a superpositionwith the rest of the states. A usual scenario in the processing of a database is to select certain sets of records, each set is selectedbased on some condition, then apply an operation on the intersection of the selected set of recordsaccording some global condition. For example, assume that R and R are two selected set of recordsaccording to the two conditions c and c respectively. Assume that an operation U should be appliedon the intersection of the selected records according to the global condition ( c AN D ( N OT c )). Fig. 6shows such construction where the set R of records is selected by a Boolean function f and the set R of records is selected by a Boolean function f . Both selected records are combined using the globalcondition ( c AN D ( N OT c )) on the last temporary qubit and a conditional application of U is donefor only the records that satisfy the global condition. In general, to apply such an arbitrary operator U on k selected set of records, k + 1 temporary qubits are required. ❣ ✇❣✇✇ ❣✇❣ n qubits ...... U f U f U ( c AN D ( N OT c )) c c Figure 6: Conditioal application of an arbitrary operation U based on two SELECT operators, where c c ⊕ c ≡ c AN D ( N OT c ). Suppose that a copy of some states in a superposition should be stored in a safe to be protectedfrom any arbitrary operations to be done by mistake on the superposition. To achieve this, assumethat f is a Boolean function that identifies the records to be backed up. Firstly, apply U f on thesuperposition taking a temporary qubit as the target qubit, this creates an entanglement between therequired subspace and the temporary qubit in state | i , and the rest of the system entangled with thetemporary qubit in state | i . This temporary qubit will be considered as the key of the safe (the safekey). 11 ... ... U f superpositionof n qubits | i extra qubit D p Figure 7: Backing up a portion of a database file.Now, there are two separate subspaces in the superposition. A subspace entangled with the tem-porary qubit in state | i representing the items sent to the backup and the rest of the superpositionthat doesn’t contain the states in the backup, entangled with state | i of the temporary qubit. Tocreate a copy of the states in the backup and insert them in the subspace entangled with state | i ,apply the partial diffusion operator D p on the system including the temporary qubit. The mechanismof these operations can be understood as follows: Assume that the system is initially as follows, | ψ i n − X i =0 α i | i i ⊗ | i . (38)1- Applying the Oracle . Apply the oracle U f that maps the items in the list to either 0 or 1simultaneously and stores the result in the temporary qubit: | ψ i = U f | ψ i = U f n − P i =0 α i | i i ⊗ | i = n − P i =0 α i | i i ⊗ | f ( i ) i . (39)2- Partial Diffusion . Let M be the number of matches, which make the oracle U f evaluate totrue, i.e. items to be sent to the backup and N = 2 n . Assume that P i ′ denotes a sum over i representing the items to be sent to the backup, and P i ′′ denotes a sum over i representing therest of the items in the list. So, the system | ψ i shown in Eqn. (39) can be written as follows: | ψ i = N − X i =0 ′′ α i ( | i i ⊗ | i ) + N − X i =0 ′ α i ( | i i ⊗ | i ) . (40)Applying D p on | ψ i will result in a new system described as follows: | ψ i = N − X i =0 ′′ a i ( | i i ⊗ | i ) + N − X i =0 ′ b i ( | i i ⊗ | i ) + N − X i =0 ′ c i ( | i i ⊗ | i ) , (41)where the mean used in the definition of partial diffusion operator is, h α i = 1 N N − X i =0 ′′ α i ! , (42)and a i , b i and c i used in Eqn. 41 are calculated as follows: a i = 2 h α i − α i , b i = 2 h α i , c i = − α i . (43)Notice that, the states with amplitude b i had amplitude zero before applying D p . The systemends up with a copy of the required states, previously sent to the backup by the oracle, in the12ubspace entangled with state | i of the safe key qubit. Applying any further operations on therecords of the database should be applied by controlling that operations by the temporary qubitto be in state | i , in an equivalent manner to that shown in Eqn.(25), keeping the backup inthe safe entangled with state | i of the temporary qubit. Notice that, a superposition of thedatabase file together with its backup cost an extra qubit added to the system. Suppose that some required records are lost from the superposition due to some invalid update and/ormistaken deletion providing that, a copy of these states has been kept in a backup and all appliedoperations were controlled with the safe key qubit to be in state | i . So, the system can be representedas follows, (cid:12)(cid:12)(cid:12) ψ ′ E = N − X i =0 ′′ a ′ i ( | i i ⊗ | i ) + N − X i =0 ′′′ b ′ i ( | i i ⊗ | i ) + N − X i =0 ′ c i ( | i i ⊗ | i ) , (44)where P i ′ denotes a sum over i representing the items in the safe, and P i ′′ denotes a sum over i representing the rest of the items in the list, and P i ′′′ denotes a sum over i representing the set of thecorrect items left in the superposition after applying the invalid operations. Applying the oracle U f ,originally used to create the backup, on (cid:12)(cid:12)(cid:12) ψ ′ E will flip the safe key qubit only for the items in P i ′ and P i ′′′ , sending the remaining correct items left in the superposition to the backup safe and restoringthe items in the safe to the superposition entangled with state | i as follows, U f (cid:12)(cid:12)(cid:12) ψ ′ E = N − X i =0 ′′ a ′ i ( | i i ⊗ | i ) + N − X i =0 ′ c i ( | i i ⊗ | i ) + N − X i =0 ′′′ b ′ i ( | i i ⊗ | i ) . (45)Since the items in the backup safe is no longer valid (as a set of items), they can be deleted by theDELETE operator. A new fresh backup could be created using the BACKUP operator. The quantum databases are expected to replace the classical databases once quantum computers areimplemented on the commercial scale. Quantum computers can behave classically if a superpositionis not used. Superposed quantum database will be useful in reducing the processing time where manyoperations could be done simultaneously on a database file as well as saving memory space. Extractinguseful information from a quantum computer in a superposition is still under investigation by manyresearchers. Distributed processing of databases could be possible where teleportation might help insending a quantum database file in a superposition from one place to another instantly for furtherprocessing and extracting useful information.The QQL operators defined in this paper still require further investigation to adjust the amplitudesof the system as required. General purpose amplitude manipulation techniques must be found to becombined with the operators of the QQL. Finding a quantum version of referential integrity andrelational algebra to get useful information from larger databases where many database files are usedcould be the next research step.To summarize, in this paper, a method for inserting exponential number of items simultaneously aswell as inserting item-by-item to a superposition has been defined. A method to update many recordssimultaneously has been shown. A way to delete certain records from the database simultaneouslyhas been suggested which still need special attention as a separate problem. Performing the selectionof some records and applying conditional operations on the intersection of these selected records hasbeen shown. And finally a method to backup and restore a database file without the need of vast extramemory has been proposed. 13 eferences [1] H. Azuma. Building partially entangled states with Grover’s amplitude amplification process.
International Journal of Modern Physics C , 11(3):469–484, 2000.[2] A. Barenco, C. Bennett, R. Cleve, D. P. Divincenzo, N. Margolus, P. Shor, T. Sleator, J. Smolin,and H. Weinfurter. Elementary gates for quantum computation.
Physical Review A , 52(5):3457–3467, 1995.[3] A. Barenco and A. Ekert. Dense coding based on quantum entanglement.
Journal of ModernOptics , 42:1253–1259, 1995.[4] J. Bell. On the Einstein-Podolsky-Rosen paradox.
Physics , 1:195–200, 1964.[5] J. Bell. On the problem of hidden variables in quantum mechanics.
Reviews of Modern Physics ,38(3):447, 1966.[6] C. Bennett. Logical reversibility of computation.
IBM Journal of Research and Development ,17(6):525–532, 1973.[7] C. Bennett, G. Brassard, C. Crepeau, R. Jozsa, A. Peres, and W. Wootters. Teleporting anunknown quantum state via dual classical and Einstein-Podolsky-Rosen channels.
Physical ReviewLetters , 70:1895–1899, 1993.[8] M. Boyer, G. Brassard, P. Høyer, and A. Tapp. Tight bounds on quantum searching.
Fortschritteder Physik , 46:493, 1998.[9] G. Brassard, P. Høyer, M. Mosca, , and A. Tapp. Quantum amplitude amplification and estima-tion. arXiv e-Print quant-ph/0005055 , 2000.[10] G. Brassard, P. Høyer, and A. Tapp. Quantum counting. arXiv e-Print quant-ph/9805082 , 1998.[11] S. Braunstein and A. Pati. Speed-up and entanglement in quantum searching.
Quantum Infor-mation and Computation , 2(5):399–409, 2002.[12] P. Dirac.
The Principles of Quantum Mechanics . Clarendon Press, Oxford, UK, 1947.[13] A. Einstien, B. Podolsky, and N. Rosen. Can quantum-mechanical description of physical realitybe considered complete?
Physical Review , 47:777, 1935.[14] R. Feynman. Simulating physics with computers.
International Journal of Theoretical Physics ,21:467–488, 1982.[15] L. Grover. A fast quantum mechanical algorithm for database search. In
Proceedings of the 28 th Annual ACM Symposium on the Theory of Computing , pages 212–219, 1996.[16] J. Gruska.
Quantum Computing . McGraw-Hill, London, 1999.[17] T. A. Hungerford.
Algebra . Springer Verlag, New York, Heidelberg, Berlin, 1974.[18] K. Iwama, Y. Kambayashi, and S. Yamashita. Transformation rules for designing CNOT–basedquantum circuits. In
Proceedings of the 39 th Conference on Design Automation , pages 419–424.ACM Press, 2002.[19] M. Mosca. Quantum searching, counting and amplitude amplification by eigenvector analysis.In
Proceedings of Randomized Algorithms, Workshop of Mathematical Foundations of ComputerScience , pages 90–100, 1998.[20] M. Nielsen and I. Chuang.
Quantum Computation and Quantum Information . Cambridge Uni-versity Press, Cambridge, United Kingdom, 2000.1421] R. R. Elmasri and S. B. Navathe.
Fundamentals of Database Systems . Addison Wesley, Boston,MA, USA, 2006.[22] E. Rieffel and W. Polak. An introduction to quantum computing for non-physicists.
ACM Com-puting Surveys , 32(3):300–335, 2000.[23] Z. S. Sazonova and R. Singh. Kronecker product/direct product/tensor product in quantumtheory. arXiv e-Print quant-ph/0104019 , 2001.[24] B. Schumacher. Quantum coding.
Physical Review A , 51:2738–2747, 1995.[25] P. Shor. Algorithms for quantum computation: Discrete logarithms and factoring. In
Proceedingsofthe 35 th Annual Symposium on Foundations of Computer Science , pages 124–134. IEEE ComputerSociety Press, 1994.[26] D. Simon. On the power of quantum computation. In
Proceedings of the 35 th Annual Symposiumon Foundations of Computer Science , pages 116–123, 1994.[27] T. Toffoli. Reversible computing. In W. de Bakker and J. van Leeuwen, editors,
Automata, Lan-guages and Programming , page 632. Springer, New York, 1980. Technical Memo MIT/LCS/TM-151, MIT Lab for Computer Science (unpublished).[28] A. Younes. Fixed phase quantum search algorithm. arXiv:0704.1585[quant-ph] , 2007.[29] A. Younes and J. Miller. Automated method for building CNOT based quantum circuits forBoolean functions. Technical Report CSR-03-3, University of Birmingham, School of ComputerScience, arXiv e-Print quant-ph/0305134, April 2003.[30] A. Younes and J. Miller. Representation of Boolean quantum circuits as Reed-Muller expansions.
International Journal of Electronics , 91(7):431–444, 2004.[31] A. Younes, J. Rowe, and J. Miller. Quantum search algorithm with more reliable behaviour usingpartial diffusion. In