Ppulate and Extract Data frm Yur Database 1. Overview In this lab, yu will: 1. Check/revise yur data mdel and/r marketing material (hme page cntent) frm last week's lab. Yu will wrk with tw classmates t be sure yur data mdel and web applicatin functinality meet all the requirements. 2. Using MySql Wrkbench, yu will ppulate all fur f yur database tables with data. 3. Yu will generate several SQL select statements. 4. Yu will put tgether a wrd dcument that shws all yur wrk. (This will later be published t yur web site.) Yu may have t reference the tutrials frm last lab: MySQL Wrkbench Tutrial 1: Hw t create database tables (with primary keys), enter data, and write single table select statements MySQL Wrkbench Tutrial 2 (cntinuatin f previus tutrial): Hw t reverse engineer a database, create database relatinships (with freign keys), and hw t write select statements that jin data frm mre than ne database table Page 1
2. Lab Requirements 1. Yur Data Mdel shall: meet the check list f the last lab (e.g., data types, PKs, FKs, Nt Null vs. Nullable, etc.). have NO SQL keywrds as table names nr field names (ggle t see list f SQL keywrds, but can't use these fr sure: user, rle, passwrd, date). be able t supprt the functinality described/marketed in yur hme page cntent (yur web app cannt deliver data unless that data is stred in yur database). If yur data mdel frm last lab des nt meet the requirements abve, fix it and/r mdify yur hme page cntent. Yu are free t ttally red yur idea frm lab 1, but the new data mdel and hme page cntent must meet the abve requirements. 2. Data Mdel Review frm Classmates. During a graded lab activity, yu will have time t get feedback frm (and give feedback t) tw classmates check. The feedback shuld indicate whether r nt yur data mdel meets the requirements specified just abve (r say why it des nt). Bring a printut f yur data mdel and yur prpsed web app functinality when yu meet with yur classmate(s) fr the review. If yu did nt cmplete the lab activity, yu'll have t find tw classmates and get their feedback utside f class time. The submissin requirements shw what yu need t submit t shw that yu gt and gave feedback frm tw classmates. 3. Yur database shall cntain the fllwing realistic lking data: a. 2-3 recrds in yur rle table, ne f which is fr the ADMIN rle. b. 4-6 user recrds. At least ne recrd with all fields ppulated with data and at least ne recrd with all f the ptinal fields empty. c. 4-6 recrds in yur ther table At least ne recrd with all fields ppulated with data and at least ne recrd with all f the ptinal fields empty. d. 10-15 recrds in yur assciative table. At least ne recrd with all fields ppulated with data and at least ne recrd with all f the ptinal fields empty. Nte: yu have t enter yur data in rder. Fr example, yu cannt enter users befre rles because user recrds reference rle recrds. The same is true fr the assciative table - its data must be entered after yu enter the user data and the "ther" data. Page 2
4. Execute a SELECT statement fr each f the fllwing (and paste screen capture int wrd dc see submissin instructins fr specifics n hw yu are t d this): a. List all f the clumns f yur ther table, rdering the clumns in a way that yu think users wuld like t view the data (dn't use "select *"). Srt the data by the first clumn. Include all recrds f the "ther" table. b. Shw all the recrds frm yur user table jined with yur rle table. Shw the rle name first, then the rle id, then the email address, fllwed by all the rest f the clumns f yur user table (rdered in a way yu think users wuld like t view the data shw the rle id nce, nt twice.) Order the result set by rle name, then email address (as a secndary srt). Include all recrds. There shuld be as many rws in yur result set as yu have recrds in yur user table. If yu have a lt mre (and see duplicatin), yu have frgtten the WHERE clause that jins the tw tables tgether. c. Jin yur assciative table with yur ther table. Include all the clumns except PK and FK (id) clumns. Order the clumns in a way yu think users wuld like t see them (nt "select *"). Order the result set by the first tw r three clumns. There shuld be as many rws in yur result set as there are recrds in yur assciative table. d. Jin yur assciative table with yur ther table and with yur user table. Include all the clumns except PK and FK (id) clumns. Order the clumns in a way yu think users wuld like t see them. Order the result set by the first tw r three clumns. There shuld be as many rws in yur result set as there are recrds in yur assciative table. Hint: yu need tw cnditins in yur WHERE clause, ne fr each PK/FK relatinship. e. Jin yur assciative table with yur ther table and with yur user table and with yur rle table. Include all the clumns except PK and FK (id) clumns. Order the clumns in a way yu think users wuld like t see them. Order the result set by the first tw r three clumns. There shuld be as many rws in yur result set as there are recrds in yur assciative table. Hint: yu need THREE cnditins in yur WHERE clause, ne fr each PK/FK relatinship. f. Mdify yur SELECT STATEMENT frm item e, adding a cnditin t yur WHERE s that yu see nly the data frm ne user (selected by user.user_id). Select a user such that yur result set has at least 2 recrds in it. g. Mdify yur SELECT STATEMENT frm item e, s that it selects ne user id, tw r mre "ther" recrds (using LIKE keywrd and % wildcard match), and sme cnditin testing a field frm the assciative table. Cme up with cnditins such that yur result set has at least 2 recrds in it. Example f using LIKE: SELECT * FROM tablea, tableb WHERE tableb.tablea_id = tablea.tablea_id AND tableb.name LIKE '%temple%' Page 3
3. Submissin Requirements Create and submit int Blackbard, a wrd r rtf dcument that cntains the inf described belw. Include yur last name in the file name f this dcument. Use landscape if that's easier t read. 1. Yur name. 2. Heading "Functinality" fllwed by yur web applicatin's prpsed functinality. 3. Heading "Marketing Material" fllwed by 1-2 paragraphs that attempt t entice peple t becme registered users and/r viewers f yur web site. This will becme the basis fr the cntent area f yur hme page. In yur paragraphs, d nt explain t me what yur web site will be able t d, write text that will entice users t visit yur site. 4. Heading "Data Mdel" fllwed by a screen capture f yur data mdel (created in MySQLWB). One way t get a screen capture is t press Alt-PrtSc (cpies active windw int the clipbard), paste int MsPaint (r any ther image editr), then cpy just the part f interest int yur wrd/rtf dcument (if yu paste the whle screen, it's t hard t read). Or use snippet tl. 5. Heading "Table Designs" fllwed by (fr each f yur fur tables) a screen capture f the table design and freign key tab f the table's design (if the table has a freign key). 6. Heading "Feedback frm Classmates" fllwed by the names and feedback frm tw classmates wh reviewed yur Data Mdel and prpsed functinality. 7. Heading "My Feedback" fllwed by the names and feedback that yu prvided t tw classmates. 8. Heading "SELECT Statements" fllwed by this fr each f the 7 select statements: Cpy/paste the descriptin f the SQL statement (frm this dc). Paste a screen capture f the SQL query windw (we need the screen capture s we can be sure that yur SQL ran prperly). The screen capture shall include: tp area: syntactically crrect SQL (n red/errr messages), middle area: all rws and all clumns f result set, bttm area (Actin Output): cnfirmatin message with number f rws returned (right click the green checkbx - clear befre running the SQL that yu are screen capturing). Right click this checkmark and clear this befre running SQL Page 4
Fr fast feedback, hand in a hard cpy f the first fur sectins this dc (name -> data mdel) t yur instructr in lecture. 4. Lab Grading Prfessinalism: When yu answer the questins abut yur prpsed web applicatin, especially the last questin which asks fr marketing material, we are lking fr quality that wuld be acceptable by a real cmpany that might be paying yu t create their web site. Check list: We will check that yur data mdel meets all f the requirements listed in lab 1 (requirements such as data type, PK, FK, null-able, unique). This is very imprtant, since yu will lse pints in many future labs and the prject if yur data mdel is nt as specified. Cnsistency: Yur data mdel has t be able t supprt the functinality that yu say yur web applicatin will ffer. Originality f Prject and Data Mdel: As in mst lab assignments, pints will be deducted if yur answer is t similar t the sample r sample(s) prvided. In this case, I gave yu a lt f prject ideas, s it s OK if yur web applicatin prpsal is similar t ne f them. Hwever, yur data mdel cannt be verly similar t the cncert/band/venue example I prvided. It als cannt be verly similar t any ther student in the class. Realistic Data: Yu were asked t enter realistic data s that yur web applicatin lks gd when it begins t display data n its pages. SELECT Statements: The select statements must be syntactically crrect and prduce the required results. The screen captures need t be readable and verifiable as described in the submissin sectin. Timeliness: See lab due date schedule (in BB) fr late plicy fr labs. 5. Suggested apprach: 1. Self check yur data mdel and functinality/marketing material. 2. Find tw classmates with whm yu will d mutual review f data mdel / functinality. Take nte f yur feedback fr the tw classmates (yu will submit alng with this lab). These students shuld als review yur wrk. 3. Ppulate yur database with realistic lking data. 4. Start wrking n the SQL select statements and getting the screen captures. If landscape wrks better t shw yur wrk, select that Page Layut. In Wrd, yu might als click n "View Web Layut" t be able t shw infrmatin better. 5. Start building yur dcument (as described in the Submissin Requirements sectin). Page 5