Hsslive-xii-comp-app--comm-act-malappuram-english
Hsslive-xii-comp-app--comm-act-malappuram-english
prepared by:
Character set
Fundamental units of C++ Language. It consists of letters, digits, special characters, white
spaces etc
Tokens
Fundamental building blocks of a program. Tokens are classified into keywords, identifiers,
literals , punctuators and operators
Keywords
Reserved words in C++ . it convey a specific meaning to the language compiler.
Eg : break , long , for etc
Identifiers
Name given to different program elements such as memory locations , statements etc.
Eg : n1 , sum , avg_ht etc
• Identifier is a sequence of letters , digits and underscore.
• The first character must be letter or underscore
• Keyword cannot be used as an identifier.
• Special characters or white spaces cannot be used
• Identifier for memory location is called variable.
• Identifier for a statement is called label.
• Identifier for group of statements is called function name.
Literals
Constant values used in programs. (Token that do not change their value during the program
run)
• Integer literals : Whole numbers Eg : 25 , -45 , +12 etc
• Floating point literals : Numbers having fractional parts Eg : 12.5 , -2.50 etc
• Character literals : A character in single quotes Eg: ‘A’ , ‘b’ , ‘8’ ,
(Escape sequences are character constants used to represent non graphic symbols. Eg: ‘\n’ , ‘\t’ etc
)
• String literals : One or more characters within double quotes. Eg: “A”, “break” , “123” etc
Punctuators
3
Operators
Symbols used to represent an operation Eg : + , < , * , && , ||
• Unary operator – operates on a single operand.
Eg : Unary + , Unary - , ++ (increment operator), -- (decrement operator), logical NOT (!)
• Binary operator – operates on two operans
Eg : Arithmetic operators ( + , - , * , / , % )
Relational operators ( < , <= , > , >= , == , != )
Logical operators ( Logical AND ( &&) , Logical OR ( ||)
Arithmetic assignment operator ( += , -= , *= , /= , %= )
• Ternary operator – operates on three operands
Eg: conditional operator ( ? : )
Data types
Used to identify the nature of data and set of operations that can be performed on data.
Fundamental data types in C++ are void, char, int , float and double
Variable
Identifier ( Name) given to memory location
• Variable name – the name given to memory location
• L value – the memory address
• R value – The value stored in the variable ( content)
Type modifiers
Used to modify the size of memory space and range of data
Type modifiers in C++ are signed , unsigned , long and short
Type conversion
The process of converting the current data type of a value into another type.
• Implicit type conversion ( Type promotion)
• Explicit type conversion (Type casting )
Expressions
Expressions are constituted by operators and required operands to perform an operation
• Arithmetic expression Eg : a+b , a*b
a. Integer expression Eg ; 5 + 4 , 10 * 5
b. Real expression Eg : 2.5 + 3.0 , 5.0 / 2.5
4
Control Statements
Control statements are used to alter the normal flow of execution
1. Selection statements / Decision making statements -
if , if ..... else , if ...... else ...... if ladder , switch
2. Iteration statements / Looping statements
for , while , do .... while
Selection Statements / Decision making statements
Statements are selected for execution based on a condition.
5
Iteration statements are classified into two: entry- controlled and exit-controlled.
In entry-controlled loop, test expression is evaluated before the execution of the loop-body.
Eg : for , while
In exit-controlled loop, condition is checked only after executing the loop- body.
Eg : do .... while
Jump Statements
Jump statements are used to transfer the program control from one place to another.
C++ provides four jump statements
7
Sample questions
1. A ............... statement in a loop forces the termination of the loop.
2. The insertion operator in C++ is ............
3. The operator which is used to find the remainder during arithmetic division is ...........
4. ............. is an exit controlled loop (while, for, do ...... while , break)
5. The operator which is an alternative of if ....... else statement.
6. Define type modifiers in C++ . List type modifiers in C++.
7. Compare break and continue statements in C++.
8. What are the main components of a loop
9. Explain switch statement with example.
10. Explain implicit and explicit conversions.
11. Write the output of the following code
for(i=1; i<=5 ; ++i)
{
cout<<’\t’<<i;
if(i==3) break;
}
12. Rewrite the following code using for loop
sum=0;
i=0;
while(i<10)
{
sum=sum+i;
i++;
}
cout<<”sum=”<<sum;
13. Rewrite the code using switch statement
cin>>pcode;
if(pcode==’c’)
cout<<”computer”;
8
else if(pcode==’m’)
cout<<”mobile phone”;
else if(pcode==’l’)
cout<<”laptop”;
else
cout<<”invalid”;
14. Rewrite the following code using for loop
int x =1;
start :
cout << x;
x=x+5;
if(x<=50)
goto start;
CHAPTER 2 – ARRAYS
9
Array
Array is a collection of elements of same type placed in contiguous memory location
Eg : A[10] , NUM[20]
Each element in an array can be accessed using its position called index number or subscript.
An array index starts from 0. The elements of an array with ten elements are numbered from 0
to 9.
Array declarations
data_type array name[size]; where size is the number of memory locations in the array.
Eg: int N[10] ;
float A[5] ;
char name[25] ;
Array initialization
Giving values to the array elements at the time of array declaration is known as array
initialization.
Eg : int N[10]={12,25,30,14,16,18,24,22,20,28} ;
float A[5]={10.5,12.0,5.75,2.0,14.5} ;
char word[7]={‘V’ , ‘I’ , ‘B’ , ‘G’ , ‘Y’ , ‘O’ , ‘R’ } ;
gets(str);
cout<<str;
If we input Higher Secondary, the output will be Higher Secondary.
puts() function is used to display a string data on the standard output device (monitor).
Eg :
char str[10] = "friends";
puts("hello");
puts(str);
The output of the above code will be as follows:
hello
friends
Sample questions
1. ................. character is stored at the end of the string
2. Accessing each element of an array at least once to perform any operation is called ..........
3. How many bytes will be allocated for the following array
int ar[ ]={3,7,8,2};
4. Find the value of sore[4] based on the following declaration statement
int score[5]={98,87,92,89,75};
5. Consider the following statement arr[5]={1,5,8,3,19};
a)Write the value of arr[3]?
b)Write the value of arr[4] – 5
6. Write C++ statement to initialize an array named ‘MARK’ with values 70,80,85,90
7. Define Array.
(1) Declare an array of size 20 to store a string
(2) Write C++ statement to store the string “welcome” in that array
8. How many bytes are required to store the string “HELLO WORLD”
9. Consider the C++ statement char first [ ] = “School”;
Write the output of the following
(a) cout<< first ;
(b) cout <<first[1] ;
(c) Find the size of the array first [ ]
10. Consider the following code
12
a) char str[20];
cin>>str ;
cout<<str;
b) char str[20];
gets(str);
cout<<str;
what will be the output if we input “NEW DELHI” . Justify your answer
CHAPTER 3 – FUNCTIONS
Modular Programming / Modularization
The process of breaking large programs into smaller sub programs is called modularization.
13
Function
Function is a named unit of statements in a program to perform a specific task.
main() is an essential function in C++ program . The execution of the program begins in main().
Two types of functions
• Predefined functions / built-in functions - ready to use programs
• User defined functions
Arguments / Parameters
The data required to perform the task assigned to a function. They are provided within the pair
of parentheses of the function name.
Return value
The result obtained after performing the task assigned to a function. Some functions do not
return any value
Built-in functions
putchar(ch) ; // displays B
putchar('C'); // displays C
3. String functions
• strlen( ) - used to find the length of the string ( number of characters)
Header file : cstring
Syntax : int strlen(string) ;
Eg: strlen(“COMPUTER”) ; // displays 8
• strcpy( ) - used to copy a string to another
Header file : cstring
Syntax : strcpy( string1,string2) ;
15
4. Mathematical functions
• abs( ) - used to find the absolute value of a number
Header file : cmath
Syntax : int abs( int) ;
Eg : cout<<abs(-5) ; // displays 5
• sqrt( ) - used to find the square root of a number
Header file : cmath
Syntax : double sqrt(double) ;
Eg : cout<<sqrt(16) ; // displays 4
• pow( ) - used to find the power of a number
Header file : cmath
Syntax : double pow(double, double) ;
Eg: cout<<pow(3,2) ; // displays 9
5. Character functions
• isupper( ) - used to check whether a character is in upper case(capital letter) or not.
Header file : cctype
Syntax : int isupper (char) ;
Eg : cout<<isupper('A') ; // displays 1
16
cout<<isupper('d') ; // displays 0
• islower( ) - used to check whether a character is in lower case(small letter) or not.
Header file : cctype
Syntax : int islower (char) ;
Eg : cout<<islower('A') ; // displays 0
cout<<islower('d') ; // displays 1
• isalpha( ) - used to check whether a character is an alphabet or not.
Header file : cctype
Syntax : int isalpha(char) ;
Eg : cout<<isalpha('B') ; // displays 1
cout<<isalpha('8') ; // displays 0
• isdigit( ) - used to check whether a character is digit or not
Header file : cctype
Syntax : int isdigit(char c) ;\
Eg : cout<<isdigit('8') ; // displays 1
cout<<isdigit('b') ; // displays 0
• isalnum( ) - used to check whether a character is alphanumeric or not.
Header file : cctype
syntax : int isalnum(char) ;
Eg : cout<<isalnum('8') ; // displays 1
cout<<isalnum('a') ; // displays 1
cout<<isalnum('+') ; // displays 0
• toupper( ) - used to convert the given character into its uppercase.
Header file : cctype
Syntax : char toupper(char) ;
Eg : cout<<toupper('b') ; // displays B
• tolower( ) - used to convert the given character into its lower case.
Header file : cctype
Syntax : chat tolower(char) ;
Eg : cout<<tolower('B') ; // displays b
Prototype of functions
A function prototype is the declaration of a function
Syntax : data_type function_name(argument list);
Eg : int sum( int , int ) ;
void sum( ) ;
int sum( ) ;
Arguments of functions
• Arguments or parameters are the means to pass values from the calling function to the called function.
• The variables used in the function definition as arguments are known as formal arguments.
• The variables used in the function call are known as actual (original) arguments.
Sample Questions
1. The variables used in the function definition are called ...............
2. The data required for a function to perform the task assigned to it are called as _________.
3. The process of breaking large program into smaller sub programs is called ...............
4. What will be the result of following C++ statements ?
(a) Strlen (“Application”); (b) Pow (5, 3);
5. Briefly explain, how call by value method is different from call by reference method.
6. ............. function is send to check whether a character is alpha numeric
7. Name the mathematical function which returns the absolute value of an integer number
8. a. Define modular programming
b. Explain the merits of modular programming
9. Explain any two built-in functions in C++ that are used for string manipulation.
10. .................... function is used to append one string to another string in C++.
11. Identify the built in function for the following
a. to convert -25 to 25
b. compare ‘computer’ and ‘COMPUTER’ ignoring cases
c. to check given character is digit or not
d. to convert the character ‘B’ to ‘b’
e. to find the square root of a number
12. Pick the character function from the following
abs(), isdigit() , strcpy()
13. Differentiate actual arguments and formal arguments
14. Write the output of the following C++ code segment
19
char s1[10]=”Computer”;
char s2[15]=”Application”;
strcpy(s1,s2);
cout <<s2;
15. Explain two stream functions for input operations with example
16. Consider the following code
char s1[10] = "hello" , s2[10];
strcpy (s2, sl);
cout << s2;
What will be the output ?
17. Consider the following code
char s1[10] = "hello" , s2[10]=”HELLO”;
int n=strcmpi(s1 , s2) ;
cout << n;
What will be the output ?
18. Consider the following code
char S1[20]= "welcome ";
char S2[20] = “ to C++” ;
strcat(S1,S2);
cout<<S1;
What will be the output ?
Website
• A website is a collection of web pages.
• Web pages are developed with the help of HTML (Hyper Text Markup Language).
• Here a user request service from a server and the server returns back the service to the client.
– If it is not found there, the ISP's DNS server initiates a recursive search starting from the
root server till it receives the IP address.
– The ISP's DNS server returns this IP address to the browser.
– The browser connects to the web server using the IP address.
Web designing
• Web designing is the process of designing attractive web sites.
• Any text editor can be used to design web pages.
• Several softwares are also available for designing web pages.
• Eg:- Bluefish, Bootstrap, Adobe Dreamweaver, Microsoft Expression Web, etc.
Static and dynamic web pages
Static web page Dynamic web page
Content and layout is fixed. Content and layout may change.
Never use databases. Uses database.
Directly run on the browser. Runs on the server.
Easy to develop. Development requires programming skills.
Scripts
• Scripts are program codes written inside HTML pages.
• Script are written inside <SCRIPT> and </SCRIPT> tags.
Types of scripting languages
• Scripting languages are classified into two:
1. Client side scripts Eg:- JavaScript, VB script.
2. Server side scriptsEg:- Perl, PHP, ASP, JSP, etc.
Scripting languages
JavaScript
• It is a client side scripting language.
• Works in every web browser.
• JavaScript file has the extension ‘.js’.
Ajax
22
• Ajax stands for Asynchronous JavaScript and Extensible Markup Language (XML).
• It helps to update parts of a web page, without reloading the entire web page.
VB Script
• Developed by Microsoft.
• It can be used as client side/server side scripting language.
PHP
• PHP stands for 'PHP: Hypertext Preprocessor'.
• It is a server side open source scripting language.
• It support database programming.
• PHP file has the extension ‘.php’.
Active Server Pages (ASP)
• It is a server-side scripting environment developed by Microsoft.
• Uses VBScript or JavaScript as scripting language.
• ASP files have the extension .asp.
• It provides support to a variety of databases.
Java Server Pages (JSP)
• It is a server side scripting language developed by Sun Microsystems.
• JSP files have the extension .jsp.
Cascading Style Sheet (CSS)
• It is a style sheet language used to define styles for webpages. (colour of the text, the style of fonts,
background images, etc.)
• CSS can be implemented in three different ways:
◦ Inline - the CSS style is applied to each tag.
◦ Embedded - CSS codes are placed within the <HEAD> tag.
◦ Linked CSS - external CSS file linked with the webpage.
Advantages of using CSS
• We can reuse the same code for all the pages.
• It reduces the size of the web page.
• Easy for maintenance.
HTML (Hyper Text Markup Language)
• HTML is the standard markup language for creating Web pages.
• The commands used in HTML are called tags.
• The additional information supplied with HTML tags are called attributes.
Eg:- <BODY Bgcolor = "Yellow">
23
Here, <BODY> is the tag, Bgcolor is the attribute, Yellow is the value of this attribute.
• HTML file is to be saved with an extension .html or .htm
The basic structure of an HTML document
<HTML>
<HEAD>
<TITLE> ....... title of web page......... </TITLE>
</HEAD>
<BODY>
...............contents of webpage..........................
</BODY>
</HTML>
Tags Use
<B> and <STRONG> To make the text Bold face
<I> and <EM> To make the text italics
<U> To underline the text
<S> and <STRIKE> To strike through the text
<BIG> To make a text big sized
<SMALL> To make a text small sized
<SUB> To make the text subscripted
<SUP> To make the text superscripted
25
Sample Questions
1. Expand DNS.
2. A Domain Name System returns the .................. of a domain name.
3. Expand HTTPS.
4. Compare static and dynamic webpages.
5. What are the differences between client side and server side scripts ?
6. What is a Script ? Name any two server side scripting languages.
7. Name two technologies that can be used to develop dynamic web pages.
8. A JavaScript file has the extension .............
9. The number of bits in a software port number is ..............
a. 8 b. 16 c. 32 d. 64
10. Write the port number for the following web services.
(i) Simple Mail Transfer Protocol (ii) HTTP Secure (HTTPS)
11. Write the service associated with the following software port number.
27
Lists in HTML
• There are three kinds of lists in HTML – Unordered lists, Ordered lists and Definition lists.
1. Unordered lists
• Unordered lists or bulleted lists display a bullet in front of each item in the list.
• <UL> tag: To create Unordered list.
• <LI> tag: To add items in the list.
• Attribute of UL tag: Type. (Values: Disc, Square, Circle.)
Eg: <UL Type= "Square">
<LI> RAM </LI>
<LI> Hard Disk </LI>
<LI> Mother Board </LI>
</UL>
2. Ordered lists
• Ordered lists or numbered lists present the items in some numerical or alphabetical order.
• <OL> tag: To create Ordered list.
• <LI> tag: To add items in the list.
• Attributes:
(1) Type: Values: “1”, “I”, “i”, “a” and “A”.
(2) Start: To specify the starting number.
Eg: <OL Type= "A" Start= "5">
<LI> Registers </LI>
<LI> Cache </LI>
<LI> RAM </LI>
</OL>
3. Definition lists
• Definition List is a list of terms and its definitions.
• <DL> tag: To create Definition list.
• <DT> tag: To specify the term, <DD> tag: To add its definition.
Eg: <DL>
<DT>Spam :</DT>
<DD> ............Definition of Spam ..............</DD>
29
<DT>Phishing :</DT>
<DD> ........... Definition of Phishing.......... </DD>
</DL>
Nested lists
• A list inside another list is called nested list.
• Eg: an unordered list inside another unordered list, an unordered list inside an ordered list, etc.
Creating links
• A hyperlink is a text/image that links to another document or another section of the same document.
• The <A> Tag (Anchor tag) is used to create Hyperlinks.
• Attribute: Href, Value is the URL of the document to be linked.
• Eg: <A Href= "http://www.dhsekerala.gov.in">Higher Secondary Education</A>.
There are two types of linking – internal linking and external linking.
1. Internal linking
• Link to a particular section of the same document is known as internal linking.
• The Name attribute is used to give a name to a section of the web page. We can refer to this section
by giving the value of Href attribute as #Name from another section of the document.
2. External linking
• The link from one web page to another web page is known as external linking.
• Here, the URL / web address is given as the value for Href attribute.
URL
• URL stands for Uniform Resource Locator, and it means the web address.
Creating graphical hyperlinks
• We can make an image as a hyperlink using <IMG> tag inside the <A> tag.
• Eg:- <A Href= "https://www.wikipedia.org"><IMG Src= "wiki.jpg"></A>
e-mail linking
• We can create an e-mail hyperlink to a web page using the hyperlink protocol mailto:
• Eg:- <A Href= mailto: "[email protected]">Mail SCERT Kerala </A>
Inserting music and videos
• <EMBED> tag: To add music or video to the web page.
• Attributes: Src, Height, Width, Align, Alt.
• <NOEMBED> tag: To display a text if the <EMBED> tag is not supported by the browser.
• <BGSOUND> tag: To play a background music while the page is viewed.
30
<TD>Arun</TD>
</TR>
</TABLE>
Eg:
<FRAMESET Rows= "30%, *"> [Horizontally divides the window into two frames]
<FRAME Src= "sample1.html">
<FRAME Src= "sample2.html">
</FRAMESET>
Nesting of Framesets
• Inserting a frameset within another frameset is called nesting of frameset.
Forms in web pages
• HTML Forms are used to collect data from the webpage viewers.
• A Form consists of two elements: <FORM> container and Form controls (like text fields, drop-down
menus, radio buttons, etc.)
Sample Questions
1. What are the different types of lists in HTML?
2. Which are the attributes of <OL> tag ? Write their default values.
3. Write the names of tags used to create an ordered and un-ordered list.
4. Write HTML code to get the following output using ordered list.
III. PRINTER
IV. MONITOR
V. PLOTTER
33
5. Write the HTML code to display the following using list tag:
(i) Biology Science
(ii) Commerce
(iii) Humanities
6. What is a definition list ? Which are the tags used to create definition list ?
7. What is a hyperlink ? Which is the tag used to create a hyperlink in HTML document ?
8. Sunil developed a personal website, in which he has to create an e-mail link. Can you suggest the protocol
used to achieve this link.
9. Name any two associated tags of <TABLE> tag.
10. Write HTML program to create the following webpage :
Operators in JavaScript
Category Operators Eg:- Result
+ 10 +5 15
- 10 - 5 5
Arithmetic Operators * 10 * 5 50
/ 10 /5 2
% 10 %5 0
< 10<5 false
> 10>5 true
<= 10<=5 false
Relational Operators
>= 10>=5 true
== 10==5 false
!= 10!=5 true
|| OR 10<5||10== 5 false
Logical Operators && AND 10<5 &&10 == 5 false
! NOT !(10==5) true
Increment and decrement ++ x++ x=x+1
i++;
updation;
}
}
alert(s);
Event Description
onClick Occurs when the user clicks on an object
onMouseEnter Occurs when the mouse pointer is moved onto an object
onMouseLeave Occurs when the mouse pointer is moved out of an object
onKeyDown Occurs when the user is pressing a key on the keyboard
onKeyUp Occurs when the user releases a key on the keyboard
Sample Questions
1. Which tag is used to include script in an HTML page?
2. What are the Data Types in Javascript?
3. Explain the operators in javascript.
4. What are the different methods for adding Scripts in an HTML Page?
5. Explain some common JavaScript events.
6. Explain Built - in Functions in JavaScript
7. The keyword used to declare a variable in Javascript is .............
40
1. Shared hosting
This is the most common type of web hosing. It is referred to as shared because many different
websites are stored on one single web server and they share resources like RAM and CPU.
2. Dedicated Hosting
Dedicated web hosting is the hosting where the client leases the entire web server and all its
resources. Dedicated hosting is ideal for websites that require more storage space and more bandwidth
and have more visitors. This is the most expensive web hosting method.
• While purchasing hosting space, we have to decide the amount of space required.
• We need to select a hosting space that is sufficient for storing the files of our website.
• If the web pages contain programming content, we need a supporting technology in the
web server.
Domain name registration
• Domain names are used to identify a website in the Internet.
• After finalising a suitable domain name for our website, we have to check whether this
domain name is available for registration .
• The websites of the web hosting companies or web sites like www.whois.net provide
41
Free hosting
• Free hosting provides web hosting services free of charge. The service provider displays
advertisements in the websites hosted to meet the expenses. Only allow you to upload very small
files. Also audio and video files are not allowed.
• Free hosting companies offer two types of services for obtaining a domain name:
1. Directory Service: -
Company Address / Our Address (www.example.com/oursite)
2. Sub Domain: - Our Address.Company Address (oursite.example.com)
Sample Questions
1. Explain the different types of Web Hosting.
2. What is Content Management System ?
3. Explain the need for applying responsive web design while developing websites
4. Briefly explain about FTP client softwares.
5. What is free hosting?
43
Need of Database
• Database is an organized collection interrelated data
• The software Database Management System (DBMS) is a set of programs which deals the storage,
retrieval and management of database
Advantages of Database
• Controlling Data redundancy
• Efficient Data access
• Data Integrity
• Data security
• Sharing of data
• Enforcement of standards
• Crash recovery
Physical level
• Lowest level of abstraction
• Describes how data is actually stored in secondary storage devices
Logical level
• Next higher level
• Describes what data stored in the database and relationship among those data
• Database Administrators decide what information to keep in database
View level
• Highest level
• closest to the users
• Describes user interaction with database system
Data independence
The ability to modify the schema definition (structure) in one level without affecting the schema
definition at the next higher level is called data independence
Two levels
1. Physical data independence
2. Logical data independence
Users of database
• Database administrator (DBA)
• Application Programmers
• Sophisticated Users
• Naive users
45
Database administrator
• Control the whole database
• Responsible for many critical task
Design of the conceptual and physical schema
Security and authorization
Data availability and recovery from failures
Application Programmers
• Computer professionals who interact with DBMS through application programs
• Application programs are written in any programming languages
Sophisticated users
• Includes engineers, scientists, business analyst who are thoroughly familiar with the facilities of
DBMS
• Interact with database with their own queries (request to the database)
Naïve users
• Interact with the database by running an application program that are written previously
• They are not aware of the details of database
• eg: Bank clerk, billing clerk in a super market
Terminologies in RDBMS
Entity
• It’s a person or a thing in the real world. e.g. student, school etc.
Relation
• Collection of data elements organized in terms of rows and columns
• A relation is also called table
46
Tuple
• The row (records) of a relation is called tuples
• A row consists of a complete set of values to represent a particular entity
Attributes
• The row (records) of a relation is called tuples
• A row consists of a complete set of values to represent a particular entity
Degree
• The number of attributes in a relation
Cardinality
• The number of rows or tuples in a relation
Domain
• It’s a pool of values from which actual values appearing in a given column
Schema
• The structure of database is called the database schema
• In RDBMS the schema for a relation specifies its name, name for each column and the type of each
column
• e.g. STUDENT
( Admno : integer
RollNo:Integer
Name: Character(15)
Batch: Character(15) )
Instance
• An instance of a relation is a set of tuples in which each tuple has the same number of fields as the
relational schema
keys
• A key is an attribute or collection of attributes in a relation that uniquely distinguishes each tuples
from other tuples in a relation
• If a key consists of more than one attribute then it is called composite key
Candidate key
It is the minimal set of attributes that uniquely identifies a row in a relation
Admno Roll Name Batch
101 12 Sachin Science
109 17 Rahul Humanities
47
Primary key
• One of the candidate key chosen to be the unique identifier for that table by the database designer
• It cannot contain null value and duplicate value
Alternate Key
• A candidate key that is not a primary key is called an alternate key
Foreign key
• A key in a table called foreign key if it is a primary key in another table
• used to link two or more table
• Also called reference key
RELATIONAL ALGEBRA
The collection of operations that is used to manipulate the entire relations of a database is known as
relational algebra
These operations are performed with the help of a special language called query language
The fundamental operations are
SELECT, PROJECT, UNION, INTERSECTION, SET DIFFERENCE, CARTESIAN PRODUCT
SELECT Operation
• Select rows from a relation that satisfies a given condition
• Denoted using sigma ()
General Format
condition (Relation)
• Uses various comparison operators
• <, >, <=, >=, <>
• Logical operators V (OR) , ˄ (AND), ! (NOT)
PROJECT Operation
• Select certain attributes from the table and forms a new relation
• Denoted by (Pi)
General Format
A1, A2,….., An (Relation)
• A1, A2,………, An are various attributes
UNION Operation
• Returns a relation that containing all tuples appearing in two specified relations
• Two relations must be UNION compatible
• UNION compatible means two relations must have same number of attributes
• Denoted by ‘U’
ARTS Relation
Admno Name Batch code
102 Rahul C2
103 Fathima H2
105 Nelson H2
108 Bincy S2
164 Rachana S1
SPORTS Relation
Admno Name Batch code
101 Sachin S2
103 Fathima H2
110 Vivek C1
132 Nevin C1
102 Rahul C2
105 Nelson H2
108 Bincy S2
164 Rachana S1
ARTS U SPORTS
INTERSECTION Operation
• Returns a relation containing tuples appearing in both of the two specified relations
• Denoted by
• Two relations must be union compatible
Features of SQL
• It’s a relational database language not a programming language
• Simple, Flexible, Powerful
• It provides commands to create and modify tables, insert data into tables, manipulate data in the table
etc.
• It can set different type of access permissions to user
• It provides concept of views
Components of SQL
Three Components
1. Data Definition Language (DDL)
2. Data Manipulation Language (DML)
3. Data Control Language (DCL)
Opening MySQL
• We use the following command in the terminal window to start MySQL
53
mysql -u root -p
• To exit from MySQL, Give the command QUIT or EXIT
Creating Database
• We use the command CREATE DATABASE for creating a database in MySQL
Syntax:
CREATE DATABASE <database_name>;
Example:
CREATE DATABASE School
Opening Database
• When we open a database, it becomes the active database in MySql
Syntax:
USE <database_Name>;
SHOW DATABASES;
• This command list the entire databases in our system
• DECIMAL
• Numbers with fractional part can be represented by DEC or DECIMAL
• Standard form DEC (size, D) or DECIMAL (size, D)
• ‘size’ indicate the total number of digits in the number
• ‘D’ represents the number of digits after the decimal point
• Eg: DEC (3,2)
CHAR or CHARACTER
• Includes Letters, Digits, Special symbols etc.
• syntax: CHAR (x), where ‘x’ is the maximum number of characters
• The value of ‘x’ can be between 0 and 255
• if the number of characters less than the size, remaining positions filled by white spaces
• Default size is ‘1’
VARCHAR
• Represents the variable length strings
• Similar to CHAR
• Space allocated for the data depends only on the actual data
DATE
• Represents date values in “YYYY-MM-DD” format
• Eg: 2013/04/23, 2015-04-16, 20160722
TIME
• Standard format is HH:MM:SS
SQL Commands
Creating Tables
• We use CREATE TABLE command for creating a table
• DDL Command
Syntax:
CREATE TABLE <table_name>
( <Column Name> <data_types> [<constraints>]
[, <Column Name> <data_types> <constraints>,]
.................................................................................
................................................................................. );
• All columns are defined with in a pair of parentheses and seperated by commas
Constraints
• Rules enforced data that are entered into the column of a table
• Two types column level and table level
Column constraints
1. NOT NULL
• Specifies that column can never have NULL values
2. AUTO_INCREMENT
• The value of the column incremented by one
• The default value is 1
• The AUTO_INCREMENT column must be defined as the Primary Key of the table
56
3. UNIQUE
• Ensures that no two rows have the same value in the column specified with this constraint
4. PRIMARY KEY
• Declares a column as the primary key
• Can be applied only to one column or a combination of columns
5. DEFAULT
• A default value can be set for a column, in case the user does not provide a value for that column of a
record
Example:
CREATE TABLE student
( admno INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(20) NOT NULL,
gender CHAR DEFAULT ‘M’,
dob DATE,
course VARCHAR(15),
fincom INT
);
Table constraints
• Similar to column constraints
• Applied on a group of columns of a table
Example:
CREATE TABLE stock
(
icode CHAR(2) PRIMARY KEY AUTO_INCREMENT,
iname VARCHAR(30) NOT NULL,
dt_purchase DATE,
rate DECIMAL(10,2),
qty INT,
UNIQUE (icode, iname)
);
Syntax:
DESCRIBE <table_name>;
OR
DESC <table_name>;
Example:
DESC student;
Operator Description
= Equal to
< > Or != Not equal to
> Greater than
< Less than
>= Grater than or equal to
<= Less than or equal to
NOT TRUE if the condition is false
AND TRUE if both condition are true
OR TRUE If either of the condition is true
Example:
SELECT * FROM student
WHERE gender=‘F’;
59
• The above query returns all female students data from the student table
SELECT name, course, fincome FROM students WHERE course =’science’ ORDER BY fincome DESC;
Aggregate Functions
• SUM( ) - Total of the values in the column specified as argument
• AVG( ) - Average of the values in the column specified as argument
• MIN( ) - Smallest values in the column specified as argument
• MAX( ) - Largest of the values in the column specified as arguments
• COUNT( ) - Number of non NULL values in the column specified as argument
Examples:
SELECT MAX(fincome), MIN(fincome), AVG(fincome) from student;
SELECT COUNT(*) from student;
Example:
SELECT course, COUNT(*) FROM student GROUP BY course;
• We can apply conditions here by using HAVING clause
Example:
SELECT course, COUNT(*) FROM student GROUP BY course HAVING course=’science’;
Examples:
UPDATE student SET fincome=27000 WHERE name=‘virat’;
• We can set expressions to column values
UPDATE student SET fincome=fincome+1000 WHERE name=“virat”;
Example:
ALTER TABLE student MODIFY regno INT UNIQUE;
Rename a table
We can rename a table in the database by using the clause RENAME TO along with ALTER TABLE
command
Syntax:
ALTER TABLE <table_name>
RENAME TO <new_table_name>;
Example:
ALTER TABLE student RENAME TO student123;
Example:
CREATE VIEW studentview AS SELECT name, course FROM student WHERE fincome<25000;
• Can use all the DML commands with the view
• Changes reflect in the base tables
• We can remove a view with DROP VIEW command
Example:
DROP VIEW studentview;
Sample Questions
1. In SQL, which is the keyword used to eliminate duplicate values in a column ?
2. Which DML command is used to retrieve information from specified column in a table
3. Write the name and use of any three column constraints in SQL
4. List and explain any three aggregate functions in SQL
5. Write any three DML Commands
6. Define the following
(a) DDL
(b) DML
64
(c) DCL
7. Consider the following table “Student” :
No. Name Mark Class
1 Kumar 430 COM
2 Salim 410 CS
3 Fida 520 BIO
4 Raju 480 COM
5 John 490 COM
6 Prakash 540 BIO
• Manufacturing Module:
This module provide freedom to change manufacturing and planing methods whenever
required.
• Production Planning Module
This module ensure the effective use of resources and help the enterprise to enhance the maximize
production and minimum loss.
• HR Module
This module ensures the effective use of human resources and human capital.
• Inventory Control Module:
This module manages the stock requirement of an organization.
• Purchasing Module:
This module is responsible for the availability of raw materials in the right time at the right price.
• Marketing Module:
It is used to handle the orders of customers.
• Sales and distribution Module:
This module will help to handle the sales enquirers,order placement and scheduling,dispatching and
invoicing.
• Quality Management Module:
This module help to maintain the quality of product. It deals with quality planning, inspection
and control.
Business Process Re-Engineering
• It is the series of activities such as rethinking and redesign of the process to enhance the enterprise's
performance such as reducing the cost ,improve the quality, prompt and speed service.
• Post implementation
Microsoft Dynamics :
• ERP for mid sized company.
• This ERP is user friendly.
• Provides Customer Relationship Management(CRM).
Tally ERP :
• Indian company located in Bangalore.
• Provide ERP solution for accounting,inventory and payroll.
Benefits of ERP
1. Improved resource utilization: - Installing ERP can reduce the wastage of resources and
resource utilization can be improved.
2. Better Customer Satisfaction:- Introduction of web based ERP, a customer can place orders and
make payments from home.
3. Provides Accurate Information:-Provide right information at the right time will help the
company to plan and manage the future cunningly.
4. Decision Making Capability:-Accurate and relevant information helps to make better decision for a
system.
67
5. Increased Flexibility: -ERP will help the company to adopt good things as well as avoid bad
things rapidly.
6. Information Integrity:-Integrate various departments in to single unit.
Risk of ERP
1. High cost
2.Time consuming
3. Requirement of additional trained staff.
4.Operational and maintenance issues
Sample Questions
1. ERP Stands for………………………
2. ………… module of ERP focus on human resource and human capital.
3. Give the significance of Marketing module in an ERP package.
4. Explain any three benefits of ERP system.
5. Explain functional units of ERP in detail.
6. Write short notes regarding ERP package companies.
7. Write short note about CRM?
8. Explain in detail the ERP packages and related technologies?
68
CHAPTER 11
3. Third Generation network(3G):- Allows high data transfer rate for mobile devices and offer
high speed wireless broadband services combining voice and data.
4. Fourth Generation network(4G):- It offers Ultra broadband Internet facility. Also offers good
quality image and videos.
5. Fifth Generation network(5G):- Next generation network. It is more faster and cost effective than
other four generations.
69
Information security
The most valuable to a company is their database it must be protected from the unauthorized access
by unauthorized persons.
Intellectual Property Right
Some people spends lots of money,time, body and mental power to create some products albums,
discoveries, inventions, software… these types of intellectual properties must be protected from unauthorized
access by law. This is called Intellectual Property Rights.
B) Copyright: It is the property right that arises automatically when a person creates a new work by
his own and by law it prevents the others from the unauthorized copying of this without the permission of the
creator ,for 60 years after the death of the authour.
Infringement(Violation)
• Patent Infringement: It prevents others from the unauthorized or intentional copying or use of
patents with out the permission of creator.
• Piracy: It is the unauthorized copying, distribution and use of creation with out the permission of
creator.
70
• Trademark Infringement: It prevents others from the unauthorized or intentional copying or use of
Trademark with out the permission of creator.
• Copy Right Infringement: It prevents others from the unauthorized or intentional copying or use of
Copy rights with out the permission of creator.
Cyber Crime
It defines as a criminal activity in which computer or computer network as a tool, target or a place
of criminal activity.
Infomania
71
It is the infatuation for acquiring knowledge from various modern sources like Internet, Email,Social
media,Whatsapp and smart phones. Due to this the person may neglect daily routine such as
family,friends,food,sleep etc. hence they get tired. They give first preference to Internet than others.
Sample Questions
1. ……………. is a standard way to send and receive message with multimedia content using
mobile phone.
2. A person committing crimes and illegal activities with the use of computer over Internet. this
crime is included as …………….crime.
3. Explain the features of Android OS?
4. Write short note on GPS?
5. Explain cyber crimes against individuals?
6. What is copy right? How does it differ from patent?
7. Explain different categories of cyber crimes in detail.
8. “Infomania has became a psychological problem” Write your opinion?
9. What you mean by infringement?
10. How do trademark and industrial design differ?
72