0% found this document useful (0 votes)
10 views21 pages

Viva Mix Questions

The document contains a series of questions and answers related to C++ programming, covering topics such as preprocessor directives, header files, object-oriented programming concepts, data types, functions, and memory management. It also discusses the differences between various programming paradigms, the structure of C++ programs, and concepts like constructors, destructors, operator overloading, and inheritance. Additionally, it touches on basic computer science concepts, including data, information, file types, and system software.

Uploaded by

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

Viva Mix Questions

The document contains a series of questions and answers related to C++ programming, covering topics such as preprocessor directives, header files, object-oriented programming concepts, data types, functions, and memory management. It also discusses the differences between various programming paradigms, the structure of C++ programs, and concepts like constructors, destructors, operator overloading, and inheritance. Additionally, it touches on basic computer science concepts, including data, information, file types, and system software.

Uploaded by

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

Viva Questions

Q1. What is # ?

Ans. # is a preprocessor directive.

Q2. What are header files?

Ans. Header files contain the definition of built-in functions.

Q3. What are the examples of header files?

Ans. iostream (input/output stream) and conio (console input/output).

Q4. What is the extension of header files?

Ans. .h

Q5. conio header file contains the definition of which functions?

Ans. getch() – it is used to get a char, until you press the character the output screen is shown
and clrscr() – it is used to clear the entire previous outputs/clear screen.

Q6. iostream header file contains the definition of which functions?

Ans. cout() – it is used to display the contents and cin()- it is used to read the content or to
take input.

Q7. What is the extension of C++ program?

Ans. .cpp

Q8. What is C++?

Ans. It is an object oriented programming language.

Q9. Who developed C++?

Ans. Barjarne Stroustrups in 1980’s at AT’ & T’s Bell Laboratories.

Q10. Previously, how C++ was known?

Ans. C with classes, the idea of C++ comes from the increment operator of C language.
Q11. What is OOPs?

Ans. The object oriented programming has main emphasis on object rather than procedure. It
follows bottom- up approach.

Q12. What do you understand about bottom – up approach?

Ans. The main function is in bottom i.e. after class declaration, therefore, the execution of the
program must be from bottom.

Q13. What is POP?

Ans. The procedure oriented programming has emphasis on procedure. It follows top-down
approach.

Q14. What is top-down approach?

Ans. The main function is declared on the top of the program, therefore, the execution of the
program must be from top.

Q15. What is the difference between OOPs and POP?

Ans. Refer Q13. & Q14.

Q16. Which symbol is used to terminate the line of the program?

Ans. Semi-colon (;)

Q17. Which operator is used for new line?

Ans. endl operator.

Q18. What are the concepts of OOPs?

Ans. Class, object, polymorphism, inheritance, data encapsulation and data abstraction,
message passing.

Q19. Explain all the concepts.

Ans. Class – A class contains the group of similar type of objects.

Object – A real world entity


Polymorphism – poly means ‘many’, morphism means ‘function/forms’ therefore,
polymorphism means more than one forms.

Inheritance – it means the new class may acquire the properties of the existing class, it
provides the idea of ‘reusability’.

Encapsulation – the wrapping up of a data and function into a single unit called class.

Abstraction – the act of representing essential features without including background


details.

Message passing – the message is sent between different function calls.

Q20. What are the basic datatypes in C++?

Ans. Char – 1 byte, int -2 bytes, float- 4 bytes, double – 8 bytes.

Q21. What is the decision making statements?

Ans. if, if-else, switch.

Q22. Which are the different types of loops are there?

Ans. for, do, do-while.

Q23. What are the access – specifiers or visibility modes ?

Ans. There are three types of access – specifiers.

private- data and functions must be accessible to its base class.

protected – data and functions must be accessible to base class and child class

public – data and functions must be accessible to all the classes.

Q24. What are keywords ?

Ans. Keywords are reserved words.

Q25. What is the difference between constant and variables ?

Ans. Constant values remain static while variable values keeps on changing throughout the
program.

Q26. Why is main() special ?


Ans. In C++ program the execution of a program starts and ends at main().

Q27. What is the difference between call by value and call by reference ?

Ans. In call by value, the called function creates its own copies of the original values sent to
it.

In call by reference, the called function accesses and works with the original values using
their references(addresses).

Q28. What are actual parameters ?

Ans. The variables and values passed to a function.

Q29. What are formal parameters?

Ans. The variables that receive the incoming values in a function.

Q30. What is Array ?

Ans. It is a continuous memory location referred by a common name .

Q31.What is scope ?

Ans. The program area inside which a variable or a function can be used.

Q32. What is the name of :: symbol used in program ?

Ans. Scope resolution operator.

Q33. What is constructor ?

Ans. A member function having the same name as its class. It initializes class objects with
legal initial values.

Q34. What is copy constructor?

Ans. A constructor that initializes an object with the data values of another object.

Q35. Which constructor is called default constructor ?

Ans. A constructor that takes no arguments.


Q36. What is destructor ?

Ans. A member function having the same name as its class but preceded by tilde sign (~). It
reinitializes an object before it goes out of scope or simply , to destroy the object created by
constructor.

Q37. What is function overloading?

Ans. Giving several definitions to a single function name that are differentiable by the
number or types of their arguments.

Q38. What is operator overloading ?

Ans. To give the special meaning to an operator.

Q39. What is base class?

Ans. A class from which another class inherits (also called super class).

Q40. What is derived class?

Ans. A class inheriting properties from another class (also called sub class).

Q41. What is SQL ?

Ans. Structured Query Language- A language that creates and operates on relational
database.

Q42. What is the difference between DDL and DML ?

Ans. Data Definition Language provides commands for defining relation schemes, deleting
relations.

Data manipulation Language includes a query language to insert , update, delete and
modify tuples in the database.

Q43. What is an operating system ?

Ans. An interface between computer and user. Eg. Windows, linux, unix, vista etc.

Q44. What is computer ?

Ans. An electronic device capable of performing variety of operations in accordance with


programs.
Q45. What is program ?

Ans. A set of instruction given to computer.

Q46. What is hardware ?

Ans. Physical and tangible components of the computer.

Q47. What is software ?

Ans. Set of programs that govern the operation of a computer system.

Q48. What is an input devices?

Ans. An input devices is any hardware component used to enter data, programs, commands,
and user responses into a computer. e.g. Keyboard, mouse, lightpen , touch screen , joystick ,
microphone etc.

Q49. What is an output devices?

Ans. An output devices produce output of the machine in human readable form. Eg. Printer,
moniter, speakers, plotter etc.

Q50. What are the units of memory ?

Ans. 8 bits = 1byte.

1024 bytes = 1 kilobyte (KB)

1024 kilobytes = 1 megabyte (MB)

1024 megabytes = 1 gigabyte (GB)

1024 gigabytes = 1 terabyte (TB)

1024 terabytes = 1 petabyte (PB)


Q51: What is BIOS.
Ans. BIOS - Basic Input Output System. It initiates the system for operation.
1. Data: A representation of facts, concepts, or instructions in a formalized manner
suitable for communication, interpretation, or processing by humans or by automated
means.

2. Information: Information is the result of processing, manipulating and organizing


data in a way that adds to the knowledge of the person receiving it.

3. Generation of Computer: The computer has experienced five generations, with the
fifth generation still very much in development.
-First Generation
-Second Generation
-Third Generation
-Fourth Generation
-Fifth Generation
4. I/O Devices
Input device
Keyboard Mouse
MICR OCR
OMR Light Pen
Output Unit
VDU (Monitor) Printer
Plotter
5. Storage Devices
 Hard Disk
 Magnetic Tape
 Floppy Disk
 Optical Disk
 Punched Card

6. System Software
 Compiler
 Interpreter
 Operating System

7. Application Software
 Databases
 Word processors
 Spreadsheet

Unit – II
1. Basic elements of assembly language are:

 Labels
 Instructions
 Operands
 Directives
 Comments .

2. Assembly Scheme

Synthesis Phase
Analysis Phase

3. Pass structure of assembler

Single Pass Assembler


Two Pass Assembler

4. Macros: A macro is a group of repetitive instructions in a program which are codified


only once and can be used as many times as necessary.
Syntax of a Macro

The parts which make a macro are:

Declaration of the macro

Code of the macro

Macro termination directive

5. Nested Macro Call: A model Statement in a macro may constitute a call on another
macro. Such calls are known as nested macro call.
Advanced Macro facilities

 Alteration of flow of control


 Expansion time variables
 Attributes of parameters

1. File : A file is organized logically as a sequence of records.


2. Records : A record is a sequence of fields
 Fixed-length
 Variable-length
 Spanned
 Unspanned
3. Types of File :
 Serial File
 Sequential File
 Index Sequential File
 Direct File
 Secondary Key Retrieval File
-Multi list file organization
-Inverted file Organization

4. Ordered Indexes: An ordered file that stores the index field and a pointer. Requires a
binary
search on the index file
Types of Ordered Indexes
 Primary
 Clustering
 Secondary

5. Secondary Indexes: A secondary index is an ordered file that stores the no ordering
field of a data file and a pointer. If the indexing field is a secondary or candidate key,
then the index is dense. If the indexing field is a nonkey field, then the index is
sparse. Introduces the idea of adding a level of indirection
1. C++ basics, loops and decisions

C++ is the object oriented programming language extension of C. As for C there is an


ANSI/ISO standard for the C++ programming language. This will ensure that the C++
code is portable between computers. For most part C++ programs look like C programs..
Although C++ defines its own, object oriented library. It also supports all the functions in
the C standard library. C++ uses the same control structures as C. C++ includes all the
build-in data types defined by C programming.

Object oriented programming encourage you to decompose a problem into its constituent
parts. Each component becomes a self-contained object that contains its own instructions
and data that relate to that object. In this way, complexity is reduced and the programmer
can manage larger program.

2. Structures and functions,


A structure is one or a group of variables considered as a (custom) data type. To create a
structure, use the struct keyword, followed by a name for the object, at least followed by
a semi-colon. Therefore, fundamentally, a structure can be created as: Struct Structure
Name; The struct keyword is required. The name of the structure follows the same rules
we reviewed for C++ names.

A function is a group of statements that is executed when it is called from some point of
the program. The following is its format:

type name ( parameter1, parameter2, ...) { statements }

where:

 type is the data type specifier of the data returned by the function.
 name is the identifier by which it will be possible to call the function.
 parameters (as many as needed): Each parameter consists of a data type specifier
followed by an identifier
 statements is the function's body. It is a block of statements surrounded by braces { }.

3. Object and classes, object arrays

A class is an expanded concept of a data structure: instead of holding only data, it can
hold both data and functions.
An object is an instantiation of a class. In terms of variables, a class would be the type,
and an object would be the variable.

Classes are generally declared using the keyword class, with the following format:
class class_name {
access_specifier_1:
member1;
access_specifier_2:
member2;
...
} object_names;

Where class name is a valid identifier for the class, object names is an optional list of
names for objects of this class. The body of the declaration can contain members, that can
be either data or function declarations, and optionally access specifies.

4. Object Array

Objects are variables and have the same capabilities and attributes as any other type of
variables. Therefore, it is perfectly acceptable for objects to be arrayed. The syntax for
declaring an array of objects is exactly as that used to declare an array of any other type
of variable. Further, arrays of objects are accessed just like arrays of other types of
variables.
#include < iostream >
class classname
{

};
void main( )
{
classname ob[4]; //array of 4 objects
}
5. Constructors and Destructor functions
Objects generally need to initialize variables or assign dynamic memory during their
process of creation to become operative and to avoid returning unexpected values during
their execution.
A class can include a special function called constructor, which is automatically called
whenever a new object of this class is created. This constructor function must have the
same name as the class, and cannot have any return type; not even void
The destructor fulfills the opposite functionality. It is automatically called when an
object is destroyed, either because its scope of existence has finished (for example, if it
was defined as a local object within a function and the function ends) or because it is an
object dynamically assigned and it is released using the operator delete.
The destructor must have the same name as the class, but preceded with a tilde sign (~)
and it must also return no value
#include < iostream >
class classname {
public:
myclass( ); //constructor
~myclass( ); //destructor }
1. Operator and function overloading:
Function Overloading: Two or more functions can share the same name as long as
either the type of their arguments differs or the number of their arguments differs - or
both. When two or more functions share the same name, they are said overloaded.
Overloaded functions can help reduce the complexity of a program by allowing related
operations to be referred to by the same name.
To overload a function, simply declare and define all required versions. The compiler
will automatically select the correct version based upon the number and/or type of the
arguments used to call the function.
Operator overloading: Operator overloading is the ability to tell the compiler how to
perform a certain operation when its corresponding operator is used on one or more
variables. To overload an operator in order to use it with classes we declare operator
functions, which are regular functions whose names are the operator keyword followed
by the operator sign that we want to overload. The format is:
data type operator sign (parameters) { /*...*/ }

Here you have an example that overloads the addition operator (+). We are going to
create a class to store bidimensional vectors and then we are going to add two of them:
a(3,1) and b(1,2). The addition of two bidimensional vectors is an operation as simple
as adding the two x coordinates to obtain the resulting x coordinate and adding the two y
coordinates to obtain the resulting y. In this case the result will be (3+1,1+2) = (4,3).

2. Inheritance, public and private inheritance, multiple inheritance

A key feature of C++ classes is inheritance. Inheritance allows to create classes which are
derived from other classes, so that they automatically include some of its "parent's"
members, plus its own. For example, we are going to suppose that we want to declare a
series of classes that describe polygons like our CRectangle, or like CTriangle. They
have certain common properties, such as both can be described by means of only two
sides: height and base.
This could be represented in the world of classes with a class CPolygon from which we
would derive the two other ones: CRectangle and CTriangle.

In order to derive a class from another, we use a colon (:) in the declaration of the
derived class using the following format:
class derived_class_name: public base_class_name
{ /*...*/ };
Where derived_class_name is the name of the derived class and base_class_name is
the name of the class on which it is based. The public access specifier may be replaced
by any one of the other access specifiers protected and private. This access specifier
describes the minimum access level for the members that are inherited from the base
class.
The objects of the classes CRectangle and CTriangle each contain members inherited
from CPolygon. These are: width, height and set_values().
The protected access specifier is similar to private. Its only difference occurs in fact
with inheritance. When a class inherits from another one, the members of the derived
class can access the protected members inherited from the base class, but not its private
members.
Since we wanted width and height to be accessible from members of the derived classes
CRectangle and CTriangle and not only by members of CPolygon, we have used
protected access instead of private.

Multiple Inheritance:
In C++ it is perfectly possible that a class inherits members from more than one class.
This is done by simply separating the different base classes with commas in the derived
class declaration. For example, if we had a specific class to print on screen (COutput) and
we wanted our classes CRectangle and CTriangle to also inherit its members in addition
to those of CPolygon we could write:

class CRectangle: public CPolygon, public COutput;


class CTriangle: public CPolygon, public COutput;

3. Pointers, pointers to base and derived classes


The memory of your computer can be imagined as a succession of memory cells, each
one of the minimal size that computers manage (one byte). These single-byte memory
cells are numbered in a consecutive way, so as, within any block of memory, every cell
has the same number as the previous one plus one.
Using pointer each cell can be easily located in the memory because it has a unique
address and all the memory cells follow a successive pattern. For example, if we are
looking for cell 1776 we know that it is going to be right between cells 1775 and 1777,
exactly one thousand cells after 776 and exactly one thousand cells before cell 2776.

The declaration of pointers follows this format:


type * name;
Operators new and new[]
In order to request dynamic memory we use the operator new. new is followed by a data
type specifier and -if a sequence of more than one element is required- the number of
these within brackets []. It returns a pointer to the beginning of the new block of memory
allocated. Its form is:
pointer = new type
pointer = new type [number_of_elements]
The first expression is used to allocate memory to contain one single element of type
type. The second one is used to assign a block (an array) of elements of type type,
where number_of_elements is an integer value representing the amount of these.
Since the necessity of dynamic memory is usually limited to specific moments within a
program, once it is no longer needed it should be freed so that the memory becomes
available again for other requests of dynamic memory. This is the purpose of the operator
delete, whose format is:
delete pointer;
delete [] pointer;
The first expression should be used to delete memory allocated for a single element, and
the second one for memory allocated for arrays of elements.

1. Polymorphism Early and late binding


One of the key features of derived classes is that a pointer to a derived class is type-
compatible with a pointer to its base class. Polymorphism is the art of taking advantage of
this simple but powerful and versatile feature, that brings Object Oriented Methodologies
to its full potential.
Connecting a function call to a function body is called as binding. In C++, there are two
types of binding: namely static (early) binding and dynamic (late/run-time) binding. If
binding happens during compilation/linking time (that is, before running), then it's called
as early binding. Binding happening during runtime is called late binding, which is
achieved through virtual functions.
2. Virtual functions
A member of a class that can be redefined in its derived classes is known as a virtual
member. In order to declare a member of a class as virtual, we must precede its
declaration with the keyword virtual:
3. Abstract base classes and pure virtual function
Pure virtual function is one, for which it's not required to have definition, but the class,
which derives the class, should override it. A virtual function can be inline and the inline
request may be served, if it's called on an object, but not when it's called on reference or
pointer to the class
An abstract class is a class that is designed to be specifically used as a base class and that
is not directly insatiable. An abstract class contains at least one pure virtual function. You
declare a pure virtual function by using a pure specifier (= 0) in the declaration of a
virtual member function in the class declaration
4. Friend function
In principle, private and protected members of a class cannot be accessed from outside
the same class in which they are declared. However, this rule does not affect friends.
Friends are functions or classes declared as such. If we want to declare an external
function as friend of a class, thus allowing this function to have access to the private and
protected members of this class, we do it by declaring a prototype of this external
function within the class, and preceding it with the keyword friend.
1. What are the basic functions of an operating system? - Operating system controls and
coordinates the use of the hardware among the various applications programs for various
uses. Operating system acts as resource allocator and manager. Since there are many
possibly conflicting requests for resources the operating system must decide which
requests are allocated resources to operating the computer system efficiently and fairly.
Also operating system is control program which controls the user programs to prevent
errors and improper use of the computer. It is especially concerned with the operation and
control of I/O devices.
2. While running DOS on a PC, which command would be used to duplicate the entire
diskette? diskcopy
3. What is virtual memory? - Virtual memory is hardware technique where the system
appears to have more memory that it actually does. This is done by time-sharing, the
physical memory and storage parts of the memory one disk when they are not actively
being used.
4. What is Throughput, Turnaround time, waiting time and Response time? -
Throughput – number of processes that complete their execution per time unit.
Turnaround time – amount of time to execute a particular process. Waiting time – amount
of time a process has been waiting in the ready queue. Response time – amount of time it
takes from when a request was submitted until the first response is produced, not output
(for time-sharing environment).
5. What is the state of the processor, when a process is waiting for some event to
occur? - Waiting state
6. What is the important aspect of a real-time system or Mission Critical Systems? - A
real time operating system has well defined fixed time constraints. Process must be done
within the defined constraints or the system will fail. An example is the operating system
for a flight control computer or an advanced jet airplane. Often used as a control device
in a dedicated application such as controlling scientific experiments, medical imaging
systems, industrial control systems, and some display systems. Real-Time systems may
be either hard or soft real-time. Hard real-time: Secondary storage limited or absent,
data stored in short term memory, or read-only memory (ROM), Conflicts with time-
sharing systems, not supported by general-purpose operating systems. Soft real-time:
Limited utility in industrial control of robotics, Useful in applications (multimedia,
virtual reality) requiring advanced operating-system features.
7. What is the difference between Hard and Soft real-time systems? - A hard real-time
system guarantees that critical tasks complete on time. This goal requires that all delays
in the system be bounded from the retrieval of the stored data to the time that it takes the
operating system to finish any request made of it. A soft real time system where a critical
real-time task gets priority over other tasks and retains that priority until it completes. As
in hard real time systems kernel delays need to be bounded
8. What is multi tasking, multi programming, multi threading? - Multi programming:
Multiprogramming is the technique of running several programs at a time using
timesharing. It allows a computer to do several things at the same time.
Multiprogramming creates logical parallelism. The concept of multiprogramming is that
the operating system keeps several jobs in memory simultaneously. The operating system
selects a job from the job pool and starts executing a job, when that job needs to wait for
any i/o operations the CPU is switched to another job. So the main idea here is that the
CPU is never idle. Multi tasking: Multitasking is the logical extension of
multiprogramming .The concept of multitasking is quite similar to multiprogramming but
difference is that the switching between jobs occurs so frequently that the users can
interact with each program while it is running. This concept is also known as time-
sharing systems. A time-shared operating system uses CPU scheduling and
multiprogramming to provide each user with a small portion of time-shared system.
Multi threading: An application typically is implemented as a separate process with
several threads of control. In some situations a single application may be required to
perform several similar tasks for example a web server accepts client requests for web
pages, images, sound, and so forth. A busy web server may have several of clients
concurrently accessing it. If the web server ran as a traditional single-threaded process, it
would be able to service only one client at a time. The amount of time that a client might
have to wait for its request to be serviced could be enormous. So it is efficient to have
one process that contains multiple threads to serve the same purpose. This approach
would multithread the web-server process, the server would create a separate thread that
would listen for client requests when a request was made rather than creating another
process it would create another thread to service the request. To get the advantages like
responsiveness, Resource sharing economy and utilization of multiprocessor architectures
multithreading concept can be used.
9. What is hard disk and what is its purpose? - Hard disk is the secondary storage device,
which holds the data in bulk, and it holds the data on the magnetic medium of the
disk.Hard disks have a hard platter that holds the magnetic medium, the magnetic
medium can be easily erased and rewritten, and a typical desktop machine will have a
hard disk with a capacity of between 10 and 40 gigabytes. Data is stored onto the disk in
the form of files.
10. What is fragmentation? Different types of fragmentation? - Fragmentation occurs in a
dynamic memory allocation system when many of the free blocks are too small to satisfy
any request. External Fragmentation: External Fragmentation happens when a dynamic
memory allocation algorithm allocates some memory and a small piece is left over that
cannot be effectively used. If too much external fragmentation occurs, the amount of
usable memory is drastically reduced. Total memory space exists to satisfy a request, but
it is not contiguous. Internal Fragmentation: Internal fragmentation is the space wasted
inside of allocated memory blocks because of restriction on the allowed sizes of allocated
blocks. Allocated memory may be slightly larger than requested memory; this size
difference is memory internal to a partition, but not being used
11. What is DRAM? In which form does it store data? - DRAM is not the best, but it’s
cheap, does the job, and is available almost everywhere you look. DRAM data resides in
a cell made of a capacitor and a transistor. The capacitor tends to lose data unless it’s
recharged every couple of milliseconds, and this recharging tends to slow down the
performance of DRAM compared to speedier RAM types.
12. What is Dispatcher? - Dispatcher module gives control of the CPU to the process
selected by the short-term scheduler; this involves: Switching context, Switching to user
mode, Jumping to the proper location in the user program to restart that program,
dispatch latency – time it takes for the dispatcher to stop one process and start another
running.
13. What is CPU Scheduler? - Selects from among the processes in memory that are ready
to execute, and allocates the CPU to one of them. CPU scheduling decisions may take
place when a process: 1.Switches from running to waiting state. 2.Switches from running
to ready state. 3.Switches from waiting to ready. 4.Terminates. Scheduling under 1 and 4
is non-preemptive. All other scheduling is preemptive.
14. What is Context Switch? - Switching the CPU to another process requires saving the
state of the old process and loading the saved state for the new process. This task is
known as a context switch. Context-switch time is pure overhead, because the system
does no useful work while switching. Its speed varies from machine to machine,
depending on the memory speed, the number of registers which must be copied, the
existed of special instructions(such as a single instruction to load or store all registers).
15. What is cache memory? - Cache memory is random access memory (RAM) that a
computer microprocessor can access more quickly than it can access regular RAM. As
the microprocessor processes data, it looks first in the cache memory and if it finds the
data there (from a previous reading of data), it does not have to do the more time-
consuming reading of data from larger memory.
16. What is a Safe State and what is its use in deadlock avoidance? - When a process
requests an available resource, system must decide if immediate allocation leaves the
system in a safe state. System is in safe state if there exists a safe sequence of all
processes. Deadlock Avoidance: ensure that a system will never enter an unsafe state.
17. What is a Real-Time System? - A real time process is a process that must respond to the
events within a certain time period. A real time operating system is an operating system
that can run real time processes successfully
What is a DBMS? Its features and Advantages.
A Database Management System (DBMS) is a software package to facilitate the creation and maintenance of
a computerised database. A Database System (DB) is a DBMS together with the data itself. The following
diagram shows the relationship of a database to a DBMS. (Figure adapted from El Masri and Navathe,
Fundamentals of Database Systems.)

Features of a database.
 It is a persistent (stored) collection of related data.
 The data is input (stored) only once.
 The data is organised (in some fashion).
 The data is accessible and can be queried (effectively and efficiently).
So a database is a collection of related data that we can query effectively and efficiently.

Advantages.
Eliminates redundancy and avoids inconsistency
Confidentiality,
Supports multiple, concurrent users
Privacy, and
Security

Various views of data


 External level - an individual user's view of the organisation of the data
 Conceptual level - how the community views the organisation of the data. only one data
model, conceptual schema. The external view differs from the conceptual level because
some users aren't interested in or are restricted from having the entire community's view
 Internal level - The internal view is the view about the actual physical storage of data. It
tells us what data is stored in the database and how. At least the following aspects are
considered at this level.
Data Indipendence
 Data Independence - The management of data at each level is independent. An objective
not a feature.
 Physical Data Independence - Physical level does not impact the conceptual level.
 Logical Data Independence - Conceptual level does not impact the external level.
Schema and subschema
The schema is the physical arrangement of the data as it appears in the DBMS. The
subschema is the logical view of the data as it appears to the application program.

DATA MODELING
It consists of some concepts to describe the structure of database i.e. data type,ralations, and constraints that
should hold on the data. Eg. ER model
Logical data modeling is a graphic-intensive technique that results in a data model representing the definition,
characteristics, and relationships of data in a business, technical, or conceptual environment. Its purpose is to
describe end-user data to systems and end-user staff.
Various methods of data modeling exist, each using a host of conventions and tools. The most popular
approach is called the entity-relationship (ER) approach, developed by Peter Chen in the late 1970s. Although
a number of authors and tool designers have modified and expanded ER concepts, most still have a strong
Chen flavor. Also, with the introduction of CASE tools, the number of diagrammatic conventions that the
data modeler must master has increased sharply.
Data Modeling Objects
The three types of data objects--entities, attributes, and relationships--are the basic building
blocks of modeling:
 Entities are persons, places, or things about which an organization wishes to save
information. Employees, States, Orders, and Time Sheets are examples of entities. (As a
convention, I capitalize the first letter of entities.)
 Attributes are the properties of entities. Attribute examples include Color, Employment
Date, Name, and Social Security Number. (As a convention, I write attributes in all
upper-case letters.)
 Relationships are verbs that describe how entities relate to each other; for example:
'Customers Buy Products,' 'Employees File Time Sheets,' 'Salespeople Place Orders.' A
sentence in this entity-relationship-entity construct is called a "relationship entity pair,"
which is a fashionable mechanism for representing relationships. Relationship entity pairs
are bidirectional. Therefore, 'Customers Buy Products' is the same as 'Products are
Bought by Customers.' "Relationship" describes an end-user relationship, not a technical
one. (As a convention, I capitalize the first letter of relationship names, and capitalize the
first letter of relationship entity pairs and put them in single quotes.)
Database Users
Following are the types of database users:
 Database Administrator - a database administrator performs the following activities:
o Monitoring performance
o Granting user authority to access the database
 Application programmers
 Data analysts
 Naive users

Entity-relationship model

The E-R (entity-relationship) data model views the real world as a set of basic objects
(entities) and relationships among these objects. This represents the overall logical
structure of the DB.
An Entity-relationship model is a relational schema database modeling method used to model a system and its
requirements in a top-down approach. This approach is commonly used in relational (RDBMS) database
design. The diagrams created using this method are called ER diagrams.
An entity-relationship model (ERM) is an abstract conceptual representation of structured data; entity-
relationship modeling is the process of generating these models. The end-product of the modeling process is
an entity-relationship diagram (ERD) or ER diagram, a type of conceptual data model or semantic data
model
The E-R (entity-relationship) data model views the real world as a set of basic objects
(entities) and relationships among these objects. It is intended primarily for the DB design
process by allowing the specification of an enterprise scheme. This represents the overall
logical structure of the DB.
Generalization/Specialization
Generalization/Specialization represents the is a relationship set , an essential element of the object oriented
paradigm. The main idea in Generalization/Specialization is that one object class (the specialization) is a
subset of another (the generalization).

Kind of Relations
One-To-One Relation
A very simple relation between two tables is an one-to-one relation. Using this relation, for every row in the
first table exactly one other row in the second table is assigned. The relation is reflected in the object world
using a reference to another object.
One-To-Many Relation
This kind of relationship is an extension of one-to-one relations. You should understand the concepts behind
one-to-one relations before reading this chapter.
Using one-to-many relations, you cannot only model a reference to a single object of same or different type,
but as many references as you like.
Many-To-Many Relation Mapping
This relationship type extends the one-to-many relations by the ability to assign from one tables row to more
than one row from the other table and vice versa. These relations are stored in a separate third table, the so-
called lookup table. Both source tables do not contain any information that deals with relations
Relational database
A relational database is a collection of data items organized as a set of formally-described tables from which
data can be accessed or reassembled in many different ways without having to reorganize the database tables.
The relational database was invented by E. F. Codd at IBM in 1970.
Various types of Keys
There are various types of relational keys (foreign keys are another issue and discussed
separately):
Candidate Key
A candidate key is any set of one or more columns whose combined values are unique
among all occurrences (i.e., tuples or rows). Since a null value is not guaranteed to be
unique, no component of a candidate key is allowed to be null.

Primary Key
The primary key of any table is any candidate key of that table which the database
designer arbitrarily designates as "primary". The primary key may be selected for
convenience, comprehension, performance, or any other reasons. It is entirely proper to
change the selection of primary key to another candidate key.

Alternate Key
The alternate keys of any table are simply those candidate keys which are not currently
selected as the primary key. According to Date95, "... exactly one of those candidate keys
[is] chosen as the primary key [and] the remainder, if any, are then called alternate keys."
An alternate key is a function of all candidate keys minus the primary key.
Superkey
A Superkey is defined in the relational model of database organisation as a set of attributes of a relation
variable (relvar) for which it holds that in all relations assigned to that variable there are no two distinct tuples
(rows) that have the same values for the attributes in this set. Equivalently a Superkey can also be defined as a
set of attributes of a relvar upon which all attributes of the relvar are functionally dependent.
Note that if attribute set K is a Superkey of relvar R, then at all times it is the case that the projection of R over
K has the same cardinality as R itself.
Informally, a Superkey is a set of columns within a table whose values can be used to uniquely identify a row.
A candidate key is a minimal set of columns necessary to identify a row, this is also called a minimal
Superkey.
Foreign key
In the context of relational databases, a foreign key is a referential constraint between two tables.[1] The
foreign key identifies a column or a set of columns in one (referencing) table that refers to a column or set of
columns in another (referenced) table. The columns in the referencing table must form a primary key or
unique key in the referenced table. The values in one row of the referencing columns must occur in a single
row in the referenced table. Thus, a row in the referencing table cannot contain values that don't exist in the
referenced table. This way references can be made to link information together and it is an essential part of
database normalization. Multiple rows in the referencing table may refer to the same row in the referenced
table. Most of the time, it reflects the one (master table, or referenced table) to many (child table, or
referencing table) relationship.

You might also like