0% found this document useful (0 votes)
3 views4 pages

DBMS Lab Assignment 1

The document outlines an assignment for a Database Management Systems course, focusing on creating a database named StudentDB with a table for students. It provides an introduction to SQL and MySQL, explaining key concepts such as relational databases, tables, and RDBMS terminology. The document also includes practical instructions for creating and managing databases and tables using MySQL commands.

Uploaded by

Vaibhav Chate
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

DBMS Lab Assignment 1

The document outlines an assignment for a Database Management Systems course, focusing on creating a database named StudentDB with a table for students. It provides an introduction to SQL and MySQL, explaining key concepts such as relational databases, tables, and RDBMS terminology. The document also includes practical instructions for creating and managing databases and tables using MySQL commands.

Uploaded by

Vaibhav Chate
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Subject Name- CI2012: Database Management Systems Class: SY-CSAI-E Roll no: 01

Assignment No:1

Title: Introduction to SQL.

Problem Statement: Create a database named StudentDB and a table named Students with
fields ID, Name, Age, and Course.

Course Objective: To understand DBMS basics, data models, and user roles.

Course Outcome: Describe the fundamentals of DBMS, various data models, architectures, and
the responsibilities of users and administrators.

Tools Required: MySql.

Theory:

1. Introduction:

SQL (Structured Query Language) is a standard language used to manage and interact with
databases. It allows you to store, retrieve, update, and delete data in a relational database.
MySQL is the most popular Open Source Relational SQL database management system. MySQL
is a fast, easy-to-use RDBMS being used for many small and big businesses. MySQL is popular
because:
 It is released under open source
 It handles a large subset of the functionality of the most expensive and powerful database
packages, it uses standard form of the well-known SQL data language,
 works on many operating systems and with many languages including PHP, PERL, C,
C++, JAVA, etc.
 MySQL works very quickly and works well even with large data sets and with PHP.
MySQL supports large databases, up to 50 million rows or more in a table.
 The default file size limit for a table is 4GB, but we can increase this (if your operating
system can handle it) to a theoretical limit of 8 million terabytes (TB)

1.1 Relational Database


A relational database organizes data in tables, like rows and columns in Excel.
 Database: A database is a collection of tables, with related data.
 Table: A table is a matrix with data. A table in a database looks like a simple
spreadsheet.
 Column: One column (data element) contains data of one and the same kind, for
example the column postcode.
 Row: A row (= tuple, entry or record) is a group of related data, for example the
data of one subscription.

2. What is Database?
A database is a separate application that stores a collection of data. Each database has one or
more distinct APIs for creating, accessing, managing, searching and replicating the data it holds.

Computer Science and Engineering (Artificial Intelligence), VIT Pune. Page 1


Subject Name- CI2012: Database Management Systems Class: SY-CSAI-E Roll no: 01

Other kinds of data stores can be used, such as files on the file system or large hash tables in
memory but data fetching and writing would not be so fast and easy with those types of systems.
So nowadays, we use relational database management systems (RDBMS) to store and manage
huge volume of data. This is called relational database because all the data is stored into
different tables and relations are established using primary keys or other keys known as foreign
keys.
A Relational DataBase Management System (RDBMS) is a software that:
 Enables you to implement a database with tables, columns and indexes.
 Guarantees the Referential Integrity between rows of various tables.
 Updates the indexes automatically.
 Interprets an SQL query and combines information from various tables.

3. RDBMS Terminology:
Before we proceed to explain MySQL database system, let's revise few definitions related to
database.
 Database: A database is a collection of tables, with related data.
 Table: A table is a matrix with data. A table in a database looks like a simple
spreadsheet.
 Column: One column (data element) contains data of one and the same kind, for
example the column postcode.
 Row: A row (= tuple, entry or record) is a group of related data, for example the data of
one subscription.
 Redundancy: Storing data twice, redundantly to make the system faster.
 Primary Key: A primary key is unique. A key value can not occur twice in one table.
With a key, you can find at most one row.
 Foreign Key: A foreign key is the linking pin between two tables.
 Compound Key: A compound key (composite key) is a key that consists of multiple
columns, because one column is not sufficiently unique.
 Index: An index in a database resembles an index at the back of a book.
 Referential Integrity: Referential Integrity makes sure that a foreign key value always
points to an existing row.

4. MySQL Connection
[root@host]# mysql -u root -p
Enter password:******

4.1 Create Database


mysql> CREATE DATABASE menagerie;

4.2 Selecting Database


mysql> USE menagerie
Database changed

4.3 Drop Database


mysql> DROP DATABASE TUTORIALS

Computer Science and Engineering (Artificial Intelligence), VIT Pune. Page 2


Subject Name- CI2012: Database Management Systems Class: SY-CSAI-E Roll no: 01

4.4 Create MySQL Tables


Syntax:
CREATE TABLE table_name
(
column_name1 data_type(size),
column_name2 data_type(size),
column_name3 data_type(size),
....
);

Example:
CREATE TABLE Persons
(
PersonID int,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
);

4.5 ALTER
Syntax:
ALTER TABLE table_name ADD column_name datatype;
ALTER TABLE table_name DROP COLUMN column_name;
ALTER TABLE table_name MODIFY COLUMN column_name datatype;

Example:
ALTER TABLE Persons ADD DateOfBirth date;
ALTER TABLE Persons ALTER COLUMN DateOfBirth int;
ALTER TABLE Persons DROP COLUMN DateOfBirth;

4.6 DROP
DROP TABLE table_name;
DROP DATABASE database_name;

Conclusion: Hence, we have successfully created a database and table.

Computer Science and Engineering (Artificial Intelligence), VIT Pune. Page 3


Subject Name- CI2012: Database Management Systems Class: SY-CSAI-E Roll no: 01

Query and Output:

Computer Science and Engineering (Artificial Intelligence), VIT Pune. Page 4

You might also like