……... business informatics 2 (pwin) ss 2011, chair of mobile business & multilateral...

59
. . . Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 1 Jenser (Flickr.com) Chair of Mobile Business & Multilateral Security Exercise 4 Business Informatics 2 (PWIN) Markup Languages & Databases & Structured Querry Language SS 2011 Dr. Andreas Albers www.m-chair.net

Upload: molly-phillips

Post on 02-Jan-2016

214 views

Category:

Documents


1 download

TRANSCRIPT

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 1

Jenser (Flickr.com)

Chair of Mobile Business & Multilateral Security

Exercise 4Business Informatics 2 (PWIN) Markup Languages & Databases &Structured Querry LanguageSS 2011

Dr. Andreas Alberswww.m-chair.net

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 2

Agenda

Exercise 1: Repetition XML (Mentorium)

Exercise 2: Well-formed XML Documents

Exercise 3: Validated XML Documents

Exercise 4: ER-Model

Exercise 5: Repetition SQL (Mentorium)

Exercise 6: SQL Statements

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 3

XML Example

Write a DTD for the storage of a dynamic customer profile based on the Myplace example. Furthermore write an example XML document which is based on this DTD.

The customer profile shall include a user’s pseudonym, login time, current location, personal data (age, gender, interests). Possible interests are cinema, restaurant, tennis, soccer, sports bar… .

Example for XML Document: Pseudonym: mobileFritz1380, Age: 25,

gender: male Interests: Cinema, Restaurants

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 4

DTD & XML Dokument “User”

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 5

Agenda

Exercise 1: Repetition XML (Mentorium)

Exercise 2: Well-formed XML Documents

Exercise 3: Validated XML Documents

Exercise 4: ER-Model

Exercise 5: Repetition SQL (Mentorium)

Exercise 6: SQL Statements

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 6

Exercise 2: Well-formed XML Documents

Which of the following XML Documents are well-formed (two XML Documents per page)?

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 7

Exercise 2: Well-formed XML Documents (1)

<?xml version="1.0"?>

<User>

<Pseudonym>

Jenny23

</Pseudonym>

<Mobile_Operator>

t-mobile

</ Mobile_Operator >

<Registration>

03.02.2007

</Registration>

<Lastlogin>

29.04.2007

</Lastlogin>

</User>

<?xml version="1.0"?>

<User>

<Pseudonym>

Joe1976

</Pseudonym>

< Mobile_Operator >

vodafone

</ Mobile_Operator >

< Registration >

03.02.2007

< Lastlogin >

29.04.2007

</User>

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 8

Exercise 2: Well-formed XML Documents (2)

<?xml version="1.0"?>

<Date>

<Place>

Fressgass 17, Frankfurt

</ Place >

<Time>

25.03.2007, 21:15-0:15

</Time>

<Meeting_Point>

Starbucks

<People>

Gina

</Meeting_Point>

</People>

<People>

Jimmy

</People>

<Activitiy>

Cocktails

</Activitiy>

<Comment>

Gina 2 Caipis ausgegeben

</Comment>

</Date>

<?xml version="1.0"?><Date><Place>

Schweizer Strasse, Frankfurt</Place><Time>

25.03.2007, 21:15-0:15</Time><Meeting_Point>

Apfelwein-Wagner</Meeting_Point><People> Pit</People><People>

Jenny23</People><Activitiy>

Äppler trinken</Activitiy><Comment> Pit hatte coole Sonnenbrille an!</Comment></Date>

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 9

Agenda

Exercise 1: Repetition XML (Mentorium)

Exercise 2: Well-formed XML Documents

Exercise 3: Validated XML Documents

Exercise 4: ER-Model

Exercise 5: Repetition SQL (Mentorium)

Exercise 6: SQL Statements

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 10

InstantONS® has bought a competitor and wants to integrate his data into its own database. Unfortunately the data is structured differently.

Validate the following XML document extracted from the competitors database against the DTD of InstantONS®. If there are mismatches, adapt the DTD so the new data can be integrated without losses.

Exercise 3: Validated XML Documents

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 11

Exercise 3: Validated XML Documents

<Date> … (gekürzt)<People>

Jenny23</People><Activity>

Äppler trinken</Activity><Success> <Compliment>ja</Compliment> <Invitation>nein</Invitation> <Newdate>nein</Newdate></Success><Comment> Pit hatte coole Sonnenbrille an!</Comment>

<?xml version="1.0"?>

<!DOCTYPE Date [<!ELEMENT Date (Place,Time,Meeting_Point,People+, Activity,Comment)>

<!ELEMENT Place (#PCDATA)> <!ELEMENT Time (#PCDATA)> <!ELEMENT Meeting_Point (#PCDATA)> <!ELEMENT People (#PCDATA)> <!ELEMENT Activity (#PCDATA)> <!ELEMENT Comment (#PCDATA)>]>

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 12

Exercise 3: Validated XML Documents

(Solution)

12

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 13

Agenda

Exercise 1: Repetition XML (Mentorium)

Exercise 2: Well-formed XML Documents

Exercise 3: Validated XML Documents

Exercise 4: ER-Model

Exercise 5: Repetition SQL (Mentorium)

Exercise 6: SQL Statements

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 14

Exercise 4: ER-Model

Create an ER-Model of the InstantONS® system with the help of the following information:

Use the following entities for your model: User InstantONS Date (when, where, who, how often …), Event (cinema, restaurant, …) Eigenschaft (User profile, e.g. age) Meeting Point(Location for the date)

Identify and mark the primary key for each entity and avoid as far as possible artificial keys (e.g. ID).

Define the Cardinalities, using the 1:n notation. Make explicitly use of weak entities.

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 15

Exercise 4: ER-Model(6)

InstantONS® System

1. Users register at InstantONS®. Thereby, they receive their pseudonyms and submit their personal profile information. Subsequently, InstantONS® attempts to certify the profile attributes of the users.

2. In order to start searching for a date, users have to activate the InstantONS® app on their mobile device.3. InstantONS® attempts to find other InstantONS® users in close proximity who are also currently looking for a

date.4. InstantONS® matches the personal proinforms the corresponding users by presenting them with a list of

matching pseudonyms. 5. InstantONS® enables matching users to communicate with each other using text messages, chat or voice. 6. If users want to arrange a meeting, InstantONS® suggests a list of appropriate meeting points based on the

personal interests of the corresponding users as well as their current geographic location. Then, InstantONS®

navigates the users to their meeting point. 7. After the date, the users can rate their files of all users in close proximity with each other.8. If there is a match, InstantONS® date on the InstantONS® app. This rating is used to improve their next date

matching process.

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 16

Exercise 4: ER-Model(7)

Define entities

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 17

Exercise 4: ER-Model(8)

Define relationships between the entities

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 18

Exercise 4: ER-Model(9)

Define weak entities

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 19

Exercise 4: ER-Model(10)

Define Cardinalities

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 20

Exercise 4: ER-Model(11)

Define attributes

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 21

Exercise 4: ER-Model(12)

Define attributes

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 22

Agenda

Exercise 1: Repetition XML (Mentorium)

Exercise 2: Well-formed XML Documents

Exercise 3: Validated XML Documents

Exercise 4: ER-Model

Exercise 5: Repetition SQL (Mentorium)

Exercise 6: SQL Statements

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 23

Exercise 5: Repetition SQL (Mentorium)

branch_namebranch_city

assets

Brighton Brooklyn7100000.00

Downtown Brooklyn9000000.00

Mianus Horseneck400000.00

North Town Rye3700000.00

Perryridge Horseneck1700000.00

Pownal Bennington300000.00

Redwood Palo Alto2100000.00

Round Hill Horseneck8000000.00

customer_name

customer_street

customer_city

Adams Spring PittsfieldBrooks Senator BrooklynCurry North RyeGlenn Sand Hill WoodsideGreen Walnut StamfordHayes Main HarrisonJackson University Salt LakeJohnson Alma Palo AltoJones Main HarrisonLindsay Park PittsfieldSmith Main RyeTurner Putnam StamfordWilliams Nassau Princeton

• The database Fortune Bank consists of four tables:Database: Fortune_Bank

Table: branch Table: customer

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 24

Exercise 5: Repetition SQL (Mentorium)

loan_number

branch_name

amount

L-11 Round Hill 900.00

L-14 Downtown 1500.00

L-15 Perryridge 1500.00

L-16 Perryridge 1300.00

L-17 Downtown 1000.00

L-23 Redwood 2000.00

L-93 Mianus 500.00

customer_name loan_numberAdams L-16Curry L-93Hayes L-15Jackson L-14Jones L-17Smith L-11Smith L-23Williams L-17

• The database Fortune Bank consists of fourtables:Database: Fortune_Bank

Table: loan Table: borrower

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 25

Exercise 5: Repetition SQL (Mentorium)

Write the appropriate SQL statements to answer the following questions and draw table which will be returned as a result.

a) How many borrowers are serviced by the branch “Downtown” and live in Princeton?

b) How many loans were granted exceeding $1000 ?c) Insert a new loan in the table “loan”.d) Delete the previously inserted entry from the table “loan”.

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 26

a) How many borrowers are serviced by the branch “Downtown” and live in Princeton?

Exercise 5a)

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 27

b) How many loans were granted exceeding 1000$ ?

Exercise 5b)

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 28

c) Insert a new loan in the table “loan”.

Exercise 5c)

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 29

d) Delete the previously inserted entry from the table “loan”.

Exercise 5d)

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 30

Agenda

Exercise 1: Repetition XML (Mentorium)

Exercise 2: Well-formed XML Documents

Exercise 3: Validated XML Documents

Exercise 4: ER-Model

Exercise 5: Repetition SQL (Mentorium)

Exercise 6: SQL Statements

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 31

Exercise 6: SQL

ID CustomerID Username Gender Birthdate Dateofregistration Lastlogin

1 2015452 terry24 m 1983-02-19 2006-01-01 2007-01-24

2 2017647 bob34 m 1973-03-28 2006-05-01 2007-01-24

3 2012470 chuck_norris m 1978-01-12 2006-08-17 2007-01-24

4 2097742 anspruchsvoll f 1979-06-25 2006-08-19 2007-01-23

5 2057454 wonne f 1975-09-27 2006-08-15 2007-01-09

6 2064719 hasi1979 f 1979-01-15 2006-07-16 2007-01-10

7 2142441 kussecht f 1978-05-12 2005-05-14 2007-01-13

8 2145714 nightmoon f 1975-05-21 2005-12-03 2007-01-14

9 2197654 schubby m 1975-05-26 2005-12-01 2007-01-24

10 2154757 selin28 f 1979-03-09 2005-12-24 2007-01-02

11 2164574 urmel31 m 1976-05-02 2007-01-01 2007-01-23

12 2113335 hexchen f 1971-02-15 2005-07-31 2007-01-19

13 2124574 sternschnuppe f 1972-06-06 2007-01-09 2007-01-20

14 2247577 sommergefluester f 1975-08-11 2005-04-19 2007-01-17

The database InstantONS® consists of two tables:Database: InstantonsTable: Customer_data

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 32

ID CustomerID Size Weight Haircolor Familystatus Kids Fitness Hobby1 Hobby2 Hobby3

1 2015452 1.85 65.0 blond single 1 topfit Music Jogging Music

2 2017647 1.70 62.5 black single 0 normal Hockey Cycling Swimming

3 2012470 1.52 60.0 brown single 0 unfit Video games Museums Watching TV

4 2097742 1.65 59.8 brown divorced 2 unfit Theater Watching TV Cooking

5 2057454 1.63 72.0 black single 1 unfit Video games Cooking Hockey

6 2064719 1.54 48.0 blond single 0 normal Swimming Cycling Theater

7 2142441 1.62 51.2 blond divorced 0 topfit Jogging Swimming Video games

8 2145714 1.67 60.2 read single 2 topfit Cycling Music Jogging

9 2197654 1.69 59.4 black single 0 normal Video games Theater Music

10 2154757 1.71 62.5 black single 0 normal Swimming Theater Museums

11 2164574 1.68 59.5 black divorced 1 topfit Cycling Jogging Swimming

12 2113335 1.75 65.3 read single 0 normal Museums Cycling Swimming

13 2124574 1.78 80.5 blond single 0 unfit Watching TV Hockey Music

14 2247577 1.84 72.5 blond single 0 unfit Watching TV Video games Theater

Tabelle: Customer_interests

Exercise 6: SQL

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 33

a) How many customers are stored in the table „Customer_data“?

Exercise 6a)

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 34

Exercise 6b)

b) What is the average weight over all InstantONS® users?

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 35

Exercise 6c)

c) What is the weight of the heaviest customer?

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 36

Exercise 6d)

d) How many people were logged in per day?

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 37

Exercise 6e)

e) How many male (female) users do exist in InstantONS®?

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 38

Exercise 6f)

f) Display the Usernames of all users born in 1975.

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 39

Exercise 6g)

g) Display the “Username“ and “Birthdate” of all users, sorted descending.

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 40

Exercise 6h)

h) How many users are “topfit“?

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 41

Exercise 6i)

i) How many users are “unfit“?

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 42

Exercise 6j) Alternative 1

j) Display the “Username”, “Gender” and the first two hobbies of each user.

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 43

Exercise 6j) Alternative 2

j) ) Display the “Username”, “Gender” and the first two hobbies of each user.

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 44

Exercise 6k) Alternative 1

k) How many users are female and are playing „Video games“ as first or second hobby?

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 45

Exercise 6k) Alternative 2

k) How many users are female and are playing “Video games“ as first or second hobby?

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 46

Exercise 6l)

l) How many users are “single“, but do have kids?

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 47

Exercise 6m)

m) Display the “Username”, “Gender”, “Size” and the according hobbies of each user.

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 48

Exercise 6m) Alternative 1

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 49

Exercise 6m) Alternative 2

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 50

Exercise 6n)

n) How many users registered for InstantONS® in 2006?

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 51

Exercise 6o) Alternative 1

o) Display the “Username”, “Haircolor” and the first hobby of all users.

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 52

Exercise 6o) Alternative 2

o) Display the “Username”, “Haircolor” and the first hobby of all users.

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 53

Exercise 6p)

p) Insert a data record into the table “Customer_data“ and display it with all attributes.

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 54

Exercise 6q)

q) Insert a data record into the table “Customer_data“ and display it with “CustomerID” and “Hobby2” only.

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 55

Exercise 6r)

r) Update the “Weight” of the user with the CustomerID „2057454“ to 62 kilograms.

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 56

Exercise 6s)

s) Delete the entry inserted in Exercise p).

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 57

Exercise 6t)

u) Delete the whole table „Customer_interests“.

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 58

Exercise 6v)

v) Delete the whole database.

……

...…

… ...

Business Informatics 2 (PWIN) SS 2011, Chair of Mobile Business & Multilateral Security 59

Questions

Open Questions?