1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Includes SQL clauses for creating and dropping tables/indexes |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 #ifndef __CMSQLMAINTENANCECLAUSES_H__ |
|
24 #define __CMSQLMAINTENANCECLAUSES_H__ |
|
25 |
|
26 /////////////////////////////////////////////////////////////////// |
|
27 // DROP CLAUSES |
|
28 /////////////////////////////////////////////////////////////////// |
|
29 _LIT8( KCmSqlDropArtists, "DROP TABLE Artists;"); |
|
30 _LIT8( KCmSqlDropGenres, "DROP TABLE Genres;" ); |
|
31 _LIT8( KCmSqlDropAlbums, "DROP TABLE Albums;" ); |
|
32 _LIT8( KCmSqlDropUpnpProfiles, "DROP TABLE UpnpProfiles;" ); |
|
33 _LIT8( KCmSqlDropUpnpClasses, "DROP TABLE Upnpclasses;" ); |
|
34 _LIT8( KCmSqlDropResolutions, "DROP TABLE Resolutions;" ); |
|
35 _LIT8( KCmSqlDropResources, "DROP TABLE Resources;" ); |
|
36 _LIT8( KCmSqlDropItems, "DROP TABLE Items;" ); |
|
37 |
|
38 /////////////////////////////////////////////////////////////////// |
|
39 // CREATE CLAUSES FOR TABLES |
|
40 /////////////////////////////////////////////////////////////////// |
|
41 _LIT8( KCmSqlCreateArtists, |
|
42 "CREATE TABLE Artists(" |
|
43 "ArtistId INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT," |
|
44 "Value TEXT NOT NULL UNIQUE);" |
|
45 ); |
|
46 |
|
47 _LIT8( KCmSqlCreateGenres, |
|
48 "CREATE TABLE Genres(" |
|
49 "GenreId INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT," |
|
50 "Value TEXT NOT NULL UNIQUE);" |
|
51 ); |
|
52 |
|
53 _LIT8( KCmSqlCreateAlbums, |
|
54 "CREATE TABLE Albums(" |
|
55 "AlbumId INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT," |
|
56 "Value TEXT NOT NULL UNIQUE);" |
|
57 ); |
|
58 |
|
59 _LIT8( KCmSqlCreateResolutions, |
|
60 "CREATE TABLE Resolutions(" |
|
61 "ResolutionId INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT," |
|
62 "Value TEXT NOT NULL UNIQUE," |
|
63 "Width INTEGER," |
|
64 "Height INTEGER," |
|
65 "PixelCount INTEGER);" |
|
66 ); |
|
67 |
|
68 _LIT8( KCmSqlCreateUpnpclasses, |
|
69 "CREATE TABLE Upnpclasses(" |
|
70 "UpnpclassId INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT," |
|
71 "Value TEXT NOT NULL UNIQUE);" |
|
72 ); |
|
73 |
|
74 _LIT8( KCmSqlCreateUpnpProfiles, |
|
75 "CREATE TABLE UpnpProfiles(" |
|
76 "ProfileId INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT," |
|
77 "Value TEXT NOT NULL UNIQUE);" |
|
78 ); |
|
79 |
|
80 _LIT8( KCmSqlCreateResources, |
|
81 "CREATE TABLE Resources(" |
|
82 "ResourceId INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT," |
|
83 "ResItemId INTEGER NOT NULL REFERENCES Items( Id )," |
|
84 "ResResolution INTEGER REFERENCES Resolutions( ResolutionId )," |
|
85 "ResUri TEXT NOT NULL," |
|
86 "Size INTEGER," |
|
87 "ResDuration INTEGER," |
|
88 "ResBitrate INTEGER);" |
|
89 ); |
|
90 |
|
91 _LIT8( KCmSqlCreateItems, |
|
92 "CREATE TABLE Items(" |
|
93 "Id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT," |
|
94 "ItemId TEXT NOT NULL," |
|
95 "Hash TEXT NOT NULL," |
|
96 "Uri TEXT NOT NULL," |
|
97 "Title TEXT NOT NULL," |
|
98 "AlbumArtUri TEXT," |
|
99 "DeviceId INTEGER NOT NULL," |
|
100 "Duration INTEGER," |
|
101 "Bitrate INTEGER," |
|
102 "Date DATETIME," |
|
103 "HarvestDate DATETIME," |
|
104 "Size INTEGER," |
|
105 "Mediatype INTEGER," |
|
106 "SearchId INTEGER," |
|
107 "UpnpclassId INTEGER REFERENCES Upnpclasses( UpnpclassId )," |
|
108 "ArtistId INTEGER REFERENCES Artists( ArtistId )," |
|
109 "AlbumId INTEGER REFERENCES Albums( AlbumId )," |
|
110 "GenreId INTEGER REFERENCES Genres( GenreId )," |
|
111 "ProfileId INTEGER REFERENCES UpnpProfiles( ProfileId )," |
|
112 "ResolutionId INTEGER REFERENCES Resolutions( ResolutionId ) );" |
|
113 ); |
|
114 |
|
115 /////////////////////////////////////////////////////////////////// |
|
116 // INDEXES |
|
117 /////////////////////////////////////////////////////////////////// |
|
118 _LIT8( KCmSqlCreateItemsIdIndex, |
|
119 "CREATE INDEX ItemsId_Index ON Items(Id);" |
|
120 ); |
|
121 |
|
122 _LIT8( KCmSqlCreateItemTitleIndex, |
|
123 "CREATE INDEX Item_Title_Index ON Items(Title);" |
|
124 ); |
|
125 |
|
126 _LIT8( KCmSqlCreateItemDateIndex, |
|
127 "CREATE INDEX Item_Date_Index ON Items(Date);" |
|
128 ); |
|
129 |
|
130 _LIT8( KCmSqlCreateItemHarvestDateIndex, |
|
131 "CREATE INDEX Item_HarvestDate_Index ON Items(HarvestDate);" |
|
132 ); |
|
133 |
|
134 _LIT8( KCmSqlCreateItemArtistIndex, |
|
135 "CREATE INDEX Item_Artist_Index ON Items(ArtistId);" |
|
136 ); |
|
137 |
|
138 _LIT8( KCmSqlCreateItemAlbumIndex, |
|
139 "CREATE INDEX Item_Album_Index ON Items(AlbumId);" |
|
140 ); |
|
141 |
|
142 _LIT8( KCmSqlCreateItemGenreIndex, |
|
143 "CREATE INDEX Item_Genre_Index ON Items(GenreId);" |
|
144 ); |
|
145 |
|
146 _LIT8( KCmSqlCreateItemUpnpclassIndex, |
|
147 "CREATE INDEX Item_Upnpclass_Index ON Items(UpnpclassId);" |
|
148 ); |
|
149 |
|
150 _LIT8( KCmSqlCreateItemUpnpProfileIndex, |
|
151 "CREATE INDEX Item_UpnpProfile_Index ON Items(ProfileId);" |
|
152 ); |
|
153 |
|
154 _LIT8( KCmSqlCreateItemResolutionIndex, |
|
155 "CREATE INDEX Item_Resolution_Index ON Items(ResolutionId);" |
|
156 ); |
|
157 |
|
158 _LIT8( KCmSqlCreateItemMediatypeIndex, |
|
159 "CREATE INDEX Item_Mediatype_Index ON Items(Mediatype);" |
|
160 ); |
|
161 |
|
162 _LIT8( KCmSqlCreateAlbumIdIndex, |
|
163 "CREATE INDEX AlbumId_Index ON Albums(AlbumId);" |
|
164 ); |
|
165 |
|
166 _LIT8( KCmSqlCreateArtistIdIndex, |
|
167 "CREATE INDEX ArtistId_Index ON Artists(ArtistId);" |
|
168 ); |
|
169 |
|
170 _LIT8( KCmSqlCreateGenreIdIndex, |
|
171 "CREATE INDEX GenreId_Index ON Genres(GenreId);" |
|
172 ); |
|
173 |
|
174 // Dropping indexes |
|
175 _LIT8( KCmSqlDropItemsIdIndex, |
|
176 "DROP INDEX ItemsId_Index;" |
|
177 ); |
|
178 |
|
179 _LIT8( KCmSqlDropItemTitleIndex, |
|
180 "DROP INDEX Item_Title_Index;" |
|
181 ); |
|
182 |
|
183 _LIT8( KCmSqlDropItemDateIndex, |
|
184 "DROP INDEX Item_Date_Index;" |
|
185 ); |
|
186 |
|
187 _LIT8( KCmSqlDropItemHarvestDateIndex, |
|
188 "DROP INDEX Item_HarvestDate_Index;" |
|
189 ); |
|
190 |
|
191 _LIT8( KCmSqlDropItemArtistIndex, |
|
192 "DROP INDEX Item_Artist_Index;" |
|
193 ); |
|
194 |
|
195 _LIT8( KCmSqlDropItemAlbumIndex, |
|
196 "DROP INDEX Item_Album_Index;" |
|
197 ); |
|
198 |
|
199 _LIT8( KCmSqlDropItemGenreIndex, |
|
200 "DROP INDEX Item_Genre_Index;" |
|
201 ); |
|
202 |
|
203 _LIT8( KCmSqlDropItemUpnpclassIndex, |
|
204 "DROP INDEX Item_Upnpclass_Index;" |
|
205 ); |
|
206 |
|
207 _LIT8( KCmSqlDropItemUpnpProfileIndex, |
|
208 "DROP INDEX Item_UpnpProfile_Index;" |
|
209 ); |
|
210 |
|
211 _LIT8( KCmSqlDropItemResolutionIndex, |
|
212 "DROP INDEX Item_Resolution_Index;" |
|
213 ); |
|
214 |
|
215 _LIT8( KCmSqlDropItemMediatypeIndex, |
|
216 "DROP INDEX Item_Mediatype_Index;" |
|
217 ); |
|
218 |
|
219 _LIT8( KCmSqlDropAlbumIdIndex, |
|
220 "DROP INDEX AlbumId_Index;" |
|
221 ); |
|
222 |
|
223 _LIT8( KCmSqlDropArtistIdIndex, |
|
224 "DROP INDEX ArtistId_Index;" |
|
225 ); |
|
226 |
|
227 _LIT8( KCmSqlDropGenreIdIndex, |
|
228 "DROP INDEX GenreId_Index;" |
|
229 ); |
|
230 |
|
231 #endif // __CMSQLMAINTENANCECLAUSES_H__ |
|
232 |
|
233 |
|