Thursday

CYBER SAFETY || Computer Science || Class 11

 

CYBER SAFETY

Short Answer Type Questions  Q.1  What is cyber safety?

Ans: Using internet with care and responsibility is called Cyber Safety so that we can keep our personal information safe.

Q.2  What should you do to protect your identity on Internet? 

Ans:  The things we can do to protect our identity on Internet.

                  Most common solution to this is Private browsing or Anonymous browsing.

                  Confidentiality of information.

                  Appropriate usage of social networking sites. Q.3  How do websites track you online?

Ans: Whenever you visit a website, your web browser may reveal your location via your device‘s IP address. 

o   It can also provide your search and browsing history etc. which may be used by third parties, like advertisers or criminals.

o   This way website track you. Tracking is generally used by advertising networks to build up details profiles for pinpoint adtargeting.  o This information is compiled through your web usage patterns, and which websites generally use for tracking you. This generally includes-

§  IP Address

§  Cookies and tracking scripts etc.

§  HTTP Referrer

§  Super Cookies

§  User Agent

Q.4  What are cookies? How are they used by websites to track you?

Ans:  cookies are small pieces of information websites can store in your browser. Cookies can be –  1. First Party Cookies- These are the cookies that store your own log in id, password, and auto fill information etc. 

2. Third Party Cookies: These are the cookies that websites store to know about your search history and web browsing history so as to place advertisements as per your interests.

Q.5  What is private browsing? Why is it considered a better way of browsing the Internet?

Ans:  àAnonymous browsers allow users to view websites without revealing personal information of user. 

àIt can be sued as a tool for governments, journalists and every security conscious surfers. 

àA popular solution to this is- Private Browsing. 

àIncognito browsing open up a version of the browser that will not track your activity.it is particularly useful if you are entering sensitive data like bank details into your browser. 

àProxy works as a middleman between your computer and the website you want to access. Now the tracking website will get the IP address of proxy site.

àVirtual Private Network (VPN) this is a method to add security and privacy to private and public networks, like WiFi hotspots and Internet. It is originally meant for business employees working offsite to gain access to shared drives or networks.

 

Q.6  What is confidentiality of information? How do you ensure it?

Ans:   

 

 

 

 

 

 

 

 

 

 

 

 

 

Q.7  What is cyber-crime? How can you report it?

Ans:   

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Q.8            What is cyber bullying and cyber stalking?

Ans: Cyber stalking is the use of the Internet or other electronic means to stalk or harass an individual, group, or organization. It may include false accusations, defamation, slander and libel. It may also include monitoring, identity theft, threats, vandalism, solicitation for sex, or gathering information that may be used to threaten, embarrass or harass.

 Cyber bullying or cyber harassment is a form of bullying or harassment using electronic means. Cyber bullying and cyber harassment are also known as online bullying. It has become increasingly common, especially among teenagers. Cyber bullying is when someone, typically teens, bully or harass others on social media sites. Harmful bullying behavior can include posting rumors, threats, sexual remarks, a victims' personal information, or pejorative labels (i.e., hate speech). Bullying or harassment can be identified by repeated behavior and an intent

to harm. Victims may have lower self-esteem, increased suicidal ideation, and a variety of emotional responses, including being scared, frustrated, angry, and depressed.  Q.9 What is identity fraud?

Ans: Identity fraud is the use by one person of another person's personal information, without authorization, to commit a crime or to deceive or defraud that other person or a third person. Q.10 What is digital footprint? Why is it so important?

Ans: A digital footprint is a trail of data you create while using the Internet. It includes the websites you visit, emails you send, and information you submit to online services. A "passive digital footprint" is a data trail you unintentionally leave online.

It is not a matter of gathering one person‘s online activity. The main concern is what the

person is doing. If he or she is going to a dark path then the online activity is the first thing that will provide a glimpse of it. The matter is serious and digital footprint is going to provide the fullest information on it. Apart from gathering information the digital footprint provides knowledge on what the person likes and how well the orientation of his mind is. If you find that your friend and beloved family member is posting something obnoxious and disgraceful in a continuous manner then you can stop him from going to the dark path. In this technical society a digital footprint can give you full information of what the person is thinking. Regardless of all thoughts of getting diverted from the prime goal, one person should keep a track of all the information of his online activity. Nowadays, when technology has become too much available and influencing all the activities in a regular manner, keeping it at a side and thinking without the influence of it has become impossible that is why analysis of your digital footprint is highly necessary. This will provide you valuable information on what you are doing and what should be avoided by you.

Q.11 Why are privacy settings of a social networking site so important?

Ans: Privacy settings, present in most of the major social networking sites can be used by the user to

adjust the visibility of their profile or of certain information on the profile. As a result, this could eliminate a certain amount of unwanted disclosures and upgrade the level of privacy of the profile.

Q.12 What are the usage rules for effective use of social networking sites?

o   Social media is everywhere these days, from personal to professional front. Social media has made it too difficult to remain entirely anonymous these days. 

o   Whatever you do online, leaves a permanent foot print, called digital foot print.

o   Once posted these becomes part of public domain and hence are visible to anyone who looks for it. 

o   Thus appropriate usage of Social media is very important and you must be aware that it may pose problems later if not used appropriately.

o   You should conduct yourself in a responsible way so that you can enjoy using it. 

o   Be Authentic.

o   Use a Disclaimer.

o   Don‘t pick fights Online.

o   Don‘t use fake names or pseudonyms. o Protect your identity. o Always take publicity test when post something. o Respect your audience. o Respect other's sentiments.

o   Monitor comments.

Q.13 Raman wanted to gift his brother a football or a wrist watch. So he searched for many sports items and wrist watches online. But after that every time he goes online, his webbrowser shows him advertisements about sports items and wrist watches.

(a)  Why is this happening?

(b)  How could have Raman avoided them?

(c)  How can Raman get rid of this now?

Ans: (a) This is happening because third party cookies saved his search preferences and now websites are posting advertisements based on his preferences.

(b) Robin could have avoided this by privately browsing i.e. opening the web browser in incognito mode before searching for such things.

(c) Now Robin can delete all the previous history and cookies stored on his computer. This would stop websites posting advertisements.

Tuesday

TABLE JOINS AND INDEXES IN SQL || MYSQL || CBSE

 

TABLE JOINS AND INDEXES IN SQL

Short Answer Type Questions 

Consider the following tables and give the commands based on the asked queries from Q1. To Q.4.

 

Q.1     Find out the Cartesian product of the table Orders and Parts.

Ans: SELECT * FROM Orders, Parts;

Q.2 What will be the equijoin of the Orders and Parts?

Ans: SELECT ord.orderdon,ord.name,ord.partnum,pr.partnum,description FROM orders ord, parts pr

WHERE ord.partnum=pr.partnum;

Q.3    Determine the total order amount for part1 „Road Bike‟.

Ans: SELECT SUM(ord.quantity*pr.price) ‗Total Amount‘ FROM orders ord, parts prWHERE ord.partnum=pr.partnum AND pr.description=‘Road Bike‘;

Q.4          Find out the order details of parts having description like „Road. . . . . .‟

Ans: SELECT * FROM orders WHERE prtnum = (SELECT partnum FROM parts WHERE description

LIKE ‗Road%‘;

Q.5     Given two tables – 

                                      Employee           PayTable

employee_id employee_id last_name salary first_name department

                                      middle_name supervisor 

marital_status

Find out the salary taken by all KUMAR, i.e. all those who have their last_name as

„KUMAR‟

Ans: SELECT e.employee_id, e.last_name, ep.salary FROM employee e, PayTable ep WHERE

e.employee_id=ep.employee_id AND e.last_name=‘KUMAR‘;

Q.6     A table FLIGHT has 4 rows and 2 columns and another table AIR HOSTESS has 3 rows and 4 columns. How many rows and columns will be there if we obtain the Cartesian product of these two tables?

Ans: 12 rows and 6 rows 

Q.7     Table Employee has 4 records ad Table Dept has 3 records in it. Mr. Jain wants to display all information stored in both of these related tables. He forgot to specify equi-join condition in the query. How many rows will get displayed on execution of this query?

Ans: 12 Rows (4 X 3)

Q.8  What are table joins?

Ans: An SQL join clause      - corresponding          to       a join operation in       relational       algebra - combines columns from one or more tables in a relational database. It creates a set that can be saved as a table or used as it is. A JOIN is a means for combining columns from one (self-join) or more tables by using values common to each. ANSI-standard SQL specifies five types of JOIN: INNER, LEFT OUTER, RIGHT OUTER, FULL OUTER and CROSS. As a special case, a table (base table, view, or joined table) can JOIN to itself in a self-join. Q.9 Name some types of joins that you can create on tables. Ans: (i)            Equi Join 

              (iii)      Non-Equi-Join

(iii)        Natural Join

(iv)       Cross Join

(v)        Left, Right Joins

Q.10    What are table Indexes? How are they useful?

Ans: Table index is a kind of data structure which is used to fetch the data from database very fast. An index keeps the location in index field in actual table, in ordered form. This is also a table which stores the location of records within it. 

Indexes are used to make the search fast. Queries work with indexes very efficiently. Indexes are very much helpful in sorting. Index guaranties in uniquely identifying the records in the databases.

Q.11    What are the advantages and disadvantages of table-indexes?

Ans: Advantages:

(i)          Indexes are used to make the search fast.

(ii)         Queries work with indexes very efficiently

(iii)        Indexes are very much helpful in sorting

(iv)       Index guaranties in uniquely identifying the records in the databases.

           Disadvantages:

(i)           The capability of insert, update and delete command reduces. As the index table‘s updating is an overburden. 

(ii)          It consumes more memory.

Q.12    What is database index? Is it a table?

Ans: Table index is a kind of data structure which is used to fetch the data from database very fast. An index keeps the location in index field in actual table, in ordered form. This is also a table which stores the location of records within it. 

Q.13    How many ways can you create index in?

Ans: There are two ways to create index  -  (i) At the time of table creation.

              (ii)               Creating an index on already existing table. 

Q.14 Why is it said that indexes should be created when needed?

Ans: (i) The capability of insert, update and delete command reduces. As the index table‘s updating is an overburden. 

(ii) It consumes more memory. That‘s why it is said that when there is a need then create the ndex.

Q.15 How is a left join different from natural join? Give example.

Ans: A NATURAL JOIN is a JOIN operation that creates an implicit join clause for you based on the common columns in the two tables being joined. Common columns are columns that have the same name in both tables. A NATURAL JOIN can be an INNERjoin, a LEFT OUTER join, or a RIGHT OUTER join. The default is INNER join.And the LEFT JOIN keyword returns all records from the left table (table1), and the matched records from the right table (table2). The result is NULL from the right side, if there is no match.

Q.16 How is a cross join different from natural join? Give example.

Ans: A NATURAL JOIN is a JOIN operation that creates an implicit join clause for you based on the common columns in the two tables being joined. Common columns are columns that have the same name in both tables. A NATURAL JOIN can be an INNERjoin, a LEFT OUTER join, or a RIGHT OUTER join. The default is INNER join.

 The SQL CROSS JOIN produces a result set which is the number of rows in the first table multiplied by the number of rows in the second table if no WHERE clause is used along

with CROSS JOIN.This kind of result is called as Cartesian Product. If WHERE clause is used with CROSS JOIN, it functions like an INNERJOIN

Q.17 

 

 

Ans: (i) mysql>SELECT * FROM Product WHERE Price between 40 and 120;

(ii)   mysql> SELECT c.ClietnName, c.City, p.ProductName, p.Price FROM Product p, Client c 

                                        WHERE p.P_ID=c.P_ID;

(iii)  mysql> UPDATE Product set Price=Price+20;

Friday

TABLE CREATION AND DATA MANIPULATION COMMANDS || MYSQL || CBSE

 TABLE CREATION AND DATA MANIPULATION COMMANDS

Short Answer Type Questions 

Q.1     Using SQL statements in MySQL, create the tables identified bellow in the following order.

           Database Name: Univ. 

       Create database if needed. (Underlined Columns depict primary key)

           Campus   (CampusID, CampusName, Street, City, State, Pin, Phone, 

CampusDiscount)

           Position            (PositionID, Position, YearlyMembershipFee)

           Members        (MemberID, Lastname, FirstName, CampusAddress, CampusPhone, 

CampusID,  PositionID, ContractDuration)

           Foreign Keys                   CampusID à Campus(CampusID)

                                                       PositionID àPosition(PositionID)

Ans: mysql>CREATE DATABASE Univ;   mysql>USE Univ;

        mysql>CREATE TABLE Campus(CampusID VARCHAR(5) PRIMARY KEY,

                                                    CampusName VARCHAR(20),

                                                           Street VARCHAR(20),

                                                              City VARCHAR(20),

                                                            State VARCHAR(15),

                                                    Pin INT(6),

                                                           Phone VARCHAR(13),

                                                    CampusDiscount INT(2));

        mysql>CREATE TABLE Position (PositionID VARCHAR(4) PRIMARY KEY,

                                                         Position VARCHAR(10),

                                                    YearlyMemberShipFee INT(4));

      mysql>CREATE TABLE Members (MemberID VARCHAR(5) PRIMARY KEY,

                                                      LastName VARCHAR(15),

                                                     FirstName VARCHAR(15),

                                                    CampuAddress VARCHAR(30),

                                                    CampusPhone VARCHAR(13),

                                                    CAMPUSID VARCHAR(5) REFERENCES Campus(CampusID),

                                                     PositionID VARCHAR(4) REFERENCES Position(PositionID),

                                                    ContractDuration INT(2));

Q.2     Write SQL commands to perform the following tasks –   (a)  Create table Employee with the following structure:

Name of

Column

ID

First_Name

Last_Name

User_ID

Salary

Type

Number(4)

Varchar(30)

Varchar(30)

Varchar(10)

Number(9,2)

            Ensure the following specification in created table:

 ID should be declared as Primary Key

 User_ID shold be unique

 Salary Must be greater than 5000

 First_Name and Lst_Name must not remain Blank

Ans: mysql>CREATE TABLE Employee (ID NUMBER(4) PRIMARY KEY,

                                                    First_Name VARCHAR(30) NOT NULL,

                                                    Last_Name VARCHAR(30) NOT NULL,

                                                        User_ID VARCHAR(10) UNIQUE,

                                                          Salary NUMBER(9,2));         

              (b)        Create another table Job with following specification:

Name of Column                                Type Job_ID                                        Number(4)

                    Job_des                                                                     Varchar(30)

                     Alloc_on                                                                          Date

                    Due_on                                                                           Date

                     Emp_id                                                                      Number(4)

Ensure the following specification in created table:

 Job_ID should be declared as Primary Key

 Job_des, Alloc_on, Due_on cannot be left blank

 Emp_id is foreign key here that us related to ID column of earlier created table Employee.

Ans: mysql>CREATE TABLE Job (Job_ID NUMBER(4) PRIMARY KEY,

                                                        Job_des VARCHAR(30) NOT NULL,

                                               Alloc_on DATE NOT NULL,

                                          Due_on DATE NOT NULL,

                                                        Emp_id NUMBER(4) REFERENCES Employee(ID));

(a)  Show the structure of the table employee.

Ans: mysql>DESC Employee;

(b)  Show the structure of the table job.

Ans: mysql>DESC Job;

(c)  Insert 10 records into the table employee as well as Job.

Ans: mysql> INSERT INTO Employee VALUES(1,  ‗Amit‘, ‘Kumar‘, ‘E1001‘,20000);  Same remaining 9 values can be inserted into Employee Table.

 mysql> INSERT INTO Job VALUES(1001,  ‗Manager‘, ‘12-25-2016‘, ‘12-28-2017‘, 1);  Same remaining 9 values can be inserted into Job Table.  

(d)  For record with ID 4 update record with Last_Name, User_ID and Salary. Ans:  mysql>UPDATE Employee SET Last_Name=‘Singh‘  WHERE ID=4;    mysql>UPDATE Employee SET Salary=25000  WHERE ID=4;    mysql>UPDATE Employee SET User_ID=‘E1004‘  WHERE ID=4; (e)  Make the changes permanent.

Ans: mysql>COMMIT

(f)  Modify the salary and increase it by 1000, for all who get salary less than 6000.

Ans: mysql>UPDATE Employee SET Salary = Salary+1000 WHERE Salary<6000; (g) Add one new column in table Employee named „Phone‟. Ans: mysql>ALTER TABLE Employee ADD(Phone VARCHAR(13)); (h)Provide the phone numbers to all the employees.

Ans: mysql>INSERT INTO Employee (Phone) VALUES(‗+918888888888‘);             Same remaining 9 values can be inserted into Employee Table.

(i) Delete the Employee record having First_Name as Manish. Ans: mysql>DELETE FROM Employee WHERE First_Name=‘Manish‘; (j) Remove employee table permanently. 

Ans: mysql>DROP TABLE Employee;

(k) Count the total records in the table employee.

Ans: mysql>SELECT Count(*) FROM Employee;

Q.3     What are the different divisions of SQL and commands? Give examples. Ans: SQL commands can be divided into following categories – 

(i)          Data Definition Language (DDL) Commands. e.g. CREATE TABLE, ALTER TABLE, DROP TABLE etc.

(ii)         Data Manipulation Language (DML) Commands. e.g. INSERT INTO, DELETE FROM, UPDATE, SELECT etc.

(iii)        Transaction Control Language (TCL) Commands.e.g. ROLLBACK, COMMIT, SAVEPOINT

etc.

Q.4            What is foreign key? How do you define a foreign key in your table?

Ans: A foreign key is a column or group of columns in a relational database table that provides a link between data in two tables. It acts as a cross-reference between tables because it references the primary key of another table, thereby establishing a link between them.

           To define a foreign key in a table we have to use REFERENCES keyword as follows  -   mysql>CREATE TABLE Job (Job_ID NUMBER(4) PRIMARY KEY,

                                                        Job_des VARCHAR(30) NOT NULL,

                                               Alloc_on DATE NOT NULL,

                                          Due_on DATE NOT NULL,

                                                       Emp_id NUMBER(4) REFERENCES Employee(ID));

          In the above example Emp_id is a foreign key which references the ID field of table Employee. Q.5          How foreign key command is different from Primary Key command?

Ans: A primary key is a special key in a relational database that acts as a unique identifier for each record meaning it uniquely identifies each row/record in a table and its value should be unique for each row of the table. A foreign key, on the other hand, is a field in one table that link two tables together. It refers to a column or a group of columns that uniquely identifies a row of another table or same table. 

A primary key is a combination of UNIQUE and Not Null constraints so no duplicate values can be allowed to have in a primary key field in a relational database table. No two rows are allowed to carry duplicate values for a primary key attribute. Unlike a primary key, foreign key can contain duplicate values and a table in a relational database can contain more than foreign key. Q.6 How is Foreign Key commands related to Primary Key?

Ans: A foreign key refers to a field or a collection of fields in a database record that uniquely identifies a key field of another database record in some other table. In simple terms, it establishes a link between records in two different tables in a database. It can be a column in a table that points to the primary key columns meaning a foreign key defined in a table refers to the primary key of some other table. References are crucial in relational databases to establish links between records which is essential for sorting databases. Foreign keys play an important role in relational database normalization especially when tables need to access other tables. Q.7 How do you enforce business rules on a database?

Ans: We can enforce Business Rules in Relational Databases Using Constraints. Constraints are restrictions over a column. Or we can say that constraint is a check or condition applicable on a field or set of fields. These are of following types – 

(i)                  Unique

(ii)                 Primary Key

(iii)               Default

(iv)               Check

(v)                 Foreign Key

Q.8       What are table constraints? What are column constraints? How these two are different?

Ans: Table constraints apply to groups of one or more columns whereas column constraints apply

only to Individual column. 

Q.9       What is default value? How do you define it? What is the default value of column for which no default value is defined?

Ans: A default value can be specified for a column using DEFAULT clause. When a user does not enter a value for the column (having default value), automatically the defined default value is inserted in the field. e.g.

                 mysql>CREATE TABLE Employee (ID NUMBER(4) PRIMARY KEY,

                                                    First_Name VARCHAR(30) NOT NULL,

                                                    Last_Name VARCHAR(30) NOT NULL,

                                                        User_ID VARCHAR(10) UNIQUE,

                                                         Salary NUMBER(9,2) DEFAULT 15000);

Q.10    Differentiate between  - 

(i)   DROP TABLE, DROP DATABASE

(ii)  DROP TABLE, DROP clause of ALTER TABLE.

Ans: (i) DROP TABLE will delete a table whereas DROP DATABASE will delete a complete database which will contain different tables. These are DDL commands. Q.11 How will you enlist the name of tables in a database?

Ams: By using SHOW TABLES command. e.g.  mysql>SHOW TABLES;

Q.12    How to view the structures of the table made by you?

Ans: By using DESC <TableName> command. e.g.

          mysql>DESC Employee;

Q.13    How to Drop Table and Databases?

Ans: By using DROP TABLE command. e.g.

          mysql>DROP TABLE Employee;