13.07.2015 Views

Software Engineering for Internet Applications - Student Community

Software Engineering for Internet Applications - Student Community

Software Engineering for Internet Applications - Student Community

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Note that numbers are stored in a column of typeVARCHAR. Won't this preclude queries such as"Find the average income of a registered user"?Not if you're using Oracle. Oracle is smart aboutautomatically casting between character stringsand numbers. It will work just fine toselect average(varchar_value)from users_extra_infowhere field_name = 'annual_income'One complication of this kind of data model is that itis tough to use simple built-in integrity constraintsto en<strong>for</strong>ce uniqueness if you're also going to usethe users_extra_info <strong>for</strong> many-to-onerelations.For example, it doesn't make sense to have tworows in the info table, both <strong>for</strong> the same user IDand both with a field name of "birthdate". A usercan only have one birthday. Maybe we shouldcreate unique indexusers_extra_info_user_id_field_idx onusers_extra_info (user_id, field_name);(Note that this will make it really fast to fetch a particular field <strong>for</strong> aparticular user as well as en<strong>for</strong>cing the unique constraint.)But what about "home_phone"? Nothing should prevent a user fromgetting two home phone numbers and listing them both. If we try toinsert two rows with the "home_phone" value in the field_namecolumn and 451 in the user_id column, the RDBMS will abort thetransactions due to violation of the unique constraint defined above.How to deal with this apparent problem? One way is to decide thatthe users_extra_info table will only be used <strong>for</strong> single-valuedproperties. Another approach would be to abandon the idea of usingthe RDBMS to en<strong>for</strong>ce integrity constraints and put logic into theapplication code to make sure that a user can only have onebirthdate. A complex but complete approach is to define RDBMS78If you're using afancycommercialRDBMS and wishto make querieslike this reallyfast, check outbitmap indices,oftendocumentedunder "DataWarehousing".These areintended <strong>for</strong>columns of lowcardinality, i.e.,not too manydistinct valuescompared to thenumber of rowsin the table.You'd build abitmap index onthefield_namecolumn.store the frequencies <strong>for</strong> weather in<strong>for</strong>mation, contactingother pilots (if non-towered) or the control tower (if towered),air traffic control <strong>for</strong> instrument flight clearances. We need torecord runway lengths and conditions. An airport may haveseveral runways, however, thus giving rise to a many-to-onerelation, which is why we model runways separately and linkthem to airports.<strong>for</strong> the runway typenumber (e.g., "09/27"), length, condition. Note that therunway number implies the magnetic orientation: 09 impliesa heading of 090 or landing facing magnetic east; if the windfavors a landing on the same strip of asphalt in the oppositedirection, you're on 27, which implies a heading of 270 ordue west (36 faces north; 18 faces south).<strong>for</strong> the navigation aid typeThe U.S. Federal Aviation Administration maintains anationwide network of Very High Frequency Omni Rangingbeacons (VORs). These transmit two signals, one of whichis constant in phase regardless of an airplane's bearing tothe VOR. The second signal varies in phase as one circles aVOR. Thus a VOR receiver in the airplane can compare thephase of the two signals and determine that an airplane is,<strong>for</strong> example, on the 123-degree radial from the VOR. If youdidn't have a Global Positioning System receiver in yourairplane, you'd determine your position on the chart byplotting radials out from two VORs. For a navaid we need tostore its type (could be an old non-directional beacon, whichsimply puts out an AM radio-style broadcast), frequency,position, and Morse code ID (you want to listen to the dotdashpattern to make sure that you're receiving the propernavaid).<strong>for</strong> the restaurant typemenu_excerpt, hours, distance_from_airport,phone_number, url, email, street_address<strong>for</strong> the hotel typeprice, distance_from_airport, phone_number, url, email,street_addressAn example of a running system along these lines, visithttp://www.airnav.com/airports/ and type in the name or code <strong>for</strong> yourfavorite airport.Back to Your Ontology ...Following the structure that you designed in the <strong>Software</strong> Modularitychapter, create a module called "km" (<strong>for</strong> "knowledge management")271

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!