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.

The trees chapter of SQL <strong>for</strong> Web Nerds, athttp://philip.greenspun.com/sql/trees, gives some examples ofconcatenated indices. If you're using Oracle you may want to read thecomposite indices section of the Per<strong>for</strong>mance Guide and Referencemanual (online and in the product documentation) and the SQLReference manual's section on "Create Index".15.6 Exercise 4: Write a Program to Generate a"Drop All Tables" ScriptWrite a script in the same admin directory as ddl-generate, calleddrop-tables-generate. This should generate DROP TABLEstatements from the metadata tables. You probably won't get yourdata model right the first time so you might as well be ready to clearout the RDBMS and start over.Feed the database management system the results of your datamodel creation and clean-up scripts until you stop getting errormessages.15.7 Dimensional ControlsWhen displaying a long list in<strong>for</strong>mation on a page consider addingdimensional controls to the top. Suppose <strong>for</strong> example that you wishto help an administrator browse among the registered users of a site.You have a feeling that the user community will grow too large <strong>for</strong> thecomplete list to be useful. You there<strong>for</strong>e add an intermediate pagewith the following options:276• show users who've registered in the last 30 days• show users from the same geographical area as me (siteadministration tends to be divided up by region)• show users who have contributed more than 5 items• show users whose content has been rated below "C"(looking <strong>for</strong> people who add a lot of crud to the database)A well-designed page of this <strong>for</strong>m will have a discreet number next toeach option, showing the number of users who will be displayed ifthat option is selected. A poorly designed page will simply leave theadministrator guessing as to how much in<strong>for</strong>mation will be shownafter an option is selected.This traditional approach has some drawbacks. First, it adds a mouseclick be<strong>for</strong>e the administrator can see any user names. Ideally youwant every page of an application to be displaying in<strong>for</strong>mation and/orChapter 5User Registration and ManagementAs noted in the <strong>Software</strong> Structure chapter, the more identified,authenticated, and accountable people are, the better the opportunity<strong>for</strong> building a community out of an aggregate. Thus the userdatabase should record as much in<strong>for</strong>mation as possible that mighthelp Person A assess Person B's credibility.As you will see in the chapter on scaling, it may become important tofacilitate occasional face-to-face meetings among subgroups ofusers. Thus it will be helpful to record their country of residence andpostal code (what Americans call "Zoning Improvement Plan code" or"ZIP code").5.1 Fat versus Skinny: the IdeasSuppose that the system specifications start off with very simplerequirements <strong>for</strong> the user database, one that can be handled by thefollowing single table:create table users (user_id integer primary key,first_names varchar(50),last_name varchar(50) not null,emailvarchar(100) not null unique,-- we encrypt passwords using-- operating system crypt functionpassword varchar(30) not null,registration_date timestamp(0));Notice that the comment about password encryption is placedabove, rather than below, the column name and that the primarykey constraint is clearly visible to other programmers. It is good toget into the habit of writing data model files in a text editor andincluding comments and examples of the queries that you expectto support. If you use a desktop application with a graphical userinterface to create tables you're losing a lot of important designin<strong>for</strong>mation. Remember that the data model is the most criticalpart of your application. You need to think about how you're goingto communicate your design decisions to other programmers.73

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

Saved successfully!

Ooh no, something went wrong!