Thread: SQL Help
View Single Post
Old 12-21-2004, 08:50 PM   #2 (permalink)
franzelneekburm
Tilted
 
Location: Boston
Quote:
Originally Posted by hrdwareguy
I am going to propose a solution that uses an SQL server but I have some questions for the SQL GURU's around here.
A very good proposal, I would say (can't claim to be a guru of any kind though). If you are looking for a free database server, might I recommed PosgtreSQL - it's full featured, mature, performat and a joy to work with

Quote:
First off, can sql tables have associated indexes and if so, how do you access the information via the index?
Tables not only can have indices, but it's an odd one that doesn't. When you perform a query, the optimizer (and these are vastly different in their design and performance between different database products) will determine which, if any, of the indices available for the tables involved in the query are likely to improve the query performance, and will create an appropriate execute plan. Some databases allow you to override the optimizer and specify which indices to use, but this is very rarely necessary.

Quote:
For example if I enter a phone number I want to be able to jump to that phone number if it exists. If it does not exist, I need to go to the closes match and be able to go to the previous and next records.
The first part is trivial, you create a table (let's say 'employees') and create an index on the 'phone' field, when you execute "SELECT * FROM employees WHERE phone = '123-456-7890" the index will be used to fetch the record instantly, if it exists.

The second part is somewhat more complicated because I am not sure what you mean by 'closest match'. Is 'closest' the nearest one if the phone number is treated as a single integer, or one with the least number of substitutions to arrive to the one you want? Or something else entirely?

Quote:
Next, I need to know how to set permissions on tables. I have one table that everyone needs read access to, but only 3 people need write access to. I will have both internal and external sources looking at some of these tables so will need to set the security appropriately.
This is also something that differs somewhat between database engines, but usually it's some variant of the GRANT/REVOKE commands. Usually along the lines of "GRANT[list of privileges] ON [tables/schemas/views/indices or pretty much any other database object] TO [users/group]" - simple, no? Consult the documentation for the database engine you choose to work with for the specifics. The most basic privileges will include SELECT, INSERT, UPDATE, DELETE (and usually many more advanced ones) so they are more than granular enough to do what you want.

Of course depending on your actual application, you may want to always connect as the same user and handle permissions in your app (for performance reasons, this is usually the way it's done in web applications).

Quote:
I will be doing my developnet in Delphi, not that it should make a difference though.
Can't claim any experience there.

Quote:
Thanks for your advice, I will probably have more questions later.
Good luck. Will be glad to answer any further questions.
franzelneekburm is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360