Databases
Databases
DATABASE SYSTEMS
(DIT Part-II)
GENERAL OBJECTIVES:
[31]
| KP BT&CE DIT-2 Year Curriculum
Allotted Contact
Module Course Contents
Weeks Hours
INTRODUCTION TO DATABASE CONCEPTS
1.1 Definition of Database
1.2 Importance/Advantages of Databases
1.3 Database Models
1.3.1 Hierarchical
1.3.2 Network
1.3.3 Relational
1.4 Definition of Database Management System (DBMS)
1.4.1 Relational DBMS (SQL Based)
(MS Access, MS SQL, MySQL, ORACLE)
01
1.4.2 Non-Relational DBMS (NoSQL) 06
01 Week
(MongoDB, HBase, Cassandra)
1.5 Functions of DBMS
1.5.1 Data Dictionary Management
1.5.2 Data Storage Management
1.5.3 Data Integrity Management
1.5.4 Backup & Recovery Management
1.5.5 Security Management
1.5.6 Multi-User Access Control
DATA MODELLING
3.1 Introduction to Data Modelling & its importance
3.2 Definition of Entity Relationship Diagram (ERD)
3.3 Elements of ERD
3.4 Transforming ERD to Relational Schema 03
03 3.5 Normalization of Relational Database 18
Weeks
3.5.1 First Normal Form (1NF)
3.5.2 Second Normal Form (2NF)
3.5.3 Third Normal Form (3NF)
ii. COUNT()
iii. CONCAT()
iv. LOWER()
v. LENGTH()
vi. LTRIM()
vii. MIN()
viii. MAX()
ix. RTRIM()
x. REPLACE()
xi. REPEAT()
xii. STRCMP()
xiii. SUBSTR()
xiv. SUM()
xv. UPPER()
4.3.7 MySQL Operators
i. Arithmetic Operators
ii. Comparison Operators
iii. Logical Operators
4.3.8 Views
i. CREATE VIEW statement
ii. DROP VIEW statement
4.3.9 MySQL Joins
i. INNER JOIN
ii. LEFT JOIN
iii. RIGHT JOIN
iv. CROSS JOIN
4.3.10 Front-end-Development
i. Connection MS Access to MySQL Database.
ii. Creating Forms for MySQL Databases
iii. Creating Reports for MySQL Databases
TOTAL 20 120
Software Requirements:
Lab Minimum Windows 7 (64-bit, Professional level or higher)
Requirements Mac OS X 10.6.1+
(Software) Ubuntu 9.10 (64bit)
Ubuntu 8.04 (32bit/64bit)
Practical Description
Number
Downloading and Installation of MySQL Server 8.0:
1. Download MySQL Community Server from
dev.mysql.com/downloads/mysql/
List of 2. Install MySQL Server 8.0, MySQL Workbench 8.0 and MySQL
Practical Shell 8.0 as follow: (a) Run the downloaded mysql-installer-
1 community-8.0 file. (b) Choose the Custom setup type, click Next.
Click Execute then Next. (d) Leave default settings on Type and
[34]
| KP BT&CE DIT-2 Year Curriculum
next. Create a MySQL Root Password and click next. Leave default
settings and click next. Click Execute. Click Finish. (e) Enter
password and click check. Then Next and then Execute. Finally
click Finish, Next and Finish. (f) The MySQL Workbench 8.0 and
MySQL Shell tool will be started.
variable.
Starting MySQL Server and Establishing the Session/Connection:
1. The MySQL Server will automatically start by starting windows
because it was selected by default during the installation of MySQL
Server.
2. If MySQL Server is not started automatically, then (a) Write
\
command and press enter key to change command prompt to SQL
\
enter key. Then enter the password. Choose whether to save
password or not. (e) If your MySQL Connection Id is shown, then
Server is started and connection is established successfully. (f)
Now here all SQL commands can be used to play with MySQL
databases.
MySQL Workbench User Interface:
1. Start MySQL Workbench 8.0. Title bar shows the application name
3.
3
home Tab icon (on the left) to go to the Home Screen.
4. The toolbar available under the menu bar contains controls for
creating a new database (Schema), new table, new view, SQL tab
etc.
5. In the Navigator Pane, two Tabs are available; Administration and
Schemas. Administration Tab provides features for managing the
server, clients etc. Schemas Tab allows to manage Databases.
6. Click on Schemas Tab to show available databases.
Using MySQL Shell tool for exploring available databases:
1. Connect to MySQL Server as explained in step-3 of practical No-2
4 above.
2.
databases are shown.
[35]
| KP BT&CE DIT-2 Year Curriculum
3.
be set to World. (Note the prompt which contains database name)
4.
will be shown.
5.
will be shown.
6. CTRL + L is used to clear screen. CTRL + C is used to interrupt
execution.
Creating and Deleting a MySQL Database:
1. Connect to MySQL Server as explained in step-3 of practical No-2
above.
2.
5 3.
4.
contains both DBs.
5.
SHOP Db.
Creating table in a MySQL database:
1. Connect to MySQL Server as explained in step-3 of practical No-2
above.
2.
to College.
3.
6
database. It is currently empty because it was only created in
practical No-5 above.
4.
command to create a new table called Student.
5.
6. Extract all data from Student table using SELECT statement.
Adding more attributes in existing table:
1. Start
2. Use the ALTER TABLE - ADD statement to add two more
7 columns (City and Phone No) in Student table.
3. Use UPDATE statement to populate these two new columns with
data.
4. Extract all records using SELECT statement.
Deleting a Column of a Table and Changing data type of a Column:
1.
2. Show all data of Student table by using SELECT statement.
3. Use ALTER TABLE- DROP COLUMN statement to delete city
column.
8
4. Use DESC statement to show the structure of Student table.
5. Use ALTER TABLE MODIFY COLUMN statement to change
the data type of phone column from VARCHAR to BIGINT.
6. Again use the DESC statement to show the structure of Student
table.
Creating a duplicate table and setting the Primary Key:
1.
2. Show all data of Student table by using SELECT statement.
3.
9
called studentcopy.
4. Show all records of the new table.
5.
command to set the ID field as Primary key of studentcopy table.
6.
[36]
| KP BT&CE DIT-2 Year Curriculum
Deleting only data from table and then using INSERT INTO SELECT:
1.
2. Show all data of studentcopy table by using SELECT statement.
3.
10 all records in the studentcopy table and then check, it will be empty.
4. Now execute this command to fill the studentcopy table again with
SELECT *
password.
2.
shown.
3.
in use.
4.
13 NOT NULL, SNAME VARCHAR(15), SCITY TEXT(15),
1. practical No-13
above, in MySQL Workbench.
2.
grid user interface.
3. Create following 4 more tables in similar way in the MySQL
14 Workbench.
a. MedicineType ( TID(int), TYPE(text) )
b. Medicine ( MID(int), MNAME(text), MPRICE(int),
MEXPIRY(date), SID(int), TID(int) )
c. CustomerOrdersMedicine (ORDID(int), MID(int),
Quantity(int) )
d. CustomerOrders ( ORDID(int), CID(int), ORDDATE(date) )
[37]
| KP BT&CE DIT-2 Year Curriculum
3.
4. Create new data source window opens up. In the list search for
list, then you
16 have to download it as explained in practical No-17 below.
5.
6.
Successf
4.
[38]