Wednesday, November 23, 2022

UNIT-V (RDBMS Concepts and MYSQL) 10+2

 Chapter -5 

RDBMS Concepts and MYSQL

Q.1 Define  database and explain its advantage and Disadvantages?

डेटाबेस को परिभाषित करें और इसके लाभ और नुकसान की व्याख्या करें!

Ans. डेटाबेस structured information का एक organized collection है. आसान शब्दों में Data के systematic collection को “Database” कहा जाता है. वो इसलिये क्योंकि इसे काफी व्यवस्थित बनाया जाता है. ताकि डेटा को आसानी से access, manage और update किया जा सके. Database का मूल कार्य data management को आसान बनाना है.

Advantages of Database:-




Disadvantages  of Database

1. जटिलता

2. आकार

3. डीबीएमएस की लागत

4. रूपांतरण की लागत

5. प्रदर्शन

6. विफलता का उच्च प्रभाव

Q. 2 Explain various types of users in database system ?


Ans. These are seven types of data base users in DBMS.

  • Database Administrator (DBA) : ...

  • Naive / Parametric End Users : ...

  • System Analyst : ...

  • Sophisticated Users : ...

  • Data Base Designers : ...

  • Application Program : ...

  • Casual Users / Temporary Users :























Q3 :- What is the difference between database and traditional file approach for storing the data.

डेटा संग्रहीत करने के लिए डेटाबेस और पारंपरिक फ़ाइल दृष्टिकोण के बीच अंतर क्या है।

Ans.




Q.4 Explain different levels of Database Architecture?


Ans Data Base Architecture :- 


Three tier architecture-

थ्री टायर आर्किटेक्चर को 3 schema architecture के नाम से भी जाना जाता है. इसमें तीन स्तर होते हैं.
1.External level
2.Conceptual level
3.Internal level

External Level-

इस स्तर पर यूजर कार्य करता है.इस स्तर के द्वारा यूजर को जो सूचना चाहिए, यूज़र जिस सूचना की आवेदन करता है सिर्फ वही सुचना उसके सामने दर्शाया जाता है. और बाकी की अंदर की जानकारी यानी की किस तरह डाटा दिखाया जा रहा है, किस तरह से संग्रह किया गया है, ये सब की जानकारी यूजर से छुपाया जाता है.external level view level के नाम से भी जाना जाता है. तो दोस्तों view के नाम से ही आप समझ गए होंगे कि इस स्तर पर हम बस अपनी जरूरत की सुचना ही देख सकते है.

Conceptual Level-

इस स्तर पर DBA(database administrator) और प्रोग्रामर कार्य करते है.इस स्तर पर यह तय किया जाता है कि डाटा किस तरह से संग्रह किया जाएगा, उसका size कितना होगा आदि सब तय किया जाता है. यह स्तर बाकी दोनों स्तर के बीच मध्यस्त का काम करती है. इस स्तर को logical level के नाम से भी जाना जाता है. तो दोस्तों logical के नाम देखते ही जान गए होंगे कि यहां पर डाटा की datatype, attributes, entity के बारे में जानकारी संग्रह किया जाता है.

Internal Level-

इसे physical level के नाम से भी जाना जाता है. इस स्तर पर वास्तविक डाटाबेस को दर्शाता जाता है. यहा पर यह तय होता है कि डाटा को किस तरह से रखा जाएगा, किस तरह से उसे organised तरीके में रखा जाएगा, यह सब physical level के कार्य है.

Q.5 Explain the role of DBA.

Ans DBA यानी कि डाटाबेस एडमिनिस्ट्रेटर(Database Administrator).

DBA की जिम्मेदारियां 

  • user के problem यानी कि user को डेटाबेस का इस्तेमाल करते समय जो भी परेशानी और दिक्कत आ रही हो उन्हें ठीक करना.

  • जो भी यूजर डाटा को इस्तेमाल कर रहा है यानी कि डाटा को access कर रहा है वह ऑथराइज्ड(authorised) है कि नहीं उसकी जांच करना.

  • जो database बनाया गया है वह डाटाबेस समय-समय पर अपडेट(update) हो रहा है या नहीं हो रहा है उसकी देखरेख करना.

  • डाटा एक्सेस(access) सही तरीके से की जा रही है या नहीं की जा रही है. या उस डाटा का कुछ गलत इस्तेमाल या गलत फायदा उठाया जा रहा है, उसका रखरखाव करना.

  • डाटा एक्सेस(access) सही तरीके से की जा रही है या नहीं की जा रही है. या उस डाटा का कुछ गलत इस्तेमाल या गलत फायदा उठाया जा रहा है, उसका रखरखाव करना.

  • डेटाबेस के सॉफ्टवेयर जैसे कि oracle,mysql,db2 आदि को रखरखाव यानी की उस सॉफ्टवेयर का मेंटेन(maintain) करना.


Q.6 What is data dictionary?

Ans DBMS मेंData dictionary एक फ़ाइल या फाइलों का समूह होती है जो कि डेटाबेस के मेटाडाटा(metadata) को store करती है। data dictionary डेटाबेस के वास्तविक डेटा को contain नही करती है, बल्कि यह सिर्फ डेटा को manage करने के लिए बहीखातों के रूप में information(जैसे-टेबल का नाम तथा विवरणआदि) को स्टोर करता है।

 

Q.7 List some advantages of RDBMS?

Ans Less redundancy :-

DBMS का use करके database redundancy को काम किया जा सकता है इसका मतलब यह है कि अगर हमें database में change करना पड़े तो यह change एक ही जगह पर करना पड़े ।

Data independent :-

जिस data की value को हम store या retrive करना चाह रहे हैं वह data independent होता है।

Efficient data accessing:-

DBMS techniques का use करके data को store और retrive आसानी से जा सकता है।

Reduce application development time :-

DBMS बहुत सारे function को support करता है जो कि बहुत सारे application के लिए common होते हैं।

Security:-

DBMS कौन कौन application database में प्रवेश कर सकते है।

Integraity(अखंडता) :-

Integraity constants database में value को uniquely identify करते हैं दो constation होते है।

Q.8 What are constraints? Explain Domain level Constraint.

Ans. Constraints का इस्‍तेमाल table के Columns के लिए कुछ rules देने के लिए किया जाता हैं। Constraints को table create करते वक्‍त और table ALTER करते वक्‍त दिया जाता हैं। Constraints या तो Column level हो सकते हैं या table level हो सकते हैं।

Domain constraints:-

यह integrity constraints का primary रूप है domain प्रत्येक column में आने वाले data का collation है । domain पर condition इसलिए भी बनाई जाती है। क्योंकि कई सारे attribute का domain same हो सकता है।

 Ex:-

हम एक domain का ऐसा set बना रहे हैं।जिसमे mobile number 10 digit का हो तथा उसकी value null ना हो जाये।

 Create domain mobile no. Int(10);

Domain constraints mobile no. (Value not null)

Q.9 What is Data Definition Language?

Ans. डाटाबेस को define करने के लिए उपयोग में लाई जा रही language data definition language या DDL कहलाती हैं। Database को Define करने के लिए उपयोग मे लाई जाने वाली कमांड्स DDL कमांड्स कहलाती हैं। DDL में टेबल बदलने, टेबल ड्राप करने या कंस्ट्रेंट्स डिफाइन करने वाली सभी कमांड्स शामिल हैं।

  • DDL का मतलब Data Definition Language है। इसका उपयोग database structure या pattern को परिभाषित करने के लिए किया जाता है। 

  • यह database में स्कीमा, टेबल, indexes, constraints आदि बनाने के लिए उपयोग किया जाता है। 

  • DDL statements का उपयोग करके, आप database के skeleton बना सकते हैं। 

  • Data Definition Language को Meta data की जानकारी को स्टोर करने के लिए उपयोग किया जाता है तालिकाओं और schemas की संख्या, उनके नाम, indexes, प्रत्येक तालिका में column, constraints, आदि।

Q.10 How to create a tables in MySQL? Explain with syntax and example.

Ans Creating a basic table involves naming the table and defining its columns and each column's data type.

The SQL CREATE TABLE statement is used to create a new table.

Syntax

The basic syntax of the CREATE TABLE statement is as follows −

CREATE TABLE table_name(

   column1 datatype,

   column2 datatype,

   column3 datatype,

  .....

  columnN datatype,

  PRIMARY KEY( one or more columns )

);


Example

The following code block is an example, which creates a CUSTOMERS table with an ID as a primary key and NOT NULL are the constraints showing that these fields cannot be NULL while creating records in this table −

SQL> CREATE TABLE CUSTOMERS(

   ID   INT              NOT NULL,

   NAME VARCHAR (20)     NOT NULL,

  AGE  INT              NOT NULL,

  ADDRESS  CHAR (25) ,

   SALARY   DECIMAL (18, 2),       

   PRIMARY KEY (ID)

);


Q.11 What is DROP statement? Explain with syntax and example.

Ans 

DROP TABLE Statement का इस्तेमाल बनाये हुए table को delete करने के लिये किया जाता है |

Syntax:

DROP object object_name

 

Examples:

DROP TABLE table_name;

table_name: Name of the table to be deleted.

 

DROP DATABASE database_name;

database_name: Name of the database to be deleted.

 

Q.12 What do you mean by DML and DCL? Explain.

Ans. Data Manipulation Language 

DML का अर्थ Data Manipulation language है। इसका उपयोग database में data Access करने और manipulate करने के लिए किया जाता है।

Here are some tasks that come under DML:

  • Select: इसका उपयोग database से data पुनः प्राप्त करने के लिए किया जाता है।

  • Insert: इसे Table में data सम्मिलित करने के लिए उपयोग किया जाता है।

  • Select: इसका उपयोग database से data पुनः प्राप्त करने के लिए किया जाता है। 

  • Insert: इसे Table में data सम्मिलित करने के लिए उपयोग किया जाता है।

  • Update: इसका उपयोग table के भीतर मौजूदा data को अपडेट करने के लिए किया जाता है। 

  • Delete: इसका उपयोग सभी records को किसी table से हटाने के लिए किया जाता है। 

  • Merge: यह UPSERT ऑपरेशन करता है,जो हैं insert या update operations

  • Call: इसका उपयोग एक structured query language या Java subprogram को Call करने के लिए किया जाता है।

  • Explain Plan: इसमें data समझाने की parameter है 

  • Lock Table: यह Concurrency को नियंत्रित करता है

Data Control Language

  • DCL का मतलब है Data Control Language इसका उपयोग संग्रहीत या सहेजे गए data को पुनः प्राप्त करने के लिए किया जाता है। 

  • DCL का execution transactional है। इसमें rollback parameter भी हैं।

Here are some tasks that come under DCL:

  • Grant: यह एक database को user access privileges को देने के लिए उपयोग किया जाता है। 

  • Revoke: इसका उपयोग उपयोगकर्ता से अनुमति वापिस लेने के लिए किया जाता है।


Q.13 What do you mean by TCL commands?

Ans. Transaction Control Language

TCL DML statement द्वारा किए गए परिवर्तनों को चलाने के लिए उपयोग किया जाता है। TCL को एक Logical transaction में समूहीकृत किया जा सकता है।

Here are some tasks that come under TCL:

  • Commit: यह database पर लेनदेन को बचाने के लिए उपयोग किया जाता है।

  • Rollback: यह पिछले commit के बाद से original database को पुनर्स्थापित (restore) करने के लिए प्रयोग किया जाता है।

  •  

Q.14 What are Scalar Functions in MySQL? Explain with syntax and example.

Ans MySQL स्केलर फ़ंक्शंस आपको डेटा मानों पर विभिन्न गणना करने की अनुमति देता है। ये फ़ंक्शन केवल एकल पंक्तियों पर काम करते हैं और प्रति पंक्ति एक परिणाम उत्पन्न करते हैं। विभिन्न प्रकार के स्केलर फ़ंक्शंस हैं।

Scalar functions:
These functions are based on user input, these too returns single value.

  1. UCASE()

  2. LCASE()

  3. MID()

  4. LEN()

  5. ROUND()

  6. NOW()

  7. FORMAT()

Scalar Functions

UCASE(): It converts the value of a field to uppercase.
Syntax:

SELECT UCASE(column_name) FROM table_name;

LCASE(): It converts the value of a field to lowercase.
Syntax:

SELECT LCASE(column_name) FROM table_name;

MID(): The MID() function extracts texts from the text field.
Syntax:

SELECT MID(column_name,start,length) AS some_name FROM table_name;

 

specifying length is optional here, and start signifies start position ( starting from 1 )

LEN(): The LEN() function returns the length of the value in a text field.
Syntax:

SELECT LENGTH(column_name) FROM table_name;

ROUND(): The ROUND() function is used to round a numeric field to the number of decimals specified

Syntax:

SELECT ROUND(column_name,decimals) FROM table_name; 

 

decimals- number of decimals to be fetched.


Q.15 What is key? Explain different types of keys?

Ans. रिलेशनल डेटाबेस में keys एक महत्वपूर्ण भूमिका निभाती हैं।

इसका उपयोग Tables से डेटा के किसी भी record या row को uniquely पहचानने के लिए किया जाता है। इसका उपयोग tables के बीच संबंधों को स्थापित करने और पहचानने के लिए भी किया जाता है।

उदाहरण के लिए: student table में, ID का उपयोग एक key के रूप में किया जाता है क्योंकि यह प्रत्येक छात्र के लिए unique है। PERSON table में, पासपोर्ट नंबर, लाइसेंस नंबर, keys हैं क्योंकि वे प्रत्येक व्यक्ति के लिए unique हैं।

 

DBMS कुंजी


Types of Key:

 

DBMS कुंजी

1. Primary key

  • यह पहली key है जो एक entity के केवल एक instance की पहचान करने के लिए उपयोग की जाती है। एक इकाई में कई keys हो सकती हैं जैसा कि हमने PERSON table में देखा था। उन lists से जो सबसे उपयुक्त है वह एक primary key बन जाती है।

  • EMPLOYEE table में, ID primary key हो सकती है क्योंकि यह प्रत्येक कर्मचारी के लिए unique है। EMPLOYEE table में, हम primary key के रूप में Licence_Number और Passport_Number भी चुन सकते हैं क्योंकि वे भी unique हैं।

  • प्रत्येक इकाई के लिए, primary key का चयन आवश्यकता और developers पर आधारित है।

 

DBMS कुंजी

 

2. Candidate key

  • एक candidate एक attribute या attributes का सेट है जो uniquely एक tuple की पहचान कर सकती है।

  • Primary key को छोड़कर शेष attributes को एक candidate key के रूप में माना जाता है। candidate key primary key के समान strong होती हैं।

उदाहरण के लिए: EMPLOYEE table में, id primary key के लिए सबसे उपयुक्त है। बाकी attributes जैसे SSN, Passport_Number, और Licence_Number, आदि को candidate key माना जाता है।

 

DBMS कुंजी

 

3. Super key

Super key एक attribute का एक सेट है जो विशिष्ट रूप से एक tuple की पहचान कर सकता है। Super key एक candidate key का superset है।

उदाहरण के लिए: उपरोक्त EMPLOYEE table में, (EMPLOEE_ID, EMPLOYEE_NAME) के लिए दो कर्मचारियों के नाम समान हो सकते हैं, लेकिन उनका EMPLYEE_ID समान नहीं हो सकता। इसलिए, यह combination भी एक key हो सकता है।

Super key EMPLOYEE-ID, (EMPLOYEE_ID, EMPLOYEE-NIN), आदि होगी।

4. Foreign key

  • Foreign keys उस table का column होती हैं जिसका उपयोग किसी अन्य table की primary key को point करने के लिए किया जाता है।

  • एक कंपनी में, प्रत्येक कर्मचारी एक विशिष्ट विभाग में काम करता है, और कर्मचारी और विभाग दो अलग-अलग entities हैं। इसलिए हम कर्मचारी table में विभाग की जानकारी संग्रहीत नहीं कर सकते। इसलिए हम इन दोनों तालिकाओं को एक तालिका की primary key के माध्यम से link करते हैं।

  • अब EMPLOYEE table में, Department_Id foreign key है, और दोनों तालिकाएँ संबंधित हैं।

DBMS कुंजी

 

Q. 16 Define Function? What are various Types of Function.

 

SQL सर्वर में function  एक डेटाबेस ऑब्जेक्ट है। मूल रूप से, यह SQL कथनों का एक सेट है जो केवल इनपुट मापदंडों को स्वीकार करता है, क्रिया करता है और परिणाम लौटाता है। फ़ंक्शन केवल एकल मान या तालिका लौटा सकता है। हम डेटाबेस function के द्वारा insert, update या delete नही क्र सकते !

SQL function दो प्रकार के होते है 

  1. aggregate functions

  2. scalar(non-aggregate) functions

 

aggregate functions कई रिकॉर्डों पर काम करते हैं और एक समूह का निर्माण करते हैं, Group BY  के साथ काम करता है जबकि गैर-एग्रीगेट कार्य प्रत्येक रिकॉर्ड पर स्वतंत्र रूप से काम करते हैं।

Q.17 Explain Aggregate function with various example.

Ans. Aggregate functions in DBMS take multiple rows from the table and return a value according to the query.

All the aggregate functions are used in Select statement.

Syntax − 

SELECT <FUNCTION NAME> (<PARAMETER>) FROM <TABLE NAME>

AVG Function

This function returns the average value of the numeric column that is supplied as a parameter.

Example: Write a query to select average salary from employee table.

Select AVG(salary) from Employee

COUNT Function

The count function returns the number of rows in the result. It does not count the null values.

Example: Write a query to return number of rows where salary > 20000.

Select COUNT(*) from Employee where Salary > 20000;

Types −

  • COUNT(*): Counts all the number of rows of the table including null.

  • COUNT( COLUMN_NAME): count number of non-null values in column.

  • COUNT( DISTINCT COLUMN_NAME): count number of distinct values in a column.

MAX Function

The MAX function is used to find maximum value in the column that is supplied as a parameter. It can be used on any type of data.

Example − Write a query to find the maximum salary in employee table.

Select MAX(salary) from Employee

SUM Function

This function sums up the values in the column supplied as a parameter.

Example: Write a query to get the total salary of employees.

Select SUM(salary) from Employee

 

True/ False

  1. Data is collection of facts and information is organized data. T

  2. Duplication of data is handled in file system. F

  3. Database management is expensive task.T

  4. Metadata is Data About Data T

  5. The logical view of information focuses on how you arrange and access information to meet the needs of the business. T

  6. In the architecture of database the external level is view level. T

  7. DBA is responsible to work at conceptual level. F

  8. Data dictionary is also called meta data.  F

  9. RDBMS does not provide multi user access for data. F

  10. Data Dictionary provides the DBMS with its self-describing characteristic. T

  11. NOT NULL Constraint − Ensures that a column cannot have NULL value. T


  1. DDL commands are used for creating, modifying, and dropping the structure of database objects. T

  2. DROP command is used to delete objects from the database. T

  3. In SQL, database is container of tables. T

  4. Truncate command is used to rename an object existing in the database. F

  5. DDL stands for Data Description Language. F

  6. SELECT statement is a Data Definition Statement. F

  7. DELETE Command removes table from database. T

  8. REVOKE statement withdraws privilege given to user. T

  9. TCL stands for Transaction Control Language. T

  10. COMMIT command used to make changes permanent. T

  11. ROLLBACK command is same as UNDO. T

  12. Primary key does not allow NULL value in the column. T

  13. A superset of candidate key is called a super key. T

  14. A table can have multiple primary keys. F

  15. The MID() function is used to round a numeric field to the number of decimals specified. F

  16. Scalar functions are based on user input. T

  17. Scalar functions return multiple values. F

  18. Aggregate Function works on the more than one column. T

  19. Scaler function work on a single row T.

  20. AVG() function is used for finding the average.T

  21. LCASE() is a example of scalar function . T


 


No comments:

Post a Comment

Chapter -5 HTML Fundamentals(10+1)

  Chapter -5 HTML Fundamentals Q.1 Define HTML. Ans. HTML   एक MarkUp Language है , जिसे वेब डॉक्युमेंट (वेब पेज) बनाने के लिए विकसित ...