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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

After a few weeks online, someone says "wouldn't it be nice to seethe user's picture and hyperlink through to his or her home page?"create table users (user_id integer primary key,first_names varchar(50),last_name varchar(50) not null,emailvarchar(100) not null unique,password varchar(30) not null,-- user's personal homepage elsewhere-- on the <strong>Internet</strong>url varchar(200),registration_date timestamp(0),-- an optional photo;-- if Oracle Intermedia Image is installed-- use the image datatype instead of BLOBportrait blob);After a few more months ...create table users (user_id integer primary key,first_names varchar(50),last_name varchar(50) not null,emailvarchar(100) not null unique,password varchar(30) not null,-- user's personal homepage elsewhere-- on the <strong>Internet</strong>url varchar(200),registration_date timestamp(0)-- an optional photo;-- if Oracle Intermedia Image is installed-- use the image datatype instead of BLOBportrait blob,-- with a 4 GB maximum, we're all set-- <strong>for</strong> Life of Johnsonbiography clob,birthdate date,-- current politically correct column name-- would be "gender"-- but data models often outlive-- linguistic fashion so-- we stick with more established usageSex char(1) check (sex in ('m','f')),In addition to the metadata-driven object table definitions your scriptshould define a generalized mapping table to support links betweenknowledge objects. Here's an Oracle-syntax example:create table km_object_object_map (object_id_a integer not null,object_id_b integer not null,-- the objects are uniquely identified above but let's-- save ourselves-- hassle by recording in which tables to find themtable_name_a not nullreferences km_metadata_object_types,table_name_b not nullreferences km_metadata_object_types,-- User-entered reason <strong>for</strong> relating two objects, e.g.-- to distinguish between John McCarthy the developer-- of Lisp and Gerry Sussman and Guy Steele, who added-- lexical scoping in the Scheme dialectmap_comment varchar(4000),creation_user not null references users,creation_date date default sysdate not null,primary key (object_id_a, object_id_b));Notice that this table allows the users to map an object to any otherobject in the system, regardless of type.For simplicity, assume that associations are bidirectional. Supposethat a knowledge author associates the Huffman encoding algorithm(used in virtually every compression scheme, including JPEG) withthe person David A. Huffman (1925-1999; an MIT graduate studentat the time of his invention, which was submitted as a term paper).We should also interpret that to mean that the person David A.Huffman is associated with the algorithm <strong>for</strong> Huffman encoding. Thisis why the columns in km_object_object_map have names suchas "object_id_a" instead of "from_object".In an Oracle database, the primary key constraint above has the sideeffect of creating an index that makes it fast to ask the question"What objects are related to Object 17, where Object 17 happens toappear in the A slot?". For efficiency in querying "What objects arerelated to Object 17, where Object 17 happens to appear in the Bslot?", create a concatenated index on the columns in the reverseorder from that of the primary key constraint.74275

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

Saved successfully!

Ooh no, something went wrong!