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.

-- ordered by recency"create index labs_by_patient_and_date onlabs(patient_id, test_date);-- make it fast to query <strong>for</strong>-- "complete history <strong>for</strong> patient #4527-- insulin levels"create index labs_by_patient_and_test onlabs(patient_id, test_name);Note that this table doesn't have a lot of integrity constraints. If youwere to specify patient_id as unique that would limit each hospitalpatient to only having one test done. Nor does it work to specify thecombination of patient_id and test_date as unique because there arefancy machines that can do multiple tests at the same time on asingle blood sample, <strong>for</strong> example.We can apply this idea to user registration: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,registration_date timestamp(0));create table users_extra_info (user_info_id integer primary key,user_id not null referencesusers,field_name varchar(100) not null,field_type varchar(100) not null,--one of the three columns below will be non-NULLvarchar_value varchar(4000),blob_value blob,date_value timestamp(0),check ( not (varchar_value is null andblob_value is null anddate_value is null))-- in a real system, you'd probably have-- additional columns-- to store when each row was inserted and-- by whom76-- here is the table <strong>for</strong> elements that are unique to an-- object type (the housekeeping elements can be defined-- implicitly in the source code <strong>for</strong> the application-- generator); there will be one row in-- the metadata table per elementcreate table km_metadata_elements (metadata_id integer primary key,table_name not null referenceskm_metadata_object_types,column_name varchar(30) not null,pretty_name varchar(100) not null,abstract_data_type varchar(30) not null,-- ie. "text" or "shorttext" "boolean" "user"-- this one is not null except when abstract_data_type-- is "user"oracle_data_type varchar(30), -- "varchar(4000)"-- e.g., "not null" or-- "check foobar in ('christof', 'patrick')"extra_sql varchar(4000),-- values are 'text', 'textarea', 'select', 'radio',-- 'selectmultiple', 'checkbox', 'checkboxmultiple',-- 'selectsql'presentation_type varchar(100) not null,-- e.g., <strong>for</strong> textarea, this would be "rows=6 cols=60",-- <strong>for</strong> select, Tcl list,-- <strong>for</strong> selectsql, an SQL query that returns N district-- values <strong>for</strong> email addresses mailto:presentation_options varchar(4000),-- pretty_name is going to be the short prompt,-- e.g., <strong>for</strong> an update page, but we also need-- something longer if we have to walk the user-- through a long <strong>for</strong>mentry_explanation varchar(4000),-- if they click <strong>for</strong> yet more helphelp_text varchar(4000),-- note that this does NOT translate into a "not null"-- constraint in Oracle if we did this, it would-- preclude an interface in which users create rows-- incrementallymandatory_p char(1)check (mandatory_p in ('t','f')),-- ordering in Oracle table creation, 0 would be on-- top, 1 underneath, etc.sort_key integer,273

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

Saved successfully!

Ooh no, something went wrong!