15
2/18/2019 Null example” MariaDB [c4333u]> select * from enroll where grade is not null; +-------+-------------+-------+ | stuId | classNumber | grade | +-------+-------------+-------+ | S1001 | ART103A | A | | S1002 | ART103A | D | | S1005 | ART103A | B | | S1002 | CSC201A | F | | S1005 | CSC201A | C | | S1010 | CSC201A | A | | S1015 | CSC201A | B | | S1020 | CSC201A | B | | S1001 | HST205A | C | | S1005 | HST205A | A | | S1002 | MTH101B | C | | S1020 | MTH101B | A | | S1002 | MTH103C | B | | S1020 | MTH103C | C | +-------+-------------+-------+ John has a car: aggregation? Ownership. A car has an engine: possible: a part of -> aggregation: part (engine), whole (car), engine does not exist by itself. A man is a person: specialization and generalization relationship A man is a kind of a person. Bun is a person: instantiation relationship: Bun, object and Person, class.

University of Houston–Clear Lakedcm.uhcl.edu/yue/courses/csci4333/spring2019/demo/… · Web viewA member must have an account to access GG member pages. An account contains an

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: University of Houston–Clear Lakedcm.uhcl.edu/yue/courses/csci4333/spring2019/demo/… · Web viewA member must have an account to access GG member pages. An account contains an

2/18/2019

Null example”MariaDB [c4333u]> select * from enroll where grade is not null;+-------+-------------+-------+| stuId | classNumber | grade |+-------+-------------+-------+| S1001 | ART103A | A || S1002 | ART103A | D || S1005 | ART103A | B || S1002 | CSC201A | F || S1005 | CSC201A | C || S1010 | CSC201A | A || S1015 | CSC201A | B || S1020 | CSC201A | B || S1001 | HST205A | C || S1005 | HST205A | A || S1002 | MTH101B | C || S1020 | MTH101B | A || S1002 | MTH103C | B || S1020 | MTH103C | C |+-------+-------------+-------+

John has a car: aggregation? Ownership.A car has an engine: possible: a part of -> aggregation: part (engine), whole (car), engine does not exist by itself.A man is a person: specialization and generalization relationshipA man is a kind of a person.Bun is a person: instantiation relationship: Bun, object and Person, class.

Page 2: University of Houston–Clear Lakedcm.uhcl.edu/yue/courses/csci4333/spring2019/demo/… · Web viewA member must have an account to access GG member pages. An account contains an

2/13/2019

A member must have an account to access GG member pages. An account contains an unique id serving as the key, and an unique username and password for logging on.

Concept:

1. Account: a. attribute of GG.b. An entity by itself (plus a relationship with the entity member).c. An attribute of member.d.

2. Pages: sign-in pages (input/output requirements): no need to capture.3. access GG member pages: you need account information stored.4. Properties of an account entity: id, username, password5. Unique id: PK.6. Unique username: not in ER-Assistant

There are many types of users (such as administrators, etc.) of accounts. These other kinds of accounts need not be modeled in this assignment. GG stores the previous old passwords for all accounts and the times these passwords were set. This is used for the purposes that account holders do not reuse old passwords.

7. Account types: a. attribute of accountb. entity by itself (plus a relationship with a member.

8. Administrator: an example of type.a. attribute valueb. value of the entity ‘Types’

For example, the account 1269487 may have the following history of passwords (encrypted when stored):

Concept:

1. password

Page 3: University of Houston–Clear Lakedcm.uhcl.edu/yue/courses/csci4333/spring2019/demo/… · Web viewA member must have an account to access GG member pages. An account contains an

a. new entity: password. Because: two properties and unlimited password, each modeled by a password entity instance.

b. Attribute of ?i. Member: probably no, password is not a property of member.ii. Account: password is a property of account. Password and

settime as two attributes, limited number of passwords.c. Relationship between ?

i. Member and Account2. password set time.

For example, the account 1269487 may have the following history of passwords (encrypted when stored):

1. current password: hahasui19$$$90 (password value), since 9/12/2017 4:35.27pm (password set time value, example)

2. former old password: $$suihaha2001, since 3/2/2017 11:11.27am3. former old password: hasuiha__65, since 1/3/2016 5:07.64pm

Page 4: University of Houston–Clear Lakedcm.uhcl.edu/yue/courses/csci4333/spring2019/demo/… · Web viewA member must have an account to access GG member pages. An account contains an

Note that currentPassword is a derived attribute which should be in synch with the password entity. (not to be updated directly)

Page 5: University of Houston–Clear Lakedcm.uhcl.edu/yue/courses/csci4333/spring2019/demo/… · Web viewA member must have an account to access GG member pages. An account contains an

A member may (or may not implied) be referred by another member to GG. Furthermore, a member may follow any number of other GG members. This information needs to be stored.

Concepts:

Refer: relationship between 2 members. Follow: relationship between 2 members.

Page 6: University of Houston–Clear Lakedcm.uhcl.edu/yue/courses/csci4333/spring2019/demo/… · Web viewA member must have an account to access GG member pages. An account contains an

Example:

M1 refers M2, M3 and M4.M5 not referred by anyone.M2 follows M1 and M4M3 follows M4M4 not follows anyone.

M1 (member) refers (verb) M2 (member)

Page 7: University of Houston–Clear Lakedcm.uhcl.edu/yue/courses/csci4333/spring2019/demo/… · Web viewA member must have an account to access GG member pages. An account contains an

Members can form groups to serve their needs. A group has an unique id, a name, a purpose, and a creation time. It may has a description. For example, here is a group:

Id: 65483 Name: UHCL DDBers Purpose: Members taking or having taken CSCI 4333 at UHCL wanting to get

good grade. Creation Time: 1/1/2017 6:40pm Description: Communications among students of CSCI 4333 at UHCL.

Page 8: University of Houston–Clear Lakedcm.uhcl.edu/yue/courses/csci4333/spring2019/demo/… · Web viewA member must have an account to access GG member pages. An account contains an

2/11/2019

Some Disadvantages of ER diagrams:

1. Limited expressiveness: cannot be extended; RDBMS2. Not concise: use a lot of spaces, e.g. Chen3. Can be ambiguous4. No standards: many versions that can be confusing (know your ER version):

compare Chen and Crow feet.5. Mostly for relational database only.

Problem

Requirements Concepts captured by ER. Four major options:

Page 9: University of Houston–Clear Lakedcm.uhcl.edu/yue/courses/csci4333/spring2019/demo/… · Web viewA member must have an account to access GG member pages. An account contains an

1. Entity:2. Attribute of what:3. Relationship between two entity instances (of what types)4. No need to capture

Secondary features:1. Cardinality2. PK: primary key; 3. CK: Candidate keys4. Nullable5. Unique6. …o

Fall 2018 Problem:

Any people can become a member of GG. They will need to provide a first name, a last name, an email address and an optional phone. GG stores the time a person joining GG. A member has an unique id.

Concepts:

1. Member: entity (many properties, central concept,..)2. People3. GG: should it be a class? Are there many instances? Are there many

properties to be stored? …4. People becoming member5. Last name, first name, email address, phone: attributes of member.6. Optional: 0 allowed, nullable -> allow nulls.7. JoinTime: be more specific, attribute of member8. Unique Id: attribute of member, PK

Page 10: University of Houston–Clear Lakedcm.uhcl.edu/yue/courses/csci4333/spring2019/demo/… · Web viewA member must have an account to access GG member pages. An account contains an

A member must have an account to access GG member pages. An account contains an unique id serving as the key, and an unique username and password for logging on. There are many types of users (such as administrators, etc.) of accounts. These other kinds of accounts need not be modeled in this assignment. GG stores the previous old passwords for all accounts and the times these passwords were set. This is used for the purposes that account holders do not reuse old passwords.

Concept:

9. Account: a. attribute of GG.b. An entity by itself (plus a relationship with the entity member).c. An attribute of member.d.

10.Pages: sign-in pages (input/output requirements): no need to capture.11.access GG member pages: you need account information stored.12.Properties of an account entity: id, username, password13.Unique id: PK.14.Unique username: not in ER-Assistant15.Types:

a. attribute of accountb. entity by itself (plus a relationship with a member_

16.Administrator: a. attribute valueb. value of the entity ‘Types’

Page 11: University of Houston–Clear Lakedcm.uhcl.edu/yue/courses/csci4333/spring2019/demo/… · Web viewA member must have an account to access GG member pages. An account contains an

For example, the account 1269487 may have the following history of passwords (encrypted when stored):

4. current password: hahasui19$$$90, since 9/12/2017 4:35.27pm5. former old password: $$suihaha2001, since 3/2/2017 11:11.27am6. former old password: hasuiha__65, since 1/3/2016 5:07.64pm

Page 12: University of Houston–Clear Lakedcm.uhcl.edu/yue/courses/csci4333/spring2019/demo/… · Web viewA member must have an account to access GG member pages. An account contains an

2/6/2019

ER: Install ER Assistant

Description: (A student has a unique student id and) can enroll (in any number of classes).

Four choices:

1. Entity: has attributes (properties); form relationships; independent; …2. Relationship between entity: association between two entities, verb, … 3. Attribute: has value (last name: Yue), single value? Property of other

concepts?4. Nothing

Student: entity: many properties: id, name (assumption), form relationship.

Student id: student id (property) of a student: attribute of Student

unique student id: unique describe student_id -> primary key

class: entity (likely to have many properties)

enroll: student – enroll – class: relatiobship.

any number of classes: cardinality (how many instances can participate.)

Page 13: University of Houston–Clear Lakedcm.uhcl.edu/yue/courses/csci4333/spring2019/demo/… · Web viewA member must have an account to access GG member pages. An account contains an
Page 14: University of Houston–Clear Lakedcm.uhcl.edu/yue/courses/csci4333/spring2019/demo/… · Web viewA member must have an account to access GG member pages. An account contains an