Presentation is loading. Please wait.

Presentation is loading. Please wait.

Database Systems Instructor Name: Lecture-5.

Similar presentations


Presentation on theme: "Database Systems Instructor Name: Lecture-5."— Presentation transcript:

1 Database Systems Instructor Name: Lecture-5

2 Today’s Lecture Database Design Steps Basis of Conceptual Schema
Business Rules Entity-Relationship Model Entity-Relationship Diagram 2

3 Three Levels of Modeling
Database Design Steps info Entity-relationship Model Typically used for conceptual database design Conceptual DB design Three Levels of Modeling Conceptual Data Model Logical DB design Logical Data Model Relational Model Typically used for logical database design Physical DB design Physical Data Model 3 CMSC424, Spring 2005

4 Basis of Conceptual Schema
Documents the rules and policies of organization that govern the data is the basis of conceptual schema A detailed description of names and definitions of main data objects in terms of Entity types (Customers, Products) Relationships (Customer buys Products) Constraints 4

5 Business Rules – Foundation of Conceptual Design
A business rule is “a statement that defines or constrains some aspect of the business. It is intended to assert business structure or to control or influence the behavior of the business rules prevent, cause, or suggest things to happen Derived from policies, procedures, events, functions, and other business objects, and they state constraints on the organization. Business rules represent the language and fundamental structure of an organization (Hay, 2003). Business rules formalize the understanding of the organization by organization owners, managers, and leaders with that of information systems architects 5

6 Modeling the Rules of Organization as System Analyst
Modeling Business Rules along with policies to create, update or remove data in an information processing and storage system A student is any person who has applied for admission or taken any course or training from any credit or noncredit unit of the University (Defines the concept as well as University Policy) A System Analyst: Identify and understand the rules that govern the data Represent those rules so that they can be unambiguously understood by database developers and users Caution: Conceptual Model do not represent all business rules. 6

7 Identifying and Understanding Business Rules
Interview Questions Documentation Is this always true? Any special circumstances when an alternative occurs? Are there distinct kind of that person? Only one or many? Interested to keep history or archive? 7

8 Entity/ Attribute Names
Data Names should be Related to Business and not Technical (Customer) Be Meaningful : avoid has, it , person etc Be Unique: For each object of data model Be Readable: gradePointAverage is good that averageOfGradePointsObtainedByStudent From Approved List of Organization: Use Alias if allowed Be Repeatable : Student Birth Date or Employee Birth Date Follow Standards 8

9 Entity-Relationship Model
The E-R model was introduced in a key article by Chen (1976) A Logical and semantic representation of data for an organization using entities for categories of data and relationship for association between entities. 9

10 Entity-Relationship Diagram
A graphical representation of ER Model. Comprises of Entities, Attributes, Relationships Developing an ER Diagram: The process of database design is an iterative rather than a linear or sequential process. It usually begins with a general narrative of the organization’s operations and procedures. The basic E-R model is graphically depicted and presented for review. The process is repeated until the end users and designers agree that the E-R diagram is a fair representation of the organization’s activities and functions. 10

11 Entity Definition A person, a place, an object, an event, or a concept in the user environment about which the organization wishes to maintain data. The Entity has a noun name 11

12 Identifying Entity People: Staff, Client, Customer, Owner, Members, Patients, Contacts, other individuals... Objects: Stock, Items, Real Estate, Offices, ... Organizations: Firms (Customers or Vendors), Departments, Clubs, Committees, .. Object Classes: Recordings, Films, Books, Types of Stock, Biological Species, Work Rules Events: Concerts, Examination, Lectures, Consultation, Sales,.. 12

13 What is NOT an Entity? Any thing, person or object that generate or receive data is not an Entity Example: Company, Treasurer, Librarian etc. Noun that do not have more than one instance Instead Use Constant Several Instance but Fixed Day of Week Organization is not interested 13

14 Entity - Terms Entity Type Entity Instance Entity Set 14

15 Entity Type A Collection of Entities that Share common properties or characteristics Entity Type is described by its name and attributes Described only once as metadata in the database Intension for set of entities share common characteristics Employees working in different departments Student studying in different departments of University 15

16 Share common characteristics e.g. Sports, electric equipment etc
Identify Entity Type Share common characteristics e.g. Sports, electric equipment etc Interest of the Organization e.g. Items of all kinds 16

17 Entity Type - Example Entity Type - Student Year Class RollNo Name
Fname Address Number(4) VARCHAR (100) VARCHAR(500) (500) (2000) 17

18 A Single Occurrence of an Entity Type
Entity Instance A Single Occurrence of an Entity Type Occurs as Stored Data in the Database 18

19 Entity Instance - Example
Entity Instance- Student Year Class RollNo Name Fname Address 2011 BSCS 100 Ali Qasim Lahore 19

20 Entity Set Each entity set has a key. Each attribute has a domain.
The Collection of all entity instances of a particular entity type at a given moment is called Entity Set Describe Extension of Entity Type Each entity set has a key. Each attribute has a domain. Example: EMLOYEE refers to Entity type as well as occurrences of all Employees 20

21 Entity Type and Set - Example
21

22 Classification of Entity Types
Strong Entity: It is also called Regular or Independent Entity Weak Entity: It is also called Dependant Entity 22

23 Strong/ Regular/ Independent Entity
An entity type that exists independently of the other entity types Example: Student, Course, Instructor 23

24 Weak Entity An entity type whose existence dependent on another entity type It has total participation in the identifying relationship set Example: Dependent of an Employee Vehicle of an Instructor OR Student in the University 24

25 Symbols for Strong and Weak Entity
Strong Entity Weak Entity EMPLOYEE DEPENDENT 25

26 Strong Entity and Weak Entity - Example
26

27 Naming Entity Type Defined by singular entity as STUDENT, COURSE, CUSTOMER, however, sometimes plural describes the Entity Type more precisely such CUSTOMER orders ITEMES. Use Capital Letters Specific to the Organization, A retail store might deal with CUSTOMER, whereas, A CONSULTANCY FIRM might deal with CLIENTS. A PURCHASE ORDER is a distinct entity type whereas a CUSTOMER ORDER is another distinct entity type. Use as few words as possible to describe Entity Type. It is called conciseness. 27

28 Naming Entity Type Name of Event Entity Type shall be assigned by result of the Event e.g. A project assigned to the employee is ASSIGNMENT, undertaking exam by a student is EXAMINATION. Standardized name across the organization, however, aliases can be used to further enhance the understanding such as ITEM may be used a MATERIAL or DRAWING 28

29 Attribute How many attributes in an Entity Type??
A property or characteristic of an entity type that is of interest to the organization An Attribute is associated with exactly one entity or relationship Each Entity type has its own attributes only and does not include any foreign attribute, these foreign attributes are defined by relationship Initial capital then lowercase for naming Domain of attribute (check to restraint values) Student – Student Id, Student Name, Major, Session, Address Employee – Employee Id, Employee Name, Address, Phone Number How many attributes in an Entity Type?? 29

30 Types of Attributes Required VS Optional Attributes
Simple VS Composite Attributes Single Valued VS Multivalued Attributes Stored VS Derived Attributes Identifier Attribute 30

31 Required VS Optional Attribute
Required Attribute: An attribute that MUST have a value for each Entity Instance in the Entity Type to which it is related Optional Attribute: An attribute that may or may not have value present for each Entity Instance in the Entity Type to which it is associated NULL: Null indicates “Not Applicable”, It does not have a value. It is nothing or Unknown. It is known but missing It is not known whether exist or not 31

32 Simple VS Composite Attributes
Composite Attributes: An attribute that can be broken down into meaningful components or parts Name into First Name, Middle Name, Last Name Address into Street, City, State, Country Simple Attribute: An attribute that can not be broken down into sub components or parts Student Gender Vehicle Color 32

33 Single Valued VS Mutivalued Attributes
Single Valued Attribute: An attribute that have one value for a given Entity Instance Multivalued Attribute: An attribute that have multiple values for a given Entity Instance Employee Skill is a multivalue attribute 33

34 Stored VS Derived Attributes
Stored Attribute: An attribute that is stored in the database Derived Attribute: An attribute whose value can be calculated from related attribute Age, Experience, CGPA etc. 34

35 Identifier Attributes
Also called key attribute of an Entity Type Identifier Attribute: An attribute or combination of attributes whose value distinguishes or uniquely identify an Entity Instance of an Entity Type It has a distinct value for each Entity Instance Composite Identifier: An identifier that consists of composite attribute Flight ID, Date, Time. A Weak Entity Type does not have Identifier Attribute 35

36 Naming Attributes An attribute should be singular noun or noun phrase that shall be materialized as data values Should be unique in an Entity type. May be prefixed with Entity Type for clarity Or may have a qualifier like (min, max etc). Similar attributes across different Entity Type use same qualifier and class. Class is permissible properties of Entity type like cls for class Qualifier are constraints on classes. 36

37 Symbol for Attributes Simple Composite Multivalued 37

38 Symbol for Attributes Derived Identifier 38

39 Entity VS Attribute Should address be an attribute of Employees or an entity (related to Employees)? Depends upon how we want to use address information, and the semantics of the data: If we have several addresses per employee, address must be an entity (since attributes cannot be set-valued). If the structure (city, street, etc.) is important, address must be modeled as an entity (since attribute values are atomic). 39

40 Relationship An relationship is an association that represent the interaction among Entity Instances of one or more Entity Types that is of interest to the organization It is Verb or Verb Phrase 40

41 Relationship- A Mathematical Definition
if A, B are sets, then a relation R is a subset of A  B A={1,2,3}, B={a,b,c,d}, A  B = {(1,a),(1,b), . . ., (3,d)} R = {(1,a), (1,c), (3,b)} - makes is a subset of Product  Company: 1 2 3 a b c d A= B= makes Company Product 41

42 Relationship Type An relationship Type is an Abstraction of Meaningful Associations among Entity Types It can answer the questions that is of interest to the organizations and these Answers cannot be answered by only using Entity Types 42

43 Relationship Set It is a set of associations or relationships among entities from participating Entity Types The Association between Entity Sets is referred to as participation. E1, E2, E3 participate in relationship set (e1, e2,e3) etc 43

44 Relationship Instance
It is an association between/ among entity instances where each relationship instance associates with exactly one entity instance from participating Entity Types 44

45 Example – Relationship Type, Relationship Instance and Relationship Set
45

46 Erroneous Relationship
Receives or summarize the data, transfer, translate or calculate data 46

47 Design Pitfalls in Conceptual Schema
Redundancy Course (course_code, Title, Major, credit_hours), store course title information only once. Incompleteness We have major, without courses offered in that major 47

48 Creating Database Objects
Oracle Offers Four Basic Data Types VARCHAR2(n) CHAR(n) NUMBER(p,s) DATE 48

49 Creating Table CREATE TABLE table_name ( Id Number NOT NULL,
Name VARCHAR2(64) ); 49

50 Assignment – What I was Expecting
major Department offers Is double major allowed? Can a student have more than 1 advisor? Is joint appointment of faculty possible? Can two profs share to teach the same course? Can a professor teach more than one course? Can a professor stay without affiliated with a department? faculty Courses teaches Professor advisor enrollment Students 50

51 ???????????????? 51


Download ppt "Database Systems Instructor Name: Lecture-5."

Similar presentations


Ads by Google