Professional Documents
Culture Documents
Unit 1 Part1
Unit 1 Part1
org
We often need to access and re-sort data for various uses. These may include:
Creating mailing lists Writing management reports Generating lists of selected news stories Identifying various client needs
Arrange
Because of the versatility of databases, we find them powering all sorts of projects:
A web site that is capturing registered users
Database Applications: Banking: all transactions Airlines: reservations, schedules Universities: registration, grades Sales: customers, products, purchases Manufacturing: production, inventory, orders, supply chain Human resources: employee records, salaries, tax deductions
Databases touch all aspects of our lives
In the early days, database applications were built on top of file systems. Drawbacks of using file systems to store data:
Data redundancy and inconsistency - duplication of information in different files.
Uncontrolled duplication of data is undesirable for following reasons:
Duplication costs time and money to enter data more than once. It takes additional storage space thus again increasing associated costs. It can be avoided by sharing data files. It may lead to data inconsistency.
Integrity problems
Integrity constraints (e.g. account balance > 0) become part of program code Hard to add new constraints or change existing ones.
Atomicity of updates
Failures may leave database in an inconsistent state with partial updates carried out. E.g. transfer of funds from one account to another should either complete or not happen at all.
Concurrent accessed needed for performance. Uncontrolled concurrent accesses can lead to inconsistencies
E.g. two people reading a balance and updating it at the same time.
Security problems
View level/ External Level: Application programs hide details of data types. Views can also hide information (e.g., salary) for security purposes.
Physical level/Internal level : The physical representation of the database on the computer. This level describes how the data is stored in the database.
Logical level/Conceptual level: The community view of the database. This level describes what data is stored in the database and the relationships among the data. View level/ External Level: The users view of the database. This level describes that part of the database that is relevant to each user.
External Schema 1
External Schema 2
Control of data redundancy Data consistency More information from the same amount of data Sharing of data Improved data integrity Improved security Enforcement of standards Economy of scale Balance of conflicting requirements Improved data accessibility and responsiveness Increased productivity Improved maintenance through data independence
Complexity provision of the functionality we expect from DBMS makes it extremely complex. Size complexity and breadth of functionality makes DBMS extremely large piece of software. Cost of DBMSs it varies significantly depending on the environment & functionality provided. Additional hardware costs to achieve required performance, it is necessary to procure large memory. Performance DBMS is written to be more general, to cater for many applications rather than just one. Higher impact of failure Centralization of resources increases the vulnerability of the system. Since all users & applications rely on DBMS, the failure of one component can bring operations to a halt.
1.
2.
3.
Hardware DBMS and the applications require hardware to run. It can range from PC to mainframe or network of computers. It depends on the organizations requirements and the DBMS used. Software It comprises of following : DBMS software itself Application program Operating System including network software Data - Most important component from end-users point of view. It acts as a bridge between the machine components and the human component. The database contains both operational data and the metadata.
Procedures It refers to the instructions and rules that govern the design and use of the database. Users of the system require documented procedures on how to use/run the system. It may consists of instructions like Log on to the DBMS Use a particular DBMS facility or application program. Start and stop DBMS Make backup copies of the database Handle H/W and S/W failures. Change structure of table to improve performance People i.e USERS
5.
Coordinates all the activities of the database system; the database administrator has a good understanding of the enterprises information resources and needs: Database administrators duties include:
Schema definition Storage structure and access method definition Schema and physical organization modification Granting user authority to access the database Specifying integrity constraints Acting as liaison with users Monitoring performance and responding to changes in requirements
Users are differentiated by the way they expect to interact with the system.
Application programmers: interact with system through DML calls. Specialized users: write specialized database applications that do not fit into the traditional data processing framework Sophisticated users: form requests in a database query language. Naive users: invoke one of the permanent application programs that have been written previously
indices
Statistical data
disk storage
Data files
Data dictionary
Self-describing nature of a database system. Insulation between programs and data, and data abstraction. Support of multiple views of the data. Sharing of data and multiuser transaction processing.
An integrated collection of concepts for describing and manipulating the following in an organization:
Data Data relationships Data semantics Data constraints
Manipulative part defining the types of operations that are allowed on the data (includes insertion, retrieval or updating)
Set of integrity rules for ensuring that data is accurate.
Relational model (e.g., SQL/DS, DB2) Network model Hierarchical model (e.g., IMS)
A hierarchical data model is a data model in which the data is organized into a tree-like structure. The structure allows repeating information using parent/child relationships: each parent can have many children but each child only has one parent. All attributes of a specific record are listed under an entity type.
ADVANTAGES:
Hierarchical Model is simple to construct and operate on. Corresponds to a number of natural hierarchically organized domains - e.g., assemblies in manufacturing, personnel organization in companies Language is simple; uses constructs like GET, GET UNIQUE, GET NEXT, GET NEXT WITHIN PARENT etc.
DISADVANTAGES:
Navigational and procedural nature of processing. Database is visualized as a linear arrangement of records Little scope for "query optimization"
The network model is a database model conceived as a flexible way of representing objects and their relationships. Its distinguishing feature is that the schema, viewed as a graph in which object types are nodes and relationship types are arcs, is not restricted to being a hierarchy or lattice.
ADVANTAGES:
DISADVANTAGES:
Network Model is able to model complex relationships and represents semantics of add/delete on the relationships. Can handle most situations for modeling using record types and relationship types. Language is navigational; uses constructs like FIND, FIND member, FIND owner, FIND NEXT within set, GET etc. Programmers can do optimal navigation through the database. Navigational and procedural nature of processing Database contains a complex array of pointers that thread through a set of records. Little scope for automated "query optimization
Attributes
Palo Alto
Harrison Rye
Instances and schemas are similar to types and variables in programming languages. Schema the logical structure of the database. This means overall description of the database.
e.g., the database consists of information about a set of customers and accounts and the relationship between them. Analogous to type information of a variable in a program. Physical schema: database design at the physical level. Logical schema: database design at the logical level. The schema is specified during the database design process and is not expected to change frequently.
Instance the actual content of the database i.e. actual data at a particular point in time .
Analogous to the value of a variable. The actual data in the database may change very frequently.
Thus many database instances can correspond to the same database schema. The schema is sometimes called as intension of the database. The instance is sometimes called as extension or state of the database.
Mappings among schema levels are needed to transform requests and data. Programs refer to an external schema, and are mapped by the DBMS to the internal schema for execution.
The disjointing of data descriptions from the application programs (or user-interfaces) that uses the data is called data independence.
Data independence is one of the main advantages of DBMS. The three-schema architecture provides the concept of data independence, which means that upper-levels are unaffected by changes to lower-levels. The interfaces between the various levels and components should be well defined so that changes in some parts do not seriously influence others.
Physical Data Independence the ability to modify the physical schema without changing the logical schema Applications depend on the logical schema In general, the interfaces between the various levels and components should be well defined so that changes in some parts do not seriously influence others.
Logical Data Independence the ability to modify the conceptual schema without changing the application program Usually done when logical structure of database is altered. Logical data independence is harder to achieve as the application programs are usually heavily dependent on the logical structure of the data. An analogy is made to abstract data types in programming languages.
An entity-relationship (ER) diagram is a specialized graphic that illustrates the interrelationships between entities in a database. ER diagrams often use symbols to represent three different types of information, namely, entities, attributes and relationships.
Define Entities: These are usually nouns used in descriptions of the system, in the discussion of business rules, or in documentation; identified in the narrative. Define Relationships: These are usually verbs used in descriptions of the system or in discussion of the business rules (entity ______ entity); identified in the narrative. Add attributes to the relations: These are determined by the queries, and may also suggest new entities, e.g. grade; or they may suggest the need for keys or identifiers.
Entity
An entity is an object or concept about which you want to store information.
Key attribute
A key attribute is the unique, distinguishing characteristic of the entity. For example, an employee's social security number might be the employee's key attribute.
Relationships
Relationships illustrate how two entities share information in the database structure.
Weak Entity
A weak entity is an entity that must defined by a foreign key relationship with another entity as it cannot be uniquely identified by its own attributes alone.
Derived attribute
A derived attribute is based on another attribute. For example, an employee's monthly salary is based on the employee's annual salary.
Multivalued attribute
A multivalued attribute can have more than one value. For example, an employee entity can have multiple skill values.
Cardinality specifies how many instances of an entity relate to one instance of another entity. Ordinality is also closely linked to cardinality. While cardinality specifies the occurrences of a relationship, ordinality describes the relationship as either mandatory or optional. In other words, cardinality specifies the maximum number of relationships and ordinality specifies the absolute minimum number of relationships. When the minimum number is zero, the relationship is usually called optional and when the minimum number is one or more, the relationship is usually called mandatory.
DDL compiler generates a set of tables stored in a data dictionary Data dictionary contains metadata (i.e., data about data)
database schema Data storage and definition language
language in which the storage structure and access methods used by the database system are specified Usually an extension of the data definition language
Language for accessing and manipulating the data organized by the appropriate data model
DML also known as query language
Entity Sets Relationship Sets Design Issues Mapping Constraints Keys E-R Diagram Extended E-R Features Design of an E-R Database Schema Reduction of an E-R Schema to Tables
An entity set is a set of entities of the same type that share the same properties.
Example: set of all persons, companies, trees, holidays
An entity is represented by a set of attributes, that is descriptive properties possessed by all members of an entity set.
Example: customer = (customer-id, customer-name, customer-street, customer-city) loan = (loan-number, amount)
A relationship is an association among several entities Example: Hayes depositor A-102 customer entity relationship set account entity A relationship set is a mathematical relation among n 2 entities, each taken from entity sets {(e1, e2, en) | e1 E 1, e2 E2, , en En}
depositor
An attribute can also be property of a relationship set. For instance, the depositor relationship set between entity sets customer and account may have the attribute access-date
Refers to number of entity sets that participate in a relationship set. Relationship sets that involve two entity sets are binary (or degree two). Generally, most relationship sets in a database system are binary. Relationship sets may involve more than two entity sets.
E.g. Suppose employees of a bank may have jobs (responsibilities) at multiple branches, with different jobs at different branches. Then there is a ternary relationship set between entity sets employee, job and branch
Relationships between more than two entity sets are rare. Most relationships are binary.
Express the number of entities to which another entity can be associated via a relationship set. Most useful in describing binary relationship sets. For a binary relationship set the mapping cardinality must be one of the following types:
One to one One to many Many to one Many to many
One to one
One to many
Note: Some elements in A and B may not be mapped to any elements in the other set
Many to one
Many to many
Note: Some elements in A and B may not be mapped to any elements in the other set
Lines link attributes to entity sets and entity sets to relationship sets.
Ellipses represent attributes Double ellipses represent multivalued attributes. Dashed ellipses denote derived attributes. Underline indicates primary key attributes (will study later)
We express cardinality constraints by drawing either a directed line ( ), signifying one, or an undirected line (), signifying many, between the relationship set and the entity set. E.g.: One-to-one relationship:
borrower
A customer is associated with at most one loan via the relationship borrower A loan is associated with at most one customer via
In the one-to-many relationship a loan is associated with at most one customer via borrower, a customer is associated with several (including 0) loans via borrower
In a many-to-one relationship a loan is associated with several customers via borrower, a customer is associated with at most one loan via borrower
A customer is associated with several (possibly 0) loans via borrower A loan is associated with several customers via borrower
Total participation (indicated by double line): every entity in the entity set participates in at least one relationship in the relationship set
E.g. participation of loan in borrower is total every loan must have a customer associated to it via borrower
Partial participation: some entities may not participate in any relationship in the relationship set
E.g. participation of customer in borrower is partial
A super key of an entity set is a set of one or more attributes whose values uniquely determine each entity. A candidate key of an entity set is a minimal super key
Customer-id is candidate key of customer account-number is candidate key of account
Although several candidate keys may exist, one of the candidate keys is selected to be the primary key.
We allow at most one arrow out of a ternary (or greater degree) relationship to indicate a cardinality constraint E.g. an arrow from works-on to job indicates each employee works on at most one job at any branch.
Use of entity sets vs. relationship sets Binary versus n-ary relationship sets
Choice mainly depends on the structure of the enterprise being modeled, and on the semantics associated with the attribute in question.
Possible guideline is to designate a relationship set to describe an action that occurs between entities
Although it is possible to replace any nonbinary (n-ary, for n > 2) relationship set by a number of distinct binary relationship sets, a n-ary relationship set shows more clearly that several entities participate in a single relationship.
An entity set that does not have a primary key is referred to as a weak entity set. The existence of a weak entity set depends on the existence of a identifying entity set
it must relate to the identifying entity set via a total, one-to-many relationship set from the identifying to the weak entity set Identifying relationship depicted using a double diamond
The discriminator (or partial key) of a weak entity set is the set of attributes that distinguishes among all the entities of a weak entity set.
The primary key of a weak entity set is formed by the primary key of the strong entity set on which the weak entity set is existence dependent, plus the weak entity sets discriminator.
We depict a weak entity set by double rectangles. We underline the discriminator of a weak entity set with a dashed line. Primary key for payment (loan-number, payment-number)
Note: the primary key of the strong entity set is not explicitly stored with the weak entity set, since it is implicit in the identifying relationship.
If loan-number were explicitly stored, payment could be made a strong entity, but then the relationship between payment and loan would be duplicated by an implicit relationship defined by the attribute loannumber common to payment and loan
In a university, a course is a strong entity and a course-offering can be modeled as a weak entity The discriminator of course-offering would be semester (including year) and section-number (if there is more than one section) If we model course-offering as a strong entity we would model course-number as an attribute. Then the relationship with course would be implicit in the course-number attribute