Presentation on theme: "Data Base Design. D ATA M ODELING Database modeling is the first step to design a complex database Entity relationship diagram (ERD) – a data model."— Presentation transcript:
Data Base Design
D ATA M ODELING Database modeling is the first step to design a complex database Entity relationship diagram (ERD) – a data model utilizing several notations to depict data in terms of the entities and relationships described by that data.
S AMPLE E NTITY R ELATIONSHIP D IAGRAM (ERD)
Persons: customer, employee, student. Places: building, room, office, campus. Objects: book, machine, product. Events: application, award, class, flight. Concepts: account, bond, course, fund. D ATA M ODELING C ONCEPTS : E NTITY Entity – a class of persons, places, objects, events, or concepts about which we need to capture and store data. Named by a singular noun
D ATA M ODELING C ONCEPTS : E NTITY Entity instance – a single occurrence of an entity. Student IDLast NameFirst Name 2144ArnoldBetty 3122TaylorJohn 3843SimmonsLisa 9844MacyBill 2837LeathHeather 2293WrenchTim instances entity
D ATA M ODELING C ONCEPTS : A TTRIBUTES Attribute – a descriptive property or characteristic of an entity.
D ATA T YPE Data type – a property of an attribute that identifies what type of data can be stored in that attribute. Representative Logical Data Types for Attributes Data TypeLogical Business Meaning NUMBERAny number, real or integer. TEXTA string of characters, inclusive of numbers. When numbers are included in a TEXT attribute, it means that we do not expect to perform arithmetic or comparisons with those numbers. MEMOSame as TEXT but of an indeterminate size. Some business systems require the ability to attach potentially lengthy notes to a give database record. DATEAny date in any format. TIMEAny time in any format. YES/NOAn attribute that can assume only one of these two values. VALUE SETA finite set of values. In most cases, a coding scheme would be established (e.g., FR=Freshman, SO=Sophomore, JR=Junior, SR=Senior). IMAGEAny picture or image.
D EFAULT V ALUE Default value – the value that will be recorded if a value is not specified by the user. Permissible Default Values for Attributes Default ValueInterpretationExamples A legal value from the domain For an instance of the attribute, if the user does not specify a value, then use this value NONE or NULLFor an instance of the attribute, if the user does not specify a value, then leave it blank. NONE NULL Required or NOT NULL For an instance of the attribute, require that the user enter a legal value from the domain. (This is used when no value in the domain is common enough to be a default but some value must be entered.) REQUIRED NOT NULL
D ATA M ODELING C ONCEPTS : I DENTIFICATION Primary key – a field used to uniquely identify a single entity instance.
D ATA M ODELING C ONCEPTS : R ELATIONSHIPS Relationship – a natural business association that exists between one or more entities. The relationship may represent an event that links the entities or merely a logical relation that exists between the entities. studentcourse
D ATA M ODELING C ONCEPTS : F OREIGN K EYS Foreign key – a primary key of an entity that is used in another entity to identify instances of a relationship. A foreign key is a primary key of one entity that is contributed to (duplicated in) another entity to identify instances of a relationship. A foreign key always matches the primary key in the another entity
D ATA M ODELING C ONCEPTS : F OREIGN K EYS Student IDLast NameFirst NameDorm 2144ArnoldBettySmith 3122TaylorJohnJones 3843SimmonsLisaSmith 9844MacyBill 2837LeathHeatherSmith 2293WrenchTimJones DormResidence Director SmithAndrea Fernandez JonesDaniel Abidjan Primary Key Foreign Key Duplicated from primary key of Dorm entity (not unique in Student entity)
D ATA M ODELING C ONCEPTS : N ONSPECIFIC R ELATIONSHIPS Nonspecific relationship – relationship where many instances of an entity are associated with many instances of another entity. Also called many-to-many relationship. Nonspecific relationships must be resolved, generally by introducing an associative entity.
R ESOLVE MANY - TO - MANY RELATIONSHIP
U SING M ICROSOFT A CCESS 2007 Access contains four types of components Table: used for data storing Form: used for data entering Query: used for data selection Report: used for formally data display Procedures: Design tables Enter data Do queries (select interesting data) Produce report
C ASE S TUDY : AN AIRLINE RESERVATION SYSTEM Passengers reserve flights through agents, who can directly access the system. An airline company can access the system to open or close a flight for reservation. Different airline companies propose different flights Each reservation concerns one flight and one passenger. A reservation could have two kinds of status: cancelled and confirmed. A flight has a departure airport and an arrival airport. A flight has a date and time of departure, and a date and time of arrival. Your task is to create an entity-relation diagram to show the data entities (tables) and their relations in this system.