DBMS Lab Record Weekwise
DBMS Lab Record Weekwise
Step 1: Go to the official website of MySQL and download the community server edition software. Here,
you will see the option to choose the Operating System, such as Windows.
Step 2: Next, there are two options available to download the setup. Choose the version number for the
MySQL community server, which you want. If you have good internet connectivity, then choose the
mysql-installer-web-community. Otherwise, choose the other one.
Step 2: In the next wizard, choose the Setup Type. There are several types available, and you need to
choose the appropriate option to install MySQL product and features. Here, we are going to select
the Full option and click on the Next button.
This option will install the following things: MySQL Server, MySQL Shell, MySQL Router, MySQL
Workbench, MySQL Connectors, documentation, samples and examples, and many more.
Step 3: Once we click on the Next button, it may give information about some features that may fail to
install on your system due to a lack of requirements. We can resolve them by clicking on
the Execute button that will install all requirements automatically or can skip them. Now, click on the
Next button.
Step 4: In the next wizard, we will see a dialog box that asks for our confirmation of a few products not
getting installed. Here, we have to click on the Yes button.
After clicking on the Yes button, we will see the list of the products which are going to be installed. So, if
we need all products, click on the Execute button.
Step 5: Once we click on the Execute button, it will download and install all the products. After
completing the installation, click on the Next button.
Step 6: In the next wizard, we need to configure the MySQL Server and Router. Here, I am not going to
configure the Router because there is no need to use it with MySQL. We are going to show you how to
configure the server only. Now, click on the Next button.
Step 7: As soon as you will click on the Next button, you can see the screen below. Here, we have to
configure the MySQL Server. Now, choose the Standalone MySQL Server/Classic MySQL Replication
option and click on Next. Here, you can also choose the InnoDB Cluster based on your needs.
Step 8: In the next screen, the system will ask you to choose the Config Type and other connectivity
options. Here, we are going to select the Config Type as 'Development Machine' and Connectivity
as TCP/IP, and Port Number is 3306, then click on Next.
Step 9: Now, select the Authentication Method and click on Next. Here, I am going to select the first
option.
Step 10: The next screen will ask you to mention the MySQL Root Password. After filling the password
details, click on the Next button.
Step 11: The next screen will ask you to configure the Windows Service to start the server. Keep the
default setup and click on the Next button.
Step 12: In the next wizard, the system will ask you to apply the Server Configuration. If you agree with
this configuration, click on the Execute button.
Step 13: Once the configuration has completed, you will get the screen below. Now, click on
the Finish button to continue.
Step 14: In the next screen, you can see that the Product Configuration is completed. Keep the default
setting and click on the Next-> Finish button to complete the MySQL package installation.
Step 15: In the next wizard, we can choose to configure the Router. So click on Next->Finish and then
click the Next button.
Step 16: In the next wizard, we will see the Connect to Server option. Here, we have to mention the root
password, which we had set in the previous steps.
In this screen, it is also required to check about the connection is successful or not by clicking on the
Check button. If the connection is successful, click on the Execute button. Now, the configuration is
complete, click on Next.
Step 17: In the next wizard, select the applied configurations and click on the Execute button.
Step 18: After completing the above step, we will get the following screen. Here, click on the Finish
button.
Step 19: Now, the MySQL installation is complete. Click on the Finish button.
Verify MySQL installation
Once MySQL has been successfully installed, the base tables have been initialized, and the server has
been started, you can verify its working via some simple tests.
Open your MySQL Command Line Client; it should have appeared with a mysql> prompt. If you have
set any password, write your password here. Now, you are connected to the MySQL server, and you can
execute all the SQL command at mysql> prompt as follows:
For example: Check the already created databases with show databases command:
STRUCTURE OF A DBMS
E-R Model
Aim: Analyze the problem and come with the entities in it. Identify what Data has to be
persisted in the databases.
Student must know the entities and attributes and representation of diagrams The
Following are the entities:
Identify the primary keys for all the entities. Identify the other keys like candidate keys,
partial keys, if any.
Example:
Entities: 1. BUS
2. Ticket
3. Passenger
Relationships: 1. Reservation
2. Cancellation
E-R Model
Bus
- BusNo
- Source
- Destination
- CoachType
SCHEMA
SCHEMA
SCHEMA
SCHEMA
Reservation(PNRNo: String, DOJ: Date, NoofSeats: integer , Address: String ,ContactNo:
String, , BusNo: String,SeatNo:Integer)
Cancellation
- PNRNo
- DOJ
- SeatNo
- ContactNo
- Status
SCHEMA
Aim: To Relate the entities appropriately. Apply cardinalities for each relationship.
Identify strong and weak entities. Indicate the type of relationships (total/partial).
Incorporate generalization, aggregation and specialization etc wherever required.
Prerequisites: Student must know the entities and attributes and relationship among entities
WEEK-2
Experiment-2: RELATIONAL MODEL
Aim: To Represent all the entities (Strong, Weak) in tabular fashion. Represent
relationships in a tabular fashion.
Mysql>desc Bus;
Ticket:
Mysql>desc Ticket;
Passenger:
Type of
ColumnName Datatype Constraints
Attributes
PassportID Varchar(15) Primary Key Single-valued
TicketNo Varchar(20) Foreign Key Single-valued
Name Varchar(20) Composite
ContactNo Varchar(20) Multi-valued
Age Integer Single-valued
Sex character Simple
Address Varchar(20) Composite
Aim: Apply the database Normalization techniques for designing relational database
tables to minimize duplication of information like 1NF, 2NF, 3NF, BCNF.
1NF: A Relation scheme is said to be in 1NF if the attribute values in the relation are
atomic.i.e., Mutli –valued attributes are not permitted.
2NF: A Relation scheme is said to be in 2NF,iff and every Non-key attribute is fully
functionally dependent on primary Key.
3NF: A Relation scheme is said to be in 3NF,iff and does not have transitivity
dependencies. A Relation is said to be 3NF if every determinant is a key for each & every
functional dependency.
BCNF: A Relation scheme is said to be BCNF if the following statements are true for eacg
FD P->Q in set F of FDs that holds for each FD. P->Q in set F of FD’s that holds over R.
Here P is the subset of attributes of R & Q is a single attribute of R.
WEEK-4
EXPERIMENT-4:Practicing DDL commands
Aim : Create a DML Commands are used to manage data within the scheme
DML Commands:
(0.03 sec)
(0.03 sec)
(0.03 sec)
WEEK-6
EXPERIMENT-6:Queries using Aggregate functions, GROUP BY, HAVING and Creation and dropping of Views.
RESERVATION2
PNR_No
10201
10202
10203
10204
Name
Rajesh
Ramesh
Ramesh
Name
Akash
Arivind
Avinash
B). Aim: To Practice Queries using Aggregate functions for the following
UNION
C). Querying using GROUP BY ,HAVING and Creation and Droping of views Aim: To
5. Find the number of tickets booked by a passenger where the number of seats
is greater than 1.
6. Find the total number of cancelled seats.
5. Find the number of tickets booked by a passenger where the number of seats is
greater than 1.
PRIMARY KEY(BUSNO));
NOT NULL, CHANGEDON DATETIME DEFAULT NULL, ACTION VARCHAR(10) DEFAULT NULL,
PRIMARY KEY(ID));
BEGIN
SET action='update',
source=OLD.source,
changedon=NOW();
END$$
BEGIN
SET action='Insert',
source=NEW.source,
changedon=NOW();
END$$
iii)
DELETE ON BUS
BEGIN
SET action='Insert',
source=NEW.source,
changedon=NOW();
END$$
BEGIN
ELSE
SET New.TicketNo = 0;
END IF;
END;
WEEK-8
EXPERIMENT-8:Procedures
EXPERIMENT-1:
BEGIN
END$$
CALL BUS_PROC1()$$
EXPERIMENT-2:
BEGIN
DECLARE X INT(3);
SET X=10;
END$$
END$$
EXPERIMENT-9:Usage of Cursors
Aim: Declare a cursor that defines a result set. Open the cursor to establish the result set.
Fetch the data into local variables as needed from the cursor, one row at a time. Close the
cursor when done.
Cursors
In MySQL, a cursor allows row-by-row processing of the result sets. A cursor is used for the
result set and returned from a query. By using a cursor, you can iterate, or by step through the
results of a query and perform certain operations on each row. The cursor allows you to iterate
through the result set and then perform the additional processing only on the rows that require it.
In a cursor contains the data in a loop. Cursors may be different from SQL commands that
operate on all the rows in the returned by a query at one time.
Declare a cursor
2 . Open a cursor statement : For open a cursor we must use the open statement.If we want
to fetch rows from it you must open the cursor.
3 . Cursor fetch statement : When we have to retrieve the next row from the cursor and
move the cursor to next row then you need to fetch the cursor.
If any row exists, then the above statement fetches the next row and cursor pointer moves ahead
to the next row.
Syntax: CLOSE_name;
By this statement we can close the previously opened cursor. If it is not closed explicitly then a
cursor is closed at the end of compound statement in which that was declared.
Delimiter $$
fetch c1 into
v_id,v_name; if
v_finished=1 then
leave std;
end if;
select concat(v_id,v_name);
end LOOP std;
close c1;
end;