Chapter 3 -
DATABASE PART – II MYSQL
Exercise
1. MULTIPLE CHOICE QUESTIONS:
1. The command used to modify the content of a table is:
১. তালিকার বিষয়বস্তু পরিবর্তন করতে ব্যবহৃত কমান্ডটি হল:
a) ALTER TABLE
ক) তালিকা পরিবর্তন করুন
b) SELECT
খ) একটি পছন্দ করুন
c) UPDATE
গ) আপডেট
Ans: c) UPDATE (আপডেট)
2. The command used to display the table structure is:
টেবিলের কাঠামো প্রদর্শনের জন্য ব্যবহৃত কমান্ডটি হল:
a) DISPLAY
ক) প্রদর্শন
b) STRUCTURE
খ) গঠন
c) DESCRIBE
গ) বর্ণনা করো
Ans: c) DESCRIBE (গ) বর্ণনা করা)
3. A table name should begin with:
(একটি টেবিলের নাম শুরু হওয়া উচিত:)
a) Number
ক) সংখ্যা
b) Alphabet
খ) বর্ণমালা
c) Symbol
গ) প্রতীক
Ans: b) Alphabet (খ বর্ণমালা)
4. The command used to delete the database physically:
(ডাটাবেসটি বাস্তবে মুছে ফেলার জন্য ব্যবহৃত কমান্ড :)
a) DELETE
ক) মুছে ফেলা
b) ERASE
খ) মুছে ফেলা
c) DROP
গ) ড্রপ
Ans: c) DROP (গ ড্রপ)
5. This wildcard character allows finding a match for any string of any length, including zero length:
(এই ওয়াইল্ডকার্ড অক্ষরটি শূন্য দৈর্ঘ্য সহ যেকোনো দৈর্ঘ্যের যেকোনো স্ট্রিংয়ের জন্য একটি মিল খুঁজে পেতে সাহায্য করে :)
a) *
b) %
c) #
Ans:
6. This operator displays only those records that do not satisfy the specified condition,
(এই অপারেটরটি কেবলমাত্র সেই রেকর্ডগুলি প্রদর্শন করে যা নির্দিষ্ট শর্ত পূরণ করে না,)
a) AND
b) OR
c) NOT
Ans: C) NOT
II. FILL IN THE BLANKS:
(খালি জায়গা পূরণ করুন :)
1. MySQL is named after co-founder Michael Widenius's daughter, _____________.
MySQL এর নামকরণ করা হয়েছে সহ-প্রতিষ্ঠাতা মাইকেল উইডেনিয়াসের কন্যা _____________ এর নামে।
Ans:
2. The number of rows denotes the of the table.
সারির সংখ্যা টেবিলের ______________ নির্দেশ করে।
Ans: The number of rows denotes the cardinality of the table
3. The number of _____________ denotes the Degree of the table.
_____________ সংখ্যাগুলি টেবিলের ডিগ্রি নির্দেশ করে।
Ans: The number of column denotes the Degree of the table
4. _____________ words are not allowed in a table name.
টেবিলের নামে _____________ শব্দ করা যাবে না।
Ans: Reserved Words are not allowed in a table name.
5. A MySQL statement is terminated by a _______________.
একটি MySQL স্টেটমেন্ট _______________ দ্বারা সমাপ্ত হয়।
Ans: A MySQL statement is terminated by a terminating semicolon.
6. The underscore wildcard allows finding a match for any ______________ character.
আন্ডারস্কোর ওয়াইল্ডকার্ড যেকোনো ______________ অক্ষরের সাথে মিল খুঁজে পেতে সাহায্য করে।
Ans: The underscore wildcard allows finding a match for any single character.
III. ANSWER THE FOLLOWING QUESTIONS:
নিম্নলিখিত প্রশ্নের উত্তর দাও:
1. Who were the developers of MySQL?
MySQL এর বিকাশকারী কে ছিলেন?
Ans: Mysql was created by a Swedish company, MySQL AB, founded by Swedish David Exmark, Alan Larsen, and Finnish Swedish Michael "Monty" Wydenius. The original development of MySQL by Weidenius and Xmark began in 1994. The first edition of MySQL was published on May 23, 1995.
(MySQL তৈরি করেছিল MySQL AB, সুইডিশ কোম্পানি ডেভিড এক্সমার্ক, অ্যালান লারসেন এবং ফিনিশ সুইডিশ মাইকেল "মন্টি" উইডেনিয়াস দ্বারা প্রতিষ্ঠিত। Weidenius এবং Exmark দ্বারা MySQL-এর মূল বিকাশ শুরু হয়েছিল ১৯৯৪ সালে। MySQL-এর প্রথম সংস্করণ প্রকাশিত হয়েছিল ২৩শে মে, ১৯৯৫ সালে।)
2. Why is MySQL becoming so popular? Give two reasons.
MySQL কেন এটি এত জনপ্রিয় হয়ে উঠেছে? দুটি কারণ দাও।
Ans: As an open-source solution, MySQL can be used independently without bearing the cost of the commercial database platform. This fact makes MySQL attractive to individuals and organizations looking for a path to economic growth.
(ওপেন-সোর্স সমাধান হিসেবে, বাণিজ্যিক ডাটাবেস প্ল্যাটফর্মের খরচ ছাড়াই MySQL স্বাধীনভাবে ব্যবহার করা যেতে পারে। এই তথ্যটি অর্থনৈতিক প্রবৃদ্ধি অর্জনকারী ব্যক্তি এবং প্রতিষ্ঠানের কাছে MySQL কে আকর্ষণীয় করে তোলে)
3. What is a constraint? Name any two constraints.
বাধাটা কী? যেকোনো দুটি সীমাবদ্ধতার নাম লেখ।
Ans: Moderation is used to ensure that the integrity of the information in the database is maintained. Unique, primary key, foreign key, test, default settings are barriers that can be applied frequently to the list. This is called a barrier.
The name of any two types constraints is
1. NOT NULL constraints
2. Unique constraints.
4. Give examples of DML commands?
DML কমান্ডের উদাহরণ দাও?
Ans: Examples of DML commands are-
1. Insert
2. Update
3. Delete
5. What are the characteristics by which you can determine the data type of MySQL?
(MySQL এর ডেটা টাইপ নির্ধারণ করার জন্য আপনাকে কোন বৈশিষ্ট্যগুলি ব্যবহার করতে হবে?)
Ans: The features that can determine the data type of MySQL are accuracy, completeness, reliability, relevance, and timeline — keep reading to learn more.
(MySQL ডেটা টাইপ নির্ধারণ করতে পারে এমন সুনির্দিষ্ট বিষয়গুলি হল - নির্ভুলতা, সম্পূর্ণতা, নির্ভরযোগ্যতা, প্রাসঙ্গিকতা এবং সময়রেখা - আরও জানতে পড়তে থাকুন।)
6. What is the query to display the table structure?
টেবুলৰ গঠন প্ৰদৰ্শন কৰিবলৈ প্ৰশ্নটো কি?
Ans: To show the structure of the table, the size is the description in sql or DESC is a statement that shows the structure of the table. Each column in the list specified here contains all the information, such as the name of the column, the type of the column, the default value, if it is zero or does not cancel, etc.
(টেবিলের গঠন দেখানোর জন্য, আকারটি SQL-এ Description অথবা DESC হল একটি বিবৃতি যা তালিকার গঠন দেখায়। এখানে সংজ্ঞায়িত তালিকার প্রতিটি কলামে সমস্ত তথ্য রয়েছে, যেমন কলামের নাম, কলামের ধরণ, ডিফল্ট মান, এটি নাল কিনা বা অবৈধ কিনা ইত্যাদি)।
7. What is the query to display all the records in a table?
একটি টেবিলে সমস্ত রেকর্ড প্রদর্শনের জন্য কোয়েরি কী?
Ans: A description of the size, square or DESC, of the structure of the list, is a statement that shows the structure of the table to display all records in a table. Each column in the list specified here contains all the information, such as the name of the column, the type of the column, the default value, if it is zero or does not cancel, etc.
(একটি টেবিলে সমস্ত রেকর্ড প্রদর্শনের জন্য তালিকার কাঠামোর আকার, বর্গক্ষেত্র, অথবা DESC বর্ণনা হল একটি বিবৃতি যা তালিকার কাঠামো দেখায়।)
8. List the Arithmetic Operators used in MySQL.
একটি টেবিলে সমস্ত রেকর্ড প্রদর্শনের জন্য কোয়েরি কী?
Ans: List of Arithmetic Operators used in MySQL are-
IN, it is used to compare a value of list of literal values
ALL, It compares a value to all values in another set of values.
ANY, It compares a value to any value in the list according to the condition specified.
9. List the Relational Operators used in MySQL.
(MySQL-এ ব্যবহৃত রিলেশনাল অপারেটরগুলির তালিকা তৈরি করুন।)
Ans: The List of Relational Operators used in MySQL -
10. Differentiate between COUNT(*) and COUNT.
গণনা (*) এবং গণনার মধ্যে পার্থক্য করো।
Ans: The Differentiate between Count(*) and Count are-
1. COUNT(*) will count the number of records. and Count will count the number of records where column name is not null.
2. COUNT(*) includes rows its cancel values .and Count does not include rows with cancelled ID.
11. What are the rules for naming a table in MySQL?
MySQL-এ একটি টেবিলের নামকরণের নিয়মগুলি কী কী?
Ans: The rules for naming a list in MySQL are- List prefixes and suffixes must be compatible with the type of list. List names must only contain letters from A to Z, from 0 to 9, and underline (_). The names on the list may contain several underlines. For more information, see the List Naming Convention section.
(MySQL-এ তালিকার নামকরণের নিয়ম হল: তালিকার উপসর্গ এবং প্রত্যয়গুলি তালিকার ধরণের সাথে সামঞ্জস্যপূর্ণ হতে হবে। তালিকার নামগুলিতে কেবল A থেকে Z পর্যন্ত, 0 থেকে 9 পর্যন্ত কেবল অক্ষর থাকতে হবে এবং (_) আন্ডারলাইন করতে হবে।
12. Explain the five categories of SQL commands?
(SQL পাঁচটি শ্রেণীর আদেশ ব্যাখ্যা কর।?)
Ans: Example the five categories of SQL commands are-
1.DDL
2.DQL
3.DNL
4.DCL
5. TCL
(SQL প্রায় পাঁচটি শ্রেণীর কমান্ড হল-)
1.ডিডিএল
2.ডিকিউএল
3.ডিএনএল
4.ডিচিএল
5. টিচিএল
IV. PRACTICAL EXERCISE
ব্যবহারিক অনুশীলন
1. Create a Table 'customer' in a database named 'Klubmart with the following fields:
('ক্লাবমার্ট' নামের ডাটাবেসে নিম্নলিখিত ক্ষেত্রগুলি ব্যবহার করে 'গ্রাহক' তালিকা তৈরি করুন।:)
Column Name | Data Type | Size | Constraints |
Customer ID | INT | PRIMARY KEY | |
Customer Name | VARCHAR | 20 | NOT NULL |
Customer Mobile | VARCHAR | 11 | NOT NULL |
Customer Category | CHAR | 1 | It is either X, Y or Z |
2. Display the structure of the table.
(টেবিলের গঠন দেখাও।)
Ans:
3. Insert five records in the table.
(টেবিলে পাঁচটি রেকর্ড সন্নিবেশ করান।)
Ans:
4. Display all the records.
(সমস্ত রেকর্ড প্রদর্শন করুন।)
Ans:
5. Display the Customer Name & Customer Mobile.
(গ্রাহকের নাম এবং গ্রাহকের মোবাইল ফোন প্রদর্শন করুন।)
Ans:
6. Display the Customer Name whose Customer Category is 'X'.
(যে গ্রাহকের গ্রাহক বিভাগ 'X' তার নাম প্রদর্শন করুন।)
Ans:
7. Display the Customer ID whose Customer Category is 'Y' OR 'Z'.
(যার গ্রাহক শ্রেণী 'Y' বা 'Z' সেই গ্রাহক আইডিটি প্রদর্শন করুন।)
Ans:
8. Display the distinct Customer Category from the table.
(তালিকা থেকে একটি পৃথক গ্রাহক বিভাগ প্রদর্শন করুন।)
Ans:
V. SOLUTION
1. The MySQL command to create the database is:
ডাটাবেস তৈরির জন্য MySQL কমান্ডটি হল:
CREATE DATABASE Klubmart;
To use the Database Klubmart, type:
USE Klubmart;
To create the table 'customer' in the database 'Klubmart":
CREATE TABLE customer
(Customer ID INT PRIMARY KEY,
Customer Name VARCHAR (20) NOT NULL,
Customer Mobile VARCHAR (10) NOT NULL,
Customer Category CHAR);
ডাটাবেস ক্লাবমার্ট তৈরি করুন;
ClubMart ডাটাবেস ব্যবহার করতে, টাইপ করুন:
ক্লাবমার্ট ব্যবহার করুন;
'ক্লাবমার্ট' ডাটাবেসে 'গ্রাহক' তালিকা তৈরি করতে:
তালিকা তৈরি করুন রিসিভার
(গ্রাহক আইডি আইএনটি প্রাথমিক কী,
গ্রাহকের নাম সংস্করণ (20) বাতিল করা হয়নি,
গ্রাহকের মোবাইল সংস্করণ (১০) বাতিল করা হয়নি,
গ্রাহক বিভাগ স্যার);
2. To display the structure of the table type the command:
(টেবিলের গঠন প্রদর্শনের জন্য কমান্ডটি টাইপ করুন :)
DESCRIBE customer;
(গ্রাহককে বর্ণনা করুন;)
Ans:
3. To insert the record type the following command:
(রেকর্ডটি সন্নিবেশ করতে নিম্নলিখিত কমান্ডটি টাইপ করুন:)
INSERT INTO customer values (1, 'Atul','9435110011", "X");
গ্রাহকের দামের মধ্যে অন্তর্ভুক্ত করুন (1, 'অতুল', '9435110011", "এক্স");
INSERT INTO customer values (2, 'Ashwini', '9864078011', 'Y');
CustomerPrice(2, 'ashwini', '9864078011', 'y') এ অন্তর্ভুক্ত করুন;
INSERT INTO customer values (3, 'Anjana, 7086219344", "Z");
গ্রাহক মূল্যের মধ্যে অন্তর্ভুক্ত করুন (3, 'অঞ্জনা, 7086219344", "Z");
INSERT INTO customer values (4, 'Archana', '9435987611", "Y");
CustomerPrice(4, 'orchana', '9435987611", "y") এ অন্তর্ভুক্ত করুন;
INSERT INTO customer values (5, 'Amresh","9435110011", "X");
গ্রাহক মূল্যে অন্তর্ভুক্ত করুন (5, 'amresh', 9435110011", "x");
4. SELECT * FROM customer;
গ্রাহক থেকে * নির্বাচন করুন;
5. SELECT Customer Name, Customer Mobile FROM customer;
গ্রাহকের নাম, গ্রাহকের মোবাইল থেকে গ্রাহক নির্বাচন করুন;
6. SELECT Customer Name FROM customer WHERE Customer Category = 'X';
Customer থেকে CustomerName নির্বাচন করুন যেখানে CustomerClass = 'X';
7. SELECT Customer ID FROM customer WHERE Customer Category = 'Y' OR
Customer Category = 'Z';
গ্রাহক থেকে গ্রাহক আইডি নির্বাচন করুন যেখানে গ্রাহক শ্রেণী = 'Y' অথবা
গ্রাহক শ্রেণী = 'Z';
8. SELECT DISTINCT(Customer Category) FROM customer;
গ্রাহকদের থেকে আলাদা (গ্রাহক শ্রেণী) বেছে নিন;
2. Create a table Worker in a database named Organisation. Enter the records given in the table below.
Organization নামের একটি ডাটাবেসে একটি টেবিল ওয়ার্কার তৈরি করুন। নিচের টেবিলে রেকর্ডগুলো লিখুন।
Worker _ ID | First _ Name | Last _ Name | Salary | Joining _ Date | Department |
001 | Rebecca | Doungel | 40000 | 2014-02-20 | HR |
002 | Jahnavi | Borthakur | 68000 | 2014-06-11 | Admin |
003 | Digvijay | Goswami | 50000 | 2014-02-20 | HR |
004 | Krishang | Shandilya | 50000 | 2014-02-20 | Admin |
005 | Jaspal | Bhatti | 55000 | 2014-06-11 | Admin |
006 | Kankana | Devi | 20000 | 2014-06-11 | Account |
007 | Shristi | Goswami | 75000 | 2014-01-20 | Account |
008 | Geeta | sharma | 90000 | 2014-04-11 | Admin |
Write the commands to do the following:
নিম্নলিখিত কাজগুলি করার জন্য কমান্ডগুলি টাইপ করুন:
1. Display Worker ID and Joining Date of Admin Department.
প্রশাসক বিভাগের কর্মীদের পরিচয়পত্র এবং যোগদানের তারিখ প্রদর্শন করুন।
2. Display records in ascending order of Salary.
বেতনের ঊর্ধ্বমুখী ক্রমে রেকর্ড প্রদর্শন করুন।
3. Display records having Salary in the range 50000 to 90000.
৫০০০০ থেকে ৯০০০০ এর মধ্যে বেতনের রেকর্ড প্রদর্শন করুন।
4. Display the record of persons who First Name ends with 'a'.
যাদের নামের প্রথম অংশ 'A' দিয়ে শেষ হয় তাদের রেকর্ড প্রদর্শন করুন।
5. Display the records of HR and Account Department.
এইচআর এবং অ্যাকাউন্ট বিভাগের রেকর্ড প্রদর্শন করুন।
6. The worker is given bonus as 1% of the Salary. Display the First Name, Last Name and Bonus.
কর্মীকে বেতনের ১% বোনাস দেওয়া হয়। প্রথম নাম, পদবি এবং বোনাস প্রদর্শন করুন।
7. Display the sum, maximum, minimum and average Salary.
সর্বোচ্চ, সর্বনিম্ন এবং গড় বেতনের যোগফল প্রদর্শন করুন।
8. Display the count of records where Department = 'HR'.
রেকর্ডের সংখ্যা প্রদর্শন করুন যেখানে বিভাগ = 'HR'।
Solution
1. SELECT Worker __ ID, Joining __ Date FROM Worker WHERE Department = 'Admin';
কর্মীর __ তারিখে যোগদানকারী কর্মী __ আইডি নির্বাচন করুন যেখানে বিভাগ = 'অ্যাডমিন';
2. SELECT * FROM Worker ORDER BY Salary;
বেতন অনুসারে কর্মীদের ক্রম থেকে * নির্বাচন করুন;
3. SELECT * FROM Worker BETWEEN 50000 AND 90000;
৫০০০০ থেকে ৯০০০০ এর মধ্যে কর্মীদের মধ্যে থেকে * নির্বাচন করুন;
4. SELECT * FROM Worker WHERE First_Name LIKE "%a";
যেখানে First_Name "%a" পছন্দ করে এমন কর্মী থেকে নির্বাচন করুন;
5. SELECT * FROM Worker WHERE Department = 'HR' OR Department = 'Account';
এমন কর্মীদের মধ্যে থেকে নির্বাচন করুন যেখানে বিভাগ = 'এইচআর' অথবা বিভাগ = 'অ্যাকাউন্টস';
6. SELECT First_Name, Last_Name, 0.01 * Salary AS "BONUS" FROM Worker;
প্রথম_নাম, শেষ_নাম, ০.০১ * কর্মীর কাছ থেকে "বোনাস" হিসেবে বেতন নির্বাচন করুন;
7. SELECT SUM(Salary), MAX(Salary), MIN(Salary), AVG(Salary);
অন্তর্ভুক্ত (বেতন), সর্বোচ্চ (বেতন), MIN(বেতন), গড় (বেতন);
8. SELECT COUNT(*) FROM Worker WHERE Department = 'HR';
কর্মীদের কাছ থেকে count(*) নির্বাচন করুন যেখানে বিভাগ = 'HR';