0% found this document useful (0 votes)
24 views

MYSQL Commands Class10

Data in a relational database management system (RDBMS) can be organized into tables with rows and columns. A table contains records (rows) with data organized into attributes (columns). A primary key uniquely identifies each record in a table and can be used to link and reference data between tables through foreign keys. Common RDBMS concepts include tables, records, attributes, primary keys, foreign keys, relationships, and referential integrity. Structured Query Language (SQL) commands like CREATE, INSERT, UPDATE, DELETE, and SELECT are used to define, manipulate and query data in tables.

Uploaded by

Sahana Banu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

MYSQL Commands Class10

Data in a relational database management system (RDBMS) can be organized into tables with rows and columns. A table contains records (rows) with data organized into attributes (columns). A primary key uniquely identifies each record in a table and can be used to link and reference data between tables through foreign keys. Common RDBMS concepts include tables, records, attributes, primary keys, foreign keys, relationships, and referential integrity. Structured Query Language (SQL) commands like CREATE, INSERT, UPDATE, DELETE, and SELECT are used to define, manipulate and query data in tables.

Uploaded by

Sahana Banu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

How do you organized data in DBMS

We can organized Data into two types:(2 Marks)

Flat File Relational

1.Data is stored in a single table 1.Data is stored in multiple tables


and the tables are linked using a
common field.

2.Usually suitable for less amount 2.Relational is suitable for medium


of data. to large amounts of data.

Important Terms :

1) Primary Key : A primary key is a field or group of fields that uniquely identifies a
row/record/tuple in a table. It can not be null(blank).

2) Composite Primary Key : When a primary key constraint is applied on one or


more columns then it is known as Composite Primary Key.

3. Foreign key : The foreign key identifies a column or set of columns in one
(referencing:child) table that refers to a column or set of columns in another
(referenced: parent) table where it acts as a primary key.it helps in maintaining
referential integrity.

4. Candidate key: Any field or group of fields that could be a primary key is called
candidate key.

Student: rollno, admno, adharno, name,age, clas, section,dob

Fields: (rollno , admno, adharno)-> candidate key.

Data in a relational database management system (RDBMS) is organized in the form


of tables.
DATABASE OBJECTS :

1) Table : A table is a set of data elements (values) that is organized using a model
of vertical columns and horizontal rows.

2) Columns or Fields or Attributes: A column is a set of data values of a particular


simple type, one for each row of the table.

Or

Fields/attribute: columns in a table are known as fields/attributes.

3) Rows or Records or Tuples :

● A row also called a Record or Tuple represents a single data item in a table.
● Every row in the table has the same structure.

Or

Tuple/Record: Row in a table is known as tuple/record.

4) Degree: No of attributes/columns in a table.

5) Cardinality: No records/tuples in a table.

Table: Student

rno Name sec Marks

1 Amit A 90

2 Sumit A 80
4. Attributes/fields are column name like rno,Name,sec and Marks

Q1. write down the degree of the above table student?

Ans. 4( Have four columns)

Q2. write down the cardinality of the above table student?

Ans. 2( no of rows)

Q3. write down the name of the attribute that can act as a primary key in the above
table student?

Ans. rno

Relationship and Referential Integrity


1. What is referential integrity?(foreign key and primary/parent-child relationship)
Ans. It ensures accuracy and consistency of data in the database.
The data can be linked between two or more tables with the help of primary
key and foreign key constraints.
2. Write down three basic aspects of referential integrity?(imp)
And.The value entered in foreign key in the child table must match a primary
key value in the parent table.
B. Any update in the key of the parent table will automatically update the
matching value in the child table. This is called an update cascade.
C. Any delete operation on a record in the parent table will automatically
delete the matching records in the child table. This is called delete cascade.

Student
Parent/master: PK(RollNo)
Rollno name fname class
1 Sumita fsjgdj 9
2 Amit fdsfsd 9
Marks:Child table
FK(Rollno)
Rollno Eng Maths Sci
1 60 50 70
2 75 65 98

3. Define relationship?
The association between tables(relation) defines the relationship.
4. Write down different types of relationships in DBMS?(2-3 marks)
There are three types of relation that exist between tables:
1. One to one:
This means one record in one table has exactly a matching record in
a related table. For example in the student and mark table we can enter
only one entry of a student against marks.

2. One to Many:
This means one record in one table has many matching records in
a related table. For example, a teacher can teach many subjects.

3. Many to Many:
This means multiple records in one table have many matching
records in another related table.
In this relationship, no table has the primary key column.
E.g students can pursue as many courses as they want.
MYSqL Queries:(4-5 Questions)
Define query?
Query is used to display specific information from a pool of data.
It helps us to join information from different tables and filter that data.
Define filtering?
It means that the query uses criteria/conditions to provide it to hide
some data and display the respective data that matches the criteria.
Define Mysql (MY structured query language)
It is a query language used to make queries into databases.
Different Categories of commands
1. DDL
2. DML
3. DCL
4. TCL

DDL: Data Definition Language


Commands: (create, alter, drop)
DML: Data Manipulation Language
Commands: (insert, update, delete,select)
DCL: Data Control language
Commands: (grant, revoke)
TCL: Transaction Control language
Commands: (commit, rollback)
Different types of Data: Datatypes
Numeric : Integer , decimal(size), float
Textual : char(size), varchar(size)
Date/time : Date
images, video audio : Binary(it stores data in form of digits 0
and 1)
decimal(10,2)->999999.99

Table: Student

rno Name sec Marks

1 Amit A 90

2 Sumit A 80

rno->integer

name->varchar

Sec ->varchar

marks->integer
Write down the name of the command used to design a table?

We use create command


Syntex:
create table tablename(fieldname1 datatype(size) constraint, fieldname2
datatype,----------);
E.g. create table
book as mentioned in
<- image

Field Name/Attributes DatatTye constraint


Book id numeric p[rimary key
Title text size 30
Author text size 30
Author text size 40
Publisher Text size 40
Price decimal
Copies integer
CREATE TABLE book (
bookid INTEGER PRIMARY KEY,
title varchar(30) NOT NULL,
author varchar(20) NOT NULL,
publisher varchar(20),price integer,copies integer
);

Write down the name of the command used to add a record in a table?
We use insert command
Syntex:
Insert into tablename values (fieldvalue1, “value2”, “value3”,---);

Q. Kindly add all record in above table book as shown in image.


INSERT INTO book VALUES (100, 'eye of the needle', 'Ken Follet',"Rupa",545,5);
INSERT INTO book VALUES (101, 'The firm', 'John Gris',"Digital Media",399,2);
INSERT INTO book VALUES (102, 'Third Twin', 'Ken Follet',"Rupa",400,2);
INSERT INTO book VALUES (104, 'The Innocent Man', 'John Gris',"Digital Media",324,3);
INSERT INTO book VALUES (103, 'Clear and Present Danger', 'Tom Clancy',"Rupa",760,1);

Write down the name of the command used to modify a record in a table?
We use update command
Syntex:
update tablename set columnname=new value where condition;
E.g.
Write a sql command to modify copies of book id 100 as 4;

Ans.
update book set copies=4 where bookid=100;
select price from book where author="Tom Clancy";

E.g.

Write a command to design the following table student.

Student
Parent/master: PK(RollNo)
Rollno name fname class
1 Sumita fsjgdj 9
2 Amit fdsfsd 9

create table student(rollno integer primary key, name varchar(12),


fname varchar(14),class integer);

Write down the name of the command used to remove a record


from a table?
We use delete command
Syntex:
Delete from tablename where condition;
E.g.
Delete a record from table book having title “The Firm”
Delete from book where title=”The Firm”;
Write down the name of the command used to delete a record in a
table?
We use insert command
Syntex:
Delete from tablename where condition;
E.g.
Remove a record from a student whose rollno is 3.
Delete from student where rollno=3;

Q. Write down the various field properties for numeric data type?(2 marks)
Ans.
AutoValue – if set to yes then the field will get the auto numeric values.
Length – By default length of the field is 10 but the size of the field can be set to
maximum length.
Default Value – A default value can be set for a field if user doesn't provide any
value while entering the values in the table.
Format example – This property helps to set the format of the data entered in the
field such as 91-222-333
Q. Write down the various field properties for character data type?
Ans. The various properties of character type data is s
Entry Required – if set to yes then it will be must to insert the value in the field
which means that field cannot be left blank.
Length – By default length of the field is 10 but the size of the field can be set to
maximum length.
Default Value – A default value can be set for a field if user don’t provide any value
while entering the values in the table.
Q. Define sorting ?
Ans. Sorting means to arrange the data in either ascending order of descending
order.
Select the column(s) then click on sort buttons. The data will be displayed
accordingly.

ASSESSMENT
Fill in the blanks:
1. The types of languages used for creating and manipulating the data in the
Database are ______________ & ______________.
2. A ____________________ is a standard for commands that define the
different structures in a database.
3. A ______________ is a language that enables users to access and
manipulate data in a database.
4. A _____________ is a part of DML involving information retrieval only.
5. A popular data manipulation language is _________________
6. __________ are the basic building blocks of a database.
7. There are __________ types of Relationships in a table.
Short Answer Questions:
1. What is the file extension for databases created using OpenOffice.Org
Base?
2. List any three file formats that can be managed using OpenOffice.Org
Base?
3.How many types of relationships can be created in Base? Explain each of
the them.
4.What do you mean by Sorting? In how many ways it can be done?
5.Explain Referential Integrity with the help of an example.

MYSQL

Assessment Fill in the blanks


1. A _______ helps the user to systematically store information in the
database.
2. A ________ enables users to view, enter, and change data directly in
database objects such as tables.
3. _________ statement retrieves zero or more rows from one or more
database tables or database views.
4. By default, data is arranged in __ order using ORDER BY clause.
5. __________ statement is used for modifying records in a database.
6. __________ statement is used to remove one or more records in a
Database.
Short Answer Questions:
1. Name DML commands.
2. What is the purpose of using queries?
3. Which clause of Select statement helps to display specific data?
4. Differentiate between Where and Orderby clause of SQL statements.
5. State the purpose of Update Command with the help of an example.
Grouping of Data To display the records containing the same type of values
“WHERE” clause can be used with the Select SQL Command. To get details
about the list of students whose favorite color is blue, you can use: select *
from SDetails where Color=’Blue’;
Form:
Write down the name of various form controls:
1. Label: used for heading in forms.
2. Textbox: used for taking user input.
3. Option box: used for making radio button for heading.
We can choose only one option button ata time.
4. Checkbox: used for displaying multiple options.
We can choose more than one option at a time.
5. Push button: To associate some action/execute an action on
database object like: submit form,reset, move to first record
etc.
6. Listbox: can create a dropdown list and choose a item from
the pre define list items:
7. Combobox:can create a dropdown list and choose a item
from the define list items but we can add more list items.:
Short Answer Questions:
1. Why is there a need to create Forms?
Ans. A form provides the user a systematic way of storing information into the
database.
It is an interface in a user specified layout that lets users to view, enter, and change
data directly in database objects such as tables.
2. What is the purpose of creating Reports?
Ans. A report helps to display the data in a summarized manner.
It is used to generate the overall work outcome in a clear format. You can create
reports in the database
3. What are the prerequisites to create a Form and Reports?
Ans. The Data source i.e table must be selected from using which data can be
displayed in a format as required.
4. Differentiate between Forms and Reports.
Ans. Forms are visual representations that are basically used to take user's Input or
information, while Reports are gathered the information for a task that is generally
shown as an output.
5. Can a form displays data from queries?
Ans. Yes, as a form is a database object that we can use to enter, edit, or display
data from a table or a query. We can use forms to control access to data, such as
which fields of data are displayed. For example, certain users may not need to see
all of the fields in a table.

6. In how many ways Forms and Reports can be created in a database?


Ans. Forms and Reports can be created in two ways:
● Create Form in design View.
● Create Form using wizard.
Fill in the blanks:
1. To create a form you need to select _________ option available under
Database section.
2. A ______ is helps to collect specific information from the pool of data in the
database.
3. ________ is used to display the display the summary of data.
4. _________ are the interfaces with which the user interacts.
5. Data from multiple tables can be stored in _______.

You might also like