Advantages of using a Data Base
description
Transcript of Advantages of using a Data Base
Advantages of using a Data Base
Controlling Redundancy Restricting Unauthorized users Providing Persistent storage for program objects Providing storage structure Providing Backup and Recovery Multiple User Interfaces Complex Relationships Enforcing Integrity constraints
Categories of Data Models
High- level or Conceptual Representational Low-level or Physical
Data Model
Underlying the structure of data base Collection of conceptual tools Defines data, relationships, constraints etc
Object Based Logical Model
Entity –Relationship model Object – oriented model Semantic model Functional data model
Hierarchical ModelNetwork Model
Schema: The description of the data base Schema diagram: The diagrammatic
representation of the schema Schema Construct: Schema Construct: Each object in the schema Snapshot: Snapshot: The data in a database at a particular
moment of time current set of occurrences current set of instances
Meta-data Meta-data : Storing of description of schema constructs and constraints is called metadata
Three Schema Architecture
Internal Schema describes:the physical storage of the databaseuses physical data model,describes the complete details of data storage
Conceptual Schema:Describes the structure of the databaseHides the physical storage structuresDescribes data types, relationships, constraints etc Also known as high level data model
External Schema describes: part of the database that a particular user group is interested in and hides the rest of the database from that user group.
Data Independence
Logical Data Independence
Physical Data Independence
Capacity to change the conceptual schema without having to change external schemas or application programs
Changing conceptual schema means: changing constraints, expanding or reducing database etc.
Only view definitions the mappings need to be changed
Capacity to change the internal schema without having to change conceptual schemas
Changing internal schema means: reorganizing physical files, creating access rights etc
Data Languages
DDL( Data Definition Language)
Underlying the structure of data base Collection of conceptual tools Defines data, relationships, constraints etc
DSL( Data Storage Language)
VDL( View Definition Language)
DML( Data Manipulation Language)
Specify internal schema
High level or non-procedural DML Low-level or procedural DML
DBMS Interfaces
Menu Based Interfaces for web-browsing Forms-based Interfaces Graphical User Interfaces Natural Language Interfaces Interfaces for parametric Users Interfaces for the DBA
Data base system environment: DBMS Component modules
Data base system Utilities
Loading back-up File – organization Performance monitoring
Centralized Architecture for DBMS
Two-Tier Client/server architecture
ClientClient ClientClientClientClient
Print Server
Print Server
Print Server
Logical two-tier C/S architecture Physical two-tier C/S architecture
Three-Tier Client/server architecture
Logical three-tier C/S architecture
Client
Application ServerOr
Web Server
Data Base Server
Entities, attributes etc
Entity: An object with physical existence Attribute: A particular property that describes an entity Simple or Atomic attributes: Attributes that are not divisible Composite attributes: Can be divided into smaller sub
parts Composite attributes can form a hierarchy Single valued attribute: An attribute which has a single
value for a particular entity Multi-valued attribute: An attribute which has a more than
one value for a particular entity Stored and derived attribute: age attribute is derived from
birth-date attribute Complex attributes: a structure of many attributes.
Entity types, sets, keys, domains
Entity Types: An entity type defines a collection of entities that have the same attributes
Entity set: Collection of all entities of a particular entity type in the database at any point of time is called an entity set
e106100, Josna, III B.Sc
e207101, Minu , IIBSC
e306320,Vianni,IIIBCA
………
E1 Josna, III B.Sc,College hostel
E2Sharal , IIBSC, Outside hostel
E3Nishath, IIIBCA, with Parents
………
Student - entity type Accommodation - entity type
key attribute: An attribute whose values are distinct for each individual entity in the entity set
Weak entity type: An entity type which has no key attribute Value sets or Domains: the set of values that may be
assigned to an attribute for each individual entity The value of an attribute A for an entity e is referred to as
A(e) Relationship: An attribute of one entity type referencing to
an attribute of another entity type; Eg: Name of “Accommodation” entity type referencing
name of student entity type
A relationship type R among n entity types E1,E2,….En defines a set of associations
Mathematically, the relationship set R is a set of relationship instances ri where each ri associates n individual entities(e1,e2,e3….en)
e1e2e3e4e5e6
e1e2e3e4e5e6
r1r2r3r4r5r6
r1r2r3r4r5r6
d1
d2
d3
d4
d1
d2
d3
d4
Employee Works for Department
Degree of relationship: no.of participating entity types. Given an example of relationship with degree 3.(Supplier, Part and project)
Role Names: Signifies the role that a participating entity plays in each relationship
s1s2..
s1s2..
r1r2r3r4r5r6
r1r2r3r4r5r6
j1
j2
j3
j4
j1
j2
j3
j4
SupplierSupply Project
p1p2p3.
p1p2p3.
Part
Recursive relationships: The same entity type participates more than once in a relationship in different roles. Such relationship types are called as recursive relationships
e1e2e3e4e5e6
e1e2e3e4e5e6
r1r2r3r4r5r6
r1r2r3r4r5r6
Employee Supervision
Cardinality Ratio: Maximum number of relationship instances that an entity can participate in.
1:1 or 1:n or n:1 or m:n
Participation constraint: Specifies whether the existence of an entity depends on its being related to another entity via the relationship type.
E-R Diagrams
RRE1E1 E2E2
E1E1 RR E2E2
Entity
Weak Entity
Relationship
Identifying relationship
attribute
Key attribute
Multivalued attribute
Composite attribute
Derived attribute
Relational data model concepts
The relational model represents the database as a collection of collection of relationsrelations
Informally a relation is called as “tabletable” A row is called as a ‘tupletuple’ A column header is called as an ‘attributeattribute’ A ‘Domain‘Domain ‘ D is a set of atomic values for an attribute A ‘relation shemarelation shema’ R is denoted by R(A1,A2,A3….,An) is made up
of relation name R and list of attributes (A1,A2,A3….,An) The degreedegree of a relation is the number of attributes n of its
relation shema n-tuple is an ordered list of n-values t =< v1,v2,v3,….vn) where
each value vi, is an element of domain(Ai) or is a NULL value. A relation state/relation instance relation state/relation instance r of the relation schema
R(A1,A2,A3….,An) is denoted by r(R) and is a set of n-tuples r = {t1,t2,t3,…..tm)
Student Relation
STUDENT Name Rollno Address Homephone Age GPA
Asha 1001 Mangalore 12345678 18 8.7
Usha 1002 Kannur 87654321 19 6.7
Nisha 1003 Mubai 87675645 20 8.8
Risha 1004 Delhi 89674534 20 8.9
Disha 1005 Baroda 23445677 18 4.5
Relation Name
AttributesT
uple
s
Mathematical definition for “relation”
A relation r( R) is a mathematical relation of degree n on the domains dom(A1), dom(A2),…..dom(An), which is a subset ofThe Cartesian product of domains that define R
))(......)()(()( 21 nAdomAdomAdomRr
The Cartesian product specifies all possible combinations of values from the underlying domains.Cardinality is the total number of values in a domain and it is denoted by |D|.The total number of tuples in the Cartesian product is: |dom(A1)| X |dom(A2)| X ………….. X |dom(An)|
Characteristics of relations
Ordering of tuples in a relation( Not predefined but can be done logically)
Ordering of values within a tuple Values and NULLs in a tuple Interpretation of a Relation
Constraints
Restrictions imposed on the actual values in a database state
There are three main categories:
Inherent model-based constraints: Constraints that are inherent in the data model
Schema based constraints: Constraints that can be directly expressed in the schemas of the data model that is specifying constraints in DDL
Application based constraints: Constraints that are expressed and enforced by the application programs
Domain Constraints
Key Constraints
Domain constraints specify that within each tuple, the value of each attribute A must be an atomic value from a domain dom(A). The data type for an attribute is domain constrain
A relation is defined as a set of tuples All elements of a set are distinct So all tuples in relation must also be distinct It means no two tuples in any relation instance r should have the
same combination of for all their attributes For any two distinct tuples t1 and t2 we have the constraint that:
t1 [Sk] ≠t2[SK] where SK is called as SUPER KEY of the relation schema R.
Super key can have redundant values but a key or primary key value cannot repeat in any tuple.
Key
A key satisfies two constraints:1.Two distinct tuples in any state of the relation cannot have identical values for the attributes in the key2. It is minimal superkey- that is a super key from which we cannot remove any attributes and still have the uniqueness constraint hold.
Candidate Key
In general a relation schema may have more than one key. In such cases each of the keys is called as candidate key.One of the candidate keys denoted as primary keyPrimary key is the candidate key whose values are used to identify tuples in a relation
Entity Integrity and Referential Integrity Constraints
The entity integrity constrain states that no primary key value can be null
The referential integrity constraint is specified between two relations and is used to maintain the consistency among tuples in two relations
Foreign Key
A set of attributes FK in relation schema R1 is a foreign key of R1 that references relation R2 if it satisfies the following two rules:1.The attributes in FK are said to reference or refer to the relation R2
2.A value of FK in a tuple t1 of the current state r1(R1) either occurs as a value of PK for some tuple t2 in the current state r2(R2) or is null.
Here we have t1[FK]=t2[PK] and we say that tuple t1 references to the tuple t2
Also R1 is referencing relation and R2 is referenced relation
Primary Key
Foreign Key