Saturday, 28 August 2021

*Episode 1* MCQ for Govt. Job/ Private Job/ MNCs

 Topic:- One Word Substitution


1) Especially skilled in storytelling 

Answer:- Raconteur


2) Fear of loneliness

Answer:- Eremophobia 


3) Usage of an incorrect word in place of the one which is similar in pronunciation 

Answer:- Malapropism 


4) The fear of not doing something right or the fear of not being good enough 

Answer:- Atelophobia 


5) The fear of sleep cliffs 

Answer:- Cremnophobia 


6) The fear of Shadows 

Answer:- Sciophobia 


7) Represent something as being less important than it really is 

Answer:- Underplay


8) The common people, Commoner 

Answer:- Plebeian


9) A nominal leader with no real power 

Answer:- Figurehead


10) Mania for making purchases 

Answer:-  Oniomania 


11) Mania for names 

Answer:- Onomamania 


12) Irresistible desire to repeat certain words 

Answer:- Onomatomania 


13) Craving for opium

Answer:- Opiomania 


14) Fear of dust 

Answer:- Amathophobia 


15) Fear of riding in a car

Answer:- Amaxophobia 


16) Fear of insanity 

Answer:- Agateophobia 


17) Fear of walking 

Answer:- Ambulophobia 


18) Boringly monotonous

Answer:- Humdrum


19) Having or giving off an odour

Answer:- Odorous


20) A brave, noble-minded or chivalrous man 

Answer:- Gallant


21) Strong and healthy, vigorous 

Answer:-Robust


22) Doing something dangerous and not worrying about the risks and the possible results 

Answer:- Reckless



👉










Friday, 30 July 2021

*Episode 3* MySQL (T) [ The SQL Structure ]

 


The SQL Structure


     In this episode you will learn the fundamental features of the SQL language and an overview of its programming aspect. In addition, you will be presented with a step-by-step instruction on where and how to download SQLite, a version of the SQL software that will be used all throughout the discussion of this e- Book.

 

SQL Fundamental Features :-


    SQL is a flexible computer language that you can deploy in different ways to communicate with relational databases. This software has some distinct features that differentiates it from other programming applications. First and foremost, SQL is a nonprocedural language. Most computer programs (e.g., C, C++ and Java) solve problems by following a sequence of commands that is called a procedure. In this case, one specific operation is performed after another until the required task has been accomplished. The flow of operation can either be a linear sequence or a looping one, depending on what the programmer had specified. This is not the same for SQL. In using this application, you will just have to specify the output that you want, not how you want to generate the output. From the CUSTOMER TABLE, if you want to create a separate list of contacts whose company are located in Texas then you have to retrieve the rows where the STATE column contains “TX” as its value. In writing the SQL command, you don’t have to indicate how the information should be retrieved. It is the primary role of the database management system to examine the database and decide how to generate the results you wanted.


     Learning the SQL syntax is like understanding the English language structure. Its command language, comprised of a limited number of statements, performs three primary data functions - definition, manipulation and control. The SQL programming language also includes reserved words that are only to be used for specific purposes. Thus, you cannot use these words as names for variables, tables and columns; or in any other way apart from their intended use.


     Below are some of the most common reserved words in SQL:2011.


ABS ALL ALLOCATE ALTER AND ANY
ARE ARRAY AS AT AVG BEGIN
BETWEEN BINARY BOOLEAN BOTH BY CALL
CASCADED CASE CEILING CHAR CHARACTER CHECK
CLOSE COLLETTE COLLECT COLUMN COMMIT CONDITION
CONNECT CONSTRAINT CONVERT COUNT CREATE CURSOR
CYCLE DATE DAY DEALLOCATE DEC DECIMAL
DECLARE DEFAULT DELETE DESCRIBE DISCONNECT DISTINCT
DOUBLE DROP DYNAMIC EACH ELEMENT ELSE
END ESCAPE EVERY EXCEPT EXECUTE EXIST
EXTERNAL EXTRACT FALSE FETCH FILTER FLOAT
FLOOR FOR FOREVER FREE FROM FULL
FUNCTION FUSION GET GLOBAL GRANT GROUP
GROUPING HAVING HOLD HOUR HOURS IDENTITY
IN INNER INOUT INSERT INT INTEGER
INTERSECT INTERVAL INTO IS JOIN KEEP
LANGUAGE LARGE LEAD LEFT LIKE LOCAL
LOWER MATCH MAX MEMBER MERGE METHOD
MINUTE MOD MODULE MONTH MULTISET NATIONAL
NATURAL NEW NILL NO NONE NORMALIZE
NOT NULL NUMERIC OF OFFSET OLD
ON ONLY OPEN OR ORDER OUT
OVER OVERLAY PARAMETER PARTITION POSITION POWER
PRECISION PREPARE PRIMARY PROCEDURE RANGE RANK
REAL RECURSIVE REF REFERENCES REFERENCING RELEASE
RESULT RETURN REVOKE RIGHT ROLLBACK ROLLUP
ROW ROWS SCOPE SCROLL SEARCH SECOND
SELECT SET SIMILAR SOME SPECIFIC SQL
START STATIC SUM SYMMETRIC SYSTEM TABLE
THEN TIME TIMESPANT TO TRANSLATE TREAT
TRIGGER TRUNCATE TRIM TRUE UNION UNIQUE
UNKNOWN UPDATE UPPER USER USING VALUE
VALUE VARCHAR VARYING VERSION WHEN WHENEVER
WHERE WINDOW WITH WITHIN WITHOUT YEAR


     If you think that an SQL database is just a collection of tables, then you are wrong. There are additional structures that need to be specified to maintain the integrity of your data, such as schemas, domains and constraints.


  • Schema – This is also called the conceptual view or the complete logical view that defines the entire database structure and provides overall table organization. Such schema is considered a metadata – stored in tables and part of the database (just like tables that consist of regular data).
  • Domain – This specifies the set of all finite data values you can store in a particular table column or attribute. For example, in our previous CUSTOMER TABLE the STATE column can only contain the values “TX”, “NY”, “CA” and “NV” if you only provide products and services in the states of Texas, New York, California and Nevada respectively. So these four state abbreviations are the domain of the STATE attribute.
  • Constraint – Often ignored but one of the important database components, this sets down the rules that identify what data values a specific table attribute can contain. Incorporating tight constraints assures that database users only enter valid data into a particular column. Together with defined table characteristics, column constraints determine its domain. Using the same STATE column as an example with the given constraint of only the four values, if a database user enters “NJ” for New Jersey, then the entry will not be accepted. The system will not proceed until a valid value is entered for the STATE attribute, unless the database structure needs to be updated due to sudden business changes.

 
SQL Command Types :-

     Before you start programming in SQL, you need to understand its basic command categories in performing various functions – database creation, object manipulation, data population and update, data deletion, query submission, access control and database administration, among others. The following are the main categories:

    Data Definition Language (DDL) :-

           Data Definition Language (or simply DDL) enables you to create, change or restructure, and even destroy the basic elements that are contained in a relational database. DDL focuses only on the structure, not the data contained within the elements. These basic elements or data objects include tables, schemas, views and more. Having no independent physical existence, a view is regarded as a virtual table in which its definition only exists in the metadata. However, the view’s data comes from the table (or tables) where you will derive the view. Stated below are some of the most common DDL commands:

      • CREATE – This command statement is responsible for building the database structure. Its syntax is:

      CREATE TABLE

      CREATE VIEW


      • ALTER – This command statement is in charge of changing the database structure after it has been created. Its syntax is:

      ALTER TABLE

      ALTER VIEW


      • DROP – This command is the reverse of the CREATE statement, which destroys the database structure. Its syntax is:

      DROP TABLE

      DROP VIEW


      Data Manipulation Language (DML) :-


           Data Manipulation Language (or simply DML) consists of SQL commands that handle data maintenance functions. This means that you are able to manipulate the data contained within the relational database objects. The command statements, which read like normal English sentences, will allow you to enter, change, remove or retrieve data. The following are the DML statements commonly used:


      • INSERT – This command statement is used to insert new data values into a certain table. To add values into a table with two columns, use the following syntax:

      INSERT INTO TABLE_NAME

      VALUES (‘value1’, ‘value2’);


      TABLE_NAME is the name of the table where you will be adding the new values. The number of items inside the VALUES parenthesis represents the number of columns of the table, which are arranged in the same order as the said columns. If the values are of character or date/time data types, they need to be enclosed by single quotation marks. This is not required for numeric or null values (the null value should be written as NULL).


      • UPDATE – This command statement is used to modify or alter pre-existing data values in a table, not add or remove records. The update is done one table at a time or multiple rows/columns of one table within a database. To change a single column, use the following syntax:

      UPDATE TABLE_NAME

      SET COLUMN_NAME = ‘value’

      [WHERE CONDITION]; 


      As long as the given WHERE clause is satisfied, then the value of the COLUMN_NAME will be updated. This could be within one or multiple records of the given TABLE_NAME.


      • DELETE – This command statement deletes certain records or even the entire table, not data values from specific columns. To remove a single row or multiple records from a table, use the following syntax:

      DELETE FROM TABLE_NAME

      [WHERE CONDITION]; 


      The WHERE clause is an important part of this command if you want to delete selected rows from the TABLE_NAME.


      Data Query Language (DQL) :-


           Data Query Language (or simply DQL) consists of commands that perform data selection, which is the main focus of relational database users in the world of SQL. The statement used is SELECT that can be accompanied by other clauses or options so that your extracted results will be in an organized and readable format. You can submit a query to the database using a separate application interface or just a single command-line. The following is a syntax for a simple SELECT statement:


      SELECT [* | ALL | DISTINCT COLUMN1, COLUMN2]

      FROM TABLE1 [, TABLE2]; 


      Using the asterisk (*) means that all columns of the given table are included in the output and will be displayed. The ALL option extracts and displays all values, even duplicates, for a column. On the other hand, using the keyword DISTINCT prevents duplicate rows from being included and displayed in the output. What follows the FROM keyword is a list of one or more tables where you want to get the data. The columns and tables specified in the syntax are all separated by commas.


      Data Control Language (DCL) :-


           Data Control Language (or simply DCL) consists of commands that allow you to manage data access within the database. Furthermore, the database is protected from accidental or intentional misuse by controlling user privileges. DCL concentrates on transactions, which capture all SQL statements that perform database operations and save them in a log file. The following are the common DCL command statements:


      • GRANT – This statement provides you with certain privileges, like giving you the permission to access the database. Its syntax is:

      GRANT PRIVILEGE1, PRIVILEGE2, … TO

       USER_NAME


      • REVOKE – This statement revokes your privileges, like removing your permission to access the database. Its syntax is:

      REVOKE PRIVILEGE1, PRIVILEGE2, … TO

      USER_NAME


      Transactional Control Commands :-


           Transactional control commands allow users to manipulate various transactions in maintaining database integrity. In SQL, transactions begin when applications are executed. The very first transaction is started at the onset of the SQL application, while the last transaction is ended when the application is terminated. The following are the common transactional control commands:


      • COMMIT – This statement completes a transaction by making the changes you made to the database permanent, or simply saving the transactions. Its syntax is:

      COMMIT [WORK]; 


      In the previous command line, the keyword WORK is optional.


      • ROLLBACK – This statement’s primary function is to restore the database system to its previous state or undo all the actions that took place in the transaction log. Its syntax is:

      ROLLBACK [WORK]; 


      In the previous command line, the keyword WORK is optional.


      • SAVEPOINT – This statement works with the ROLLBACK command, wherein it creates sections or points within groups of transactions in which you will be performing the ROLLBACK command. Its syntax is:

      SAVEPOINT SAVEPOINT_NAME;


      SQLite Installation Instructions and Database Features Before you start overwhelming yourself with various database solutions and SQL command lines, you need to determine first your purpose why you are creating a database. This will further determine other database design considerations such as size, complexity, type of machine where the application will run, storage medium and more. When you start thinking of your database requirements, you need to know up to what level of detail should be considered in your design. Too much detail will result to a very complex design that further wastes time and effort, and even your computer’s storage space. Too little will lead to a poor performing, corrupt and worthless database. Once you are done with the design phase, then you can decide which database software you can download to start your SQL experience.


           For the sake of this e-Book’s discussion, SQLite, a simple software library, will be used as a starter database engine to design, build and deploy applications. A free and stand-alone database software that is quick to download and easy to administer, SQLite was developed by Richard Hipp and his team of programmers. It is was designed so that it can be easily configured and implemented, which does not require any client-server setup at all. Thus, SQLite is considered as one of the most widely used database software applications in the world.


           Stated below are some of the major features of SQLite:


      • Transactions are atomic, consistent, isolated and durable.
      • Compilation is simple and easy.
      • System crashes and power failures are supported.
      • Full SQL implementation with a stand-alone command-line interface client.
      • Code footprint is significantly small.
      • Adaptable and adjustable to larger projects.
      • Self-contained with no external dependencies.
      • Portable and supports other platforms like Windows, Android, iOS, Mac, Solaris and more.

           In using SQLite, you need to download SQLiteStudio as your database manager and editor. With its intuitive interface, this software is very light yet fast and powerful. You don’t even need to install it, just download, unpack and run the application. Follow these simple steps in downloading SQLiteStudio on a Windows 10 computer:


           1.) Go to http://sqlitestudio.pl/?act=about. You should get the following page:



           2.) Check the version of your computer’s operating system then click the appropriate link to start downloading the software.



           3.) After downloading the software, go to the folder where the application was saved (usually the Downloads Folder in Windows). Click on the Extract tab on top then choose the Extract all option.



           4.) You will get the Extract Compressed (Zipped) Folders dialog box. Change the destination folder to C:\SQL then click the Extract button. This will be the folder where all your SQLite files will be saved.



           5.) Once all the files have been extracted, you will have the SQLiteStudio subfolder.



            6.) Find the application program named SQLiteStudio inside the subfolder. To create a shortcut on your desktop (so you can quickly launch the application), right-click the filename, select Send to option then choose Desktop (create shortcut).



           7.) When you double-click the SQLiteStudio icon on your desktop,



           8.) you should get the following screen:



            The Database Navigator (left pane) shows all the logical units of the database such as tables and views. The gray pane at the right is the SQL Work Area where you will write your query statements. You will have a better understanding of this program’s graphical user interface in the succeeding episode.


            In this episode you have learnt the fundamental features of the SQL database language, which includes program flow, syntax characteristic, reserved words list, schema, domain, constraint and more. The main categories of SQL commands were also introduced, that govern the various functions of the programming language. You were also given a guide on how to download and install SQLite and SQLiteStudio for your application software. 


      👈Episode 2(MT)

      Share This Post

      *Episode 2* MySQL(P) [ SQL Command Syntax ]

       


      Introduction to SQL command syntax


           In this episode we will start working with SQL, a special-purpose programming language used for managing data held in MySQL. We will show you the SQL syntax and some basic commands: how to create a database, how to create a table, and how to create a user.


      SQL commands syntax


           MySQL uses a standard form of the well-known SQL data language. The great thing about SQL is that the code is very easy to read, as opposed to harder programming languages, such as C or C++. SQL statements are made up of plain English terms. These terms are called keywords, and every SQL statement is made up of one or more keywords. The SQL statement that you’ll probably use most frequently is the SELECT statement, for example:


      SELECT * FROM customers;


           All SQL commands and keywords are case-insensitive. However, most people write SQL commands (such as SELECT, FROM, LIMIT, etc.) in uppercase.


           To separate or to end SQL commands, the semicolon is used. This allows you to issue more than one command at a time by placing a semicolon after each command:


      mysql> USE employees; SELECT * FROM employees LIMIT 10;


      Database changed

      +––—+––––+––––+–––—+––—+––––+

      | emp_no | birth_date | first_name | last_name | gender | hire_date |

      +––—+––––+––––+–––—+––—+––––+

      | 10001 | 1953-09-02 | Georgi | Facello | M | 1986-06-26 |

      | 10002 | 1964-06-02 | Bezalel | Simmel | F | 1985-11-21 |

      | 10003 | 1959-12-03 | Parto | Bamford | M | 1986-08-28 |

      | 10004 | 1954-05-01 | Chirstian | Koblick | M | 1986-12-01 |

      | 10005 | 1955-01-21 | Kyoichi | Maliniak | M | 1989-09-12 |

      | 10006 | 1953-04-20 | Anneke | Preusig | F | 1989-06-02 |

      | 10007 | 1957-05-23 | Tzvetan | Zielinski | F | 1989-02-10 |

      | 10008 | 1958-02-19 | Saniya | Kalloufi | M | 1994-09-15 |

      | 10009 | 1952-04-19 | Sumant | Peac | F | 1985-02-18 |

      | 10010 | 1963-06-01 | Duangkaew | Piveteau | F | 1989-08-24 |

      +––—+––––+––––+–––—+––—+––––+

      10 rows in set (0.00 sec)


         {NOTE - table names are case-insensitive on Windows, but case-sensitive on Linux and OS X. It is recommended to use lowercase characters for tables.}


      Create a database


           To create an MySQL database, the CREATE DATABASE name statement is used. For example, to create a database named testdb, we can use the following command:


      mysql> CREATE DATABASE testdb;


      Query OK, 1 row affected (0.01 sec)


           We got the message indicating that our query was OK and the time it took to complete the command. We should see our new database in the output of the SHOW databases command:


      mysql> SHOW databases;


      +––––––—+

      | Database |

      +––––––—+

      | information_schema |

      | employees |

      | mysql |

      | performance_schema |

      | sakila |

      | sys |

      | testdb |

      | world |

      +––––––—+

      8 rows in set (0.00 sec)


           To work with our new database, we need to issue the USE testdb command:


      mysql> USE testdb;


      Database changed


      Create a user


           You should not do all your work in MySQL with the root user; instead, it is recommended to create users with custom permissions. To create a user, the CREATE USER ‘user’@‘hostname’IDENTIFIED BY ‘password’ command is used. Here is an example:


      mysql> CREATE USER ‘testuser’@‘localhost’ IDENTIFIED BY ‘verysecret’;


      Query OK, 0 rows affected (0.00 sec)


           The command above creates a new user called testuser with the password of verysecret (localhost refers to the local computer MySQL is running on).


           When the user is created, it has no permissions to do anything with the databases. The GRANT command is used to grant privileges. Here is the syntax:


      GRANT PRIVILEGES ON database.object TO ‘username’@‘hostname’ IDENTIFIED BY ‘password’


           The database.object keywords refer to the database itself and the objects it contains (e.g. tables). Here are some values of these keywords and their meaning:


      • *.* - all databases and all their objects.
      • database.* - the database specified and all its objects.
      • database.object - the database specified and its specified objects.

           For example, to grant the full access to the user testuser@localhost on the testdb database, the following command can be used:


      mysql> GRANT ALL PRIVILEGES ON testdb.* TO ‘testuser’@‘localhost’;


      Query OK, 0 rows affected (0.00 sec)


          {NOTE - you can grant only privileges that you already have, and you must have the privilege to issue the GRANT command.}


           We can rerun MySQL and log in as testuser to test whether the command above worked:


      C:\>mysql -u testuser -p

      Enter password: **********

      Welcome to the MySQL monitor. Commands end with ; or \g.

      Your MySQL connection id is 22

      Server version: 5.7.11-log MySQL Community Server (GPL)

      Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.


           Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.


           Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.


      mysql> SHOW databases;


      +––––––—+

      | Database |

      +––––––—+

      | information_schema |

      | testdb |

      +––––––—+

      2 rows in set (0.00 sec)

      mysql>


           As you can see from the output above, we’ve successfully logged in as testuser and displayed the testdb database.


      Create a table


           Tables are subcontainers within a database that store the actual data. The database is created without any tables. To create a table, the following command is used:


      CREATE TABLE name(

      column_list

      ) ENGINE name


           Here is the explanation of the syntax:

      • name - specifies the name of the table.
      • column_list - specifies the list and data types of columns, separated by commas.
      • ENGINE name - specifies the type of database engine to use for this table. If you don’t specify this parameter explicitly, MySQL will use InnoDB by default.

           Here is an example. Let’s say we want to specify a table called testtable with three colums - name, surname, and birth year. We can use the following command:


      mysql> USE testdb;


      Database changed


      mysql> CREATE TABLE testtable (name VARCHAR(128), surname VARCHAR(128), year CHAR(4)) ENGINE MyISAM;


      Query OK, 0 rows affected (0.01 sec)


      mysql> SHOW tables;


      +––––––+

      | Tables_in_testdb |

      +––––––+

      | testtable |

      +––––––+

      1 row in set (0.00 sec)


           To check how our new table looks like, we can use the following command:


      mysql> DESCRIBE testtable;


      +–––+––––—+––+–—+–––+––-+

      | Field | Type | Null | Key | Default | Extra |

      +–––+––––—+––+–—+–––+––-+

      | name | varchar(128) | YES | | NULL | |

      | surname | varchar(128) | YES | | NULL | |

      | year | char(4) | YES | | NULL | |

      +–––+––––—+––+–—+–––+––-+

      3 rows in set (0.03 sec)



           Note how each column has a specific data type and the size (e.g.,VARCHAR(255)). This data type is very useful, as it serves a guideline for MySQL to understand what type of data is expected inside of each column, and it also identifies how MySQL interacts with the stored data.. For example, the column year has predictable values, so instead of VARCHAR we have used the more efficient CHAR(4) data type. This parameter of 4 allows for 4 bytes of data, supporting all years from –999 to 9999.


      Data types


           A data type defines what kind of value a column in a database table can contain. This parameter tells MySQL the type of data that will be stored inside each table column, so MySQL can plan the size of databases and perform lookups and searches more effectively.


           In the previous chapter we’ve defined the VARCHAR and CHAR data types. MySQL offers many additional data types, including string, numeric, and spatial data types. Here is a description of the most important ones:


      • CHAR - a fixed-length string.
      • VARCHAR - a variable-length string.
      • BINARY - a fixed-length binary string. Used to store strings of full bytes that do not have an associated character set (such as GIFs).
      • BLOB - a Binary Large OBject. Used for binary data in excess of 65,536 bytes in size.
      • INT - a standard integer numerical.
      • FLOAT - a single-precision floating point number.
      • DATE - a date value in YYYY-MM-DD format.
      • TIME - a time value in HH:MM:SS format.
      • DATETIME - a date and time value in YYYY-MM-DD HH:MM:SS format.

      👈Episode 1(MP)
      Share This Post

      Featured post

      *Episode 1* MCQ for Govt. Job/ Private Job/ MNCs

        Topic:- One Word Substitution 1) Especially skilled in storytelling  Answer:- Raconteur 2) Fear of loneliness Answer:- Eremophobia  3) Usa...