0% found this document useful (0 votes)
32 views32 pages

Cs403 Short Notes

good

Uploaded by

Tanveer Abbas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views32 pages

Cs403 Short Notes

good

Uploaded by

Tanveer Abbas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 32

Short Notes

FOREIGN KEY: enforces Referential integrity


PRIMARYKEY: enforces ENTITY integrity.
Database DB: is collection of data.
DBMS is tool to manage this data, and both jointly are called database system.

DBMS + DB: Database System.


Data:
The facts or figures (raw form).
Q: Write the type of computer applications?
ANS:
1. Commercial ( or business applications)
2. Scientific (or engineering).
Major drawback in the traditional file system environment are the:
1. Non-sharing of data.
2. Redundancy
3. Inconsistency
Advantages of Databases:
1. Data Sharing
2. Data Independence
3. Controlled Redundancy
4. Better Data Integrity
Data and programs are …… of each other?
i): Independent ii): Dependent
Redundancy:
Duplication of data.

Ch02
Data:
collection of raw facts.
Information:
Meaningful form of the Data is called information.
Schema: is a repository or structure to express the format.
Database is a self describing collection of …………..records.”?
i): interrelated ii): intera-related
Two basic operations performed by the DBMS are:
• Management of Data in the Database.
• Management of Users associated with the database.
Concurrency means the access of database form as number of points
simultaneously.
Data inconsistency leads to a number of problems:
Loss of information and incorrect results.
Different types of costs:
1. Financial
2. Personnel
Levels of Data: (03)
1. Real-world data
2. Metadata (also known as schema)
3. Data Occurrence
Q: Level of data at which entities or objects exist in reality is called?
a. Real world data
Q: Which one of the following is NOT a characteristic of meta data?
a. Data about data
b. Describes a data dictionary
c. Self-describing
d. Includes user data
Meta data consist on:
1. type of data
2. size of a certain attribute

Two basic operations performed by the DBMS are:


3. • Management of Data in the Database.
4. • Management of Users associated with the database.

Type of Database Systems user:


Two
o Application Programmers (skilled people who have clear idea)
o End Users
Types of end user?
• Naïve
• Sophisticated (additional rights over the Naïve users)
Database Administrators (DBA):
Who is responsible for authorizing access to the database, for coordinating
and monitoring its use?
►Database Designer
►Database Administrator (Page 26)
►End User
►Application Programmer

Ch03
Database standard proposed by ANSI/SPARK in 1975 is being used
worldwide.
ANSI/SPARC architecture: The conceptual level is a level of indication
between the internal level and the external level. (Page 33)
The three levels architecture is useful for hiding the details of internal
systems.
Three level architecture:
1. External View or User view (Level, Schema or Model)
2. Logical View or Conceptual View (Community view)
3. Internal view or Physical View / Schema
Architecture: repository used for storing definitions of the structures used in
database.
Extension -It is the number of tuples present in a table at any instance. This is
time dependent.
Intension - It is a constant value that gives the name, structure of table and
the constraints laid on it.
Intension is undesirable to change intension.
Q: A change to the data made for the extension of data will effect only a
….record?
i): Single ii): Whole
Q: A change to the internal level (Intention) of the database the change effects
….. the stored records.
i) All/whole ii): Single
Other name of Logical or conceptual view (Level or model):
Community view
Community view:
It stores the complete data of the organization.
Q: Conceptual schema as it describes the ……. of the database?
i): Intention ii): Extension
Data stored onto a magnetic media is stored in binary format.
Mapping: changed format of the
The mechanism through which the records or data at one level is related to
the changed format of the same data at another level is known as
mapping.

Two types of mapping:

o External / Conceptual Mapping


o Conceptual/ Internal Mapping

External/conceptual mapping:
When we associate one form of data at the external level with the same data in
another form is know as the external/conceptual mapping of the data.
Conceptual/Internal mapping:
when data at the conceptual level is correlated with the same data at the
internal level, this is called the conceptual/Internal mapping.
The data store on the physical level is in binary format.
At the internal level we can see that data is prefixed with:
1. Block Header BH
2. Record header RH
The Record header is prefixed to every record.
The block header is prefixed to a group of records.
The block size is generally larger than the record size.
Data independence types:
o Logical Data Independence
o Physical Data Independence
Logical Data Independence Physical Data Independence
 Changes in conceptual/
Logical model do not Changes in the internal
affect the external views model/physical do not affect the
conceptual model

 Immunity of external level Immunity of Conceptual level


from changes at conceptual from changes at Internal level.
level

 Changes transparency between


the conceptual and internal levels.

Catalog which stores almost all of the information of the database.


Functions of DBMS: Their Works
 A User Accessible Catalog User all information
 Transaction Support Data manipulation
 Concurrency Control Services support a number of transactions to
be executed simultaneously
 Recovery Services Recover the data inconsistent state to
consistent state.
 Integrity Services maintain something in its truth
DBMS Environments:
1. Single User or (Desktop Database systems)
2. Multi-user
a. Tele-processing
b. File Servers
c. Client-Server
Teleprocessing:
All processing at a central computer.
Dumb terminals.
Client-Server:
Q: Which type of multi-user environment is the best implementation of the
network and DBMS environments?
Or
Q: Which environment is best suited for large enterprises where bulk of data
is processed and requests are very much frequent.
 Teleprocessing
 File Servers
 Client-Server

Ch: 05
Database Application development Process includes the Following
Stages or steps:
Database Design Application/program Implementation
Q: Database Application development Process occur in …..?
i): Parallel ii): Series
Physical Design:
transform our logical design into a Physical design.

DFD-Symbols:
Data Flow Diagram: It is used to design systems graphically.
Links between processes describe the information flow.
DATAFLOW:

 The purpose of the dataflow in a DFD is to express the flow of


information from one entity to another entity in the system
 Data flows are pipelines through which packets of information flow.
 Arrows are labeled with name of the data that moves through them.

DATA STORE:
Data store is a repository for the storage of the data.
It is express with a rectangle open on right width and left width of the
rectangle drawn with double lines.
Name of the DATASTORE is a noun.

Processes:
Processes are expressed with ovals or rounded rectangles.
Processes are used to express the transformation of incoming dataflow into
outgoing dataflow.

DFD-Process:
External Entities:
These are the entities interacting with the system in any of two different ways:
1. They may be either receiving the data from the system,
2. They may be producing the data for the system to consume.
Shape used to express external entities is rectangle.

Collector:
Multiple to Single
Collector is used to show the convergence of data to a single point.
Separator:
Single to Multiple
The dataflow symbol which is used for separating data from a single source to
multiple sinks is known as a separator.

Ring Sum Operator:


This operator is used when data from a source process can flow to one of the
mentioned sinks.

AND Operator:
This operator is used when data from a source process must flow to all the
connected sinks.

Types of DFD:
o Context diagram (least amount of details)
o Level 0 diagram
o Detailed diagram
CDFD: Context Data Flow Diagram
DDFD: Detailed Data Flow Diagram
Context Diagram:
 least amount of details about the working of the system.
 They always consist of single process and describe the single system.
 Name of the CDFDs is generally a Noun Phrase.
 no data stores are created.
Level 0 Data Flow Diagrams:
is used to describe the working of the whole system.

1. Ring Sum Operator


data from a source process
can flow to one of the
mentioned sinks.
2. AND Operator
data from a source process
must flow to all the connected
sinks.
Ch: 06
Detailed dataflow diagram: we create sub-processes.
Level one:
1.1, 1.2, …, 1.n
Level two:
1.1.1, 1.1.2,…1.1.n
Maximum process in one Detailed DFD:
Maximum of 7 or 9 processes in one detailed DFD.
Data Dictionary:
A repository of information that describes logical structure of database, or it
contains the metadata.
Types of Data Dictionaries:
Two types of data dictionaries:
1. Integrated. (Created by DBMS) (more efficient)
2. Free Standing. (Created by CASE tool)
CRM: Cross Reference Matrix
1. X axis. The Rows in this matrix contain different attributes.
2. Y axis. The columns contain different transitions, reports and objects.
Database Design represents logical structure of the database.
Database Modeling/Design:
The process of creating the logical structure of the database is called database modeling.
Generally the design of the database is represented graphically.

Integrity Constraints: ensure the correctness of data.

Ch: 07

Types of Data Models:


 Semantic: (Entity-Relationship, Object-Oriented)
 Record based: (Hierarchical, Network, Relational)
 Conceptual: using SDM (semantic data model) E.R Entity-Relationship Data
Model

 Logical: using DM of tool


 Physical: using the DBMS
1. Entity: Represent by rectangle. (real word object)
2. Attribute: Represent by oval.
3. Relationship: Represent by diagonal rectangle.
Entity: Entity is a concept to abstractly represent all instances of a group of
similar “things”.
Entity Instance: a single occurrence of an entity.
Entity Type: It is collection of entity having common/same attribute.
Entity set: A group of entity instances.
EI:ET:ES
Example:
 Entity Instance: M. Sharif
 Entity Type: Employee
 Entity Set: All employees

Entity types (ETs) can be classified into:


1. Strong ETs / Regular or independent ETs
2. Weak ETs / Irregular or dependent ETs
Strong entity types: rectangle with a single line is used
Weak entity type: double lined rectangle
Naming Entity Types:
• Singular noun recommended, but still plurals can also be used
• Organization specific names, like customer, client, gahak anything will work
• Write in capitals, yes, this is something that is generally followed, otherwise
will also work.
• Abbreviations can be used, be consistent.
Entity instances of same entity type have the same attributes.
One entity type cannot have two attributes with the same name.
Q: Attribute (Oval representation) name generally consists of…...?
i): Two parts ii): three parts
Q: Way of writing attributes?
i): Empname ii): empname ii): empName
emp Name
entity types purpose of attribute
Domain is the set of possible values that an attribute can have.
Data type is defined as a set of values along with the operations.
Values may be different or same.
But the domain will be the same.

Ch: 08
A key is an attributes or set of attribute which is used to uniquely identifies a
tuple or Row.
Super key is general key.
Simple Key: consisting of single attribute.
Composite key or (Concatenated Key): it could be composite which consists
of two or more attributes.
Following are the major types of keys:
o Super Key o Candidate Key (Minimal super key)
o Primary Key o Alternate Key
o Secondary Key o Foreign Key
A super key is key that identify a record uniquely.

Primary key:
1. Not be a null
2. Uniquely identify
Candidate key, Primary key, Alternate key these all are super key.
3. Candidate key/ Minimal super key:
A super key for which no subset is a super key is called a candidate key
or the minimal super key is the candidate key.
4. (A candidate key is a super key which have no extra attributes)
It means that there are two conditions for the candidate key:
1. It identifies the entity instances uniquely, as is required in case of super
key,
2. It should be minimum, that is, no proper subset of candidate key is a
key.
Every candidate key is a super key.
Every primary key (PK) is a candidate key and every candidate key is a super
key.
Note:
Every candidate key is a super key but not the other way round.
The relation that holds between super and candidate keys also holds between
candidate and primary keys, that is,
Note:
Every primary key (PK) is a candidate key and every candidate key is a super
key.
NULL: that means “not given” or “not defined”.
There is not the compulsion or it is not necessary for secondary key to return
unique instance,
In case of super, candidate, primary and alternate keys it is compulsion that
they will always return unique instance.
Q: Which key is not necessary or not compulsion to return unique instance?
► Secondary key
► super key
► candidate key
► primary key
►alternate key

Ch: 09
Participants:
Entities enrolled in a relationship are called its participants.

Diamond sign is use for relationship.


Q: Relation can be…….?
1. Total
2. partial.
Total: when all entities of that set might be participant in the relationship
otherwise it is partial.
Roles:
The labels “manager” and “worker” are called “roles”.
Lines between diamonds and rectangles are called labels.
Diamond is doubled: i): Dependent
Diamond is singled: i): Independent
• Total participation is indicated by double lines.
There are three types of relationships.
1. Unary relationships (recursive relationship)
2. Binary relationships (degree two)
3. Ternary relationships (degree three)
Unary Relationship:
An ENTITY TYPE linked with itself, also called recursive relationship.

Mapping
One-to-One mapping:
A mapping R from X to Y is one-to-one
if each entity in X is associated with at most one entity in Y and vice versa.
Many-to-One mapping:
A mapping R from X to Y is many-to-one
if each entity in X is associated with at most one entity in Y but each entity in
Y is associated with many entities in X.

One-to-Many mapping:
A mapping R from X to Y is one-to-many
if each entity in X is associated with many entities in Y but each entity in Y is
associated with one entity in X.
Many-to-Many mapping:
A mapping R from X to Y is many-to-many if each entity from X is associated
with many entities in Y and one entity in Y is associated with many entities in
X.

Ch: 10
Relationship Cardinalities:
is the number of entities to which another entity can map under that
relationship.
Maximum cardinality: tells us that how many instance of an entity can be
placed in the second relation at most.
Minimum cardinality: show us that how many instance of one entity can be
placed in another relation at least.
Minimum cardinality Sign or notation:
Maximum cardinality Sign or notation:

Optional

Mandatory
Above all notations are called crow’s foot notation.
One cardinality we have used 1.
Many cardinality M or N is used.
Single arrow: show the one cardinality
Double arrow: show the many cardinality.
The black filled Dot is used for showing many cardinality.
Roles: The way an entity is involved in a relationship.
Two types of relationships:
1. Recursive Relationship: (Such a link initiates from one entity and
terminates on the same entity.
e.g. A one to one relationship
2. Multiple Relationships:
Two ETs having more than one relationship
Type of Dependencies:

1. The Existence dependency (exists when one entity instance needs


instance of another entity for its existence.)
2. Referential Dependency: (: composite keys)
3. Identifier Dependency: (foreign keys)
Ch: 11

Super type Sub type


Generalization Specialization
bottom-up approach (top-down approach)
higher level entity  Lower level higher level entity two lower level
entity higher level entity entities
There are two types of completeness constraints.
1. Partial completeness constraints
2. Total completeness constraints

Total Completeness constraint Partial completeness

This Completeness constraint exist This completeness constraint exist


only if we have a super type and to specifies that all the instances of
some subtypes associated with that the entity super type may not be
supertype. the member of the entity subtype.
All the instances of the entity
super type should be the member
of the at least one entity subtype.

Constraint:
Rule or constraint defines the existence of a super type entity in a subtype
entity.
Disjointness constraint
 Disjoint rule
 Overlap rule
Disjointne rule: Super type Sub type
 Existence: exactly one instance
Overlap rule: Super type Sub type
 Existence: multiple instances
Disjoint situation where one supertype entity instance can be placed only in
one subtype of that supertype.
Overlapping constraint; it is the situation where one supertype attribute can
be placed in more than one subtype entities.
To store several entities and neglect others, and it is called as partial
completeness constraint rule.

Subtype Discriminator:
methodology to determine that to which subtype one
instance of a supertype belongs.
Ch: 12
CRM: Cross Reference Matrix: doth:
 Reports vs Items
 Columns Vs Rows
 The major item names on a matrix in the row wise order
 The reports which will be generated will be written on top or in
column wise order.
Ch: 13
The cardinality between:
Student and program is one
Course offered and teacher is one
programs and students can be zero to many (0 - *)
teacher and course offered is one to many
Cardinality
Program and courses one to many (1 -*)
Courses and program zero to many (0 - *).
Student and program zero to many (0 - *)
semester and course many to many ( * *)
course offered and teacher one to many ((1 -*))
One to many (1 -*)
Zero to many (0 - *)
Many to many ( * -*)
CDD: Conceptual Database Design
LDD: Logical Database Design
The outcome of analysis phase is the……..?
i): CDD ii): LDD
Conceptual Database Design Logical Database Design.
Conceptual Database Design Logical Database Design
This design is independent of any tool dependent.
tool or data model.

network, relational or hierarchal Relational data model


models.

Developed in a semantic data model Free of particular DBMS


(generally E-R data model)

Results from Analysis Phase translating the conceptual database


design into another data model

Graphically Descriptive
More expressive less expressive

Going to be transformed and then Going to be implemented


implemented

Ch: 14
Data model “a set of constructs/tools used to develop a database design.
The components of data model / Relational model (RDM):
Three components
1. Constructs /Structure
2. Manipulation language
3. Integrity constraints
RDM: Relational Data model
An IBM scientist E.F. Codd proposed the relational data model in 1970.
The RDM is based on a single structure and that is a relation.
The relation in RDM is similar to the mathematical relation.
The RDM is mainly used for designing/defining external and conceptual
schemas.
Table:
Database relation is also represented in a two dimensional structure called
table.
A table consists of rows and columns.

{
A row or tuple of a table represents a record or an entity instance,
Columns of the table represent the properties or attributes.

}
Q: There are ….. basic properties of the database relations?
i): Six
Each cell of a table contains atomic/single value.
A cell is the intersection of a row and a column.
The order of the columns is immaterial. / does not matter
An attribute can contain only a single value.
• Each column has a distinct name; the name of the attribute it represents
• The values of the attributes come from the same domain
• The order of the columns is immaterial (Order does not matter)
• The order of the rows is immaterial (Order does not matter)
• Each row/tuple/record is distinct, no two rows can be same.
As with the columns, if rows’ order is changed the table remains the same.
Two rows of a table cannot be same.
In the database context each ordered pair represents a tuple.
Elements in the ordered pairs represent values of the attributes.
Rows/tuples represent records
Columns represent the attributes.

Ch: 15
Order of columns:
Mathematical relations order does matter.
Database relations order does not matter.
Relationship is a link or association between one or more entity types.
Degree of a relation:
The number of columns in that relation.
Cardinality of a Relation:
The number of rows present in that relation.
Q: …..will be used quite frequently in the RDM?
i): Foreign key ii): Primary Key
There can be more than:
zero, one or multiple foreign keys in a table.
Primary Key:
Foreign Key: …………

Integrity Constraints:
Two main types
 Entity integrity constraint (row Integrity) (PK)
 Primary key cannot have null value
 Referential integrity constraint (FK)
 Value of Foreign key is either null or matches with a value in its home
relation
conceptual database into logical database
of
E-R data model into relational data model.
Null Constraints: value is not yet given, not defined yet.
By default a non-key attribute can have Null value.
Default Value:
We do not give any value to any particular attribute.
Default Value: used for efficiency purposes.
Transforming Rules: (2)
Converting conceptual database into logical database design:
1. Manually
2. automatically with CASE tools
Composite Attributes:
a combination of two or more than two attributes.
Multi-valued Attributes:
more than one value against an attribute.

Ch: 16
Relation is a structure, which is obtained by converting an entity type in E-R
model into a relation.
Relationship is in between two relations of relational data model.
Relationships in relational data model are mapped according to their degree
(Columns) and cardinalities (Rows).
Following are the three types of cardinalities for binary relationships:
o One to One
o One to Many (P K TO F K)
o Many to Many

Minimum Cardinality (Row):


Minimum Cardinality (Row) is zero: then the FK is defined as normal
and it can have the Null value.
Minimum Cardinality (Row) is one: FK attribute(s) as Not Null.
 If optional (0) define FK as normal (Can be NULL value)
 If compulsory (1) make FK not null
In many to many relationship: a third table is created for the relationship,
which is also called as associative entity type.
Mapping Relationship

o One to One one instance of first entity type is


mapped with one instance of
second entity type and also the
other way round.
o One to Many 1. one instance of a relation or
entity type is mapped with
many instances of second
entity type.
2. one instance of second entity
type is mapped with one
instance of first entity type.
P K TO F K.

o Many to Many 3. one instance of first entity


can be mapped with many
instances of second entity.
4. one instance of second entity
can be mapped with many
instances of first entity type.

 Q: Associative entity type (Table is created in which …..?


i): Many to many ii): one to many

Unary Relationship or recursive relationships:


These are the relationships, which involve a single entity. These are also called
recursive relationships.
Procedural Languages: in which what to do and how to do on the database is
required..
Non -Procedural Languages:
in which only what to do is required.
Relational Algebra: procedural
Relational Calculus: non – procedural
Relational algebra operations work on one or more relations.
Closure: Allows expressions to be nested, just as in arithmetic. This property
is called closure.
Ch: 17
DML: Data Manipulation Languages.
There are five basic operations in relational algebra:
1. Selection, (Rows or Tuples) denoted by Greek letter sigma (σ)
single table horizontally
2. Projection: single table vertically (Greek letter (∏))
3. Cartesian product: (denoted by X.)
It is also called as cross product.
4. Union: (other name set operations) denoted by U.
5. Set Difference.
They are broadly divided into two categories:
1. Unary Operations
2. Binary operations
Unary Operations:
These are those operations, which involve only one relation or table.
1. Select
2. Project
Binary Operations:
These are those operations, which involve pairs of relations and are, therefore
called as binary operations.
The input for these operations is two relations
Binary Operators:
3. Union
4. Set Difference
5. Cartesian Product
The Select operation works horizontally on the table.
The Project operator operates on a single table vertically.
Composition of Relational Operators:
The relational operators like select and project can also be used in nested
forms iteratively.
Condition for the Union Operation:
1. Both the relations should be of (same degree)
2. The domains of corresponding attributes is same. (Same domains)
The union operator is commutative which means: -
RUS=SUR
In select operation: Degree of the new and old tables are same. Is also
commutative.
Lower Greek letter sigma (σ) is used to denote the selection.
In selection operation the comparison operators like , =, <=, >=, <> can be
used in the predicate.
The Intersection Operation:
1. Same degree
2. Same domains
It is represented by∩.
Just like union intersection is also commutative.
R∩S=S∩R
Cartesian product or cross product:
The Cartesian product needs not to be union compatible mean (different degree).
It is denoted by X.
RXS
The Cartesian product is also commutative and associative.

Ch: 18
Join Operation: 42
Join is a special form of cross product of two tables.

Join operation: Certain selections + Cartesian product.

Following are the different types of joins: -


1. Theta Join 2. Equi Join 3. Semi Join
4. Natural Join 5. Outer Joins
Theta join: (R X Ө S)
only those selected rows
In theta join we apply the condition on input relation(s) and then only those selected rows
are used in the cross product to be merged and included in the output.

Q: What is difference between normal cross product and Theta join?


ANS:
In normal cross product: all the rows of one relation are mapped/merged with
all the rows of second relation.
But in Theta join: here only selected rows of a relation are made cross
product with second relation.
Equi–Join:
In equi–join rows are joined on the basis of values of a common attribute
between the two relations.
joined on the basis of common attributes between them
This means on the basis of primary key, which is a foreign key in another
relation.
Rows having the same value in the common attributes are joined.
Common attributes appear twice in the output.
In natural join, the common attribute appears only once.
In equi-join, the common attribute appears twice.
Outer Join:
all the tuples of left and right relations are part of the output.
It means that all those tuples of left relation which are not matched with right
relation are left as Null.
All those tuples of right relation which are not matched with left relation are
left as Null.
Left Outer Join: Right Outer Join
In left outer join all the tuples of left In right outer join all the tuples of
relation remain part of the output. right relation remain part of the
right tuple have Null values. output.
left as Null

Semi Join:
In semi join, first we take the natural join of two relations then we project the
attributes of first table only.

Predicate calculus:
Relational calculus takes name from a branch of symbolic logic called the
predicate calculus.
It has two following forms: -
1. Tuple Oriented Relational Calculus
2. Domain Oriented Relational Calculus
Tuple Variable:
A tuple variable is a variable that takes on only the tuples of some relation or
relations as its range of values.
It is expressed as
{S | P (S)}
Anomaly means inconsistency in the pattern from the normal form.
Q: How many types of Anomalies?
ANS:
There are four types of anomalies, which are of
i): Redundancy, ii): Insertion, iii): Deletion iv): Updation.

You might also like