EE221 Databases Practicals Manual

Similar documents
In mathematical terms, the relation itself can be expressed simply in terms of the attributes it contains:

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL)

Chapter 7. Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel

SQL functions fit into two broad categories: Data definition language Data manipulation language

tablename ORDER BY column ASC tablename ORDER BY column DESC sortingorder, } The WHERE and ORDER BY clauses can be combined in one

T-SQL Training: T-SQL for SQL Server for Developers

G64DBS Database Systems. Lecture 7 SQL SELECT. The Data Dictionary. Data Dictionaries. Different Sections of SQL (DDL) Different Sections of SQL (DCL)

Chapter 1 SQL and Data

Unit 27 Web Server Scripting Extended Diploma in ICT

Chapter-14 SQL COMMANDS

CSC Web Programming. Introduction to SQL

Networks and Web for Health Informatics (HINF 6220)

The University of Nottingham

Lecture 07. Spring 2018 Borough of Manhattan Community College

Chapter 8: Working With Databases & Tables

Concepts of Database Management Seventh Edition. Chapter 4 The Relational Model 3: Advanced Topics

SQL Interview Questions

More MySQL ELEVEN Walkthrough examples Walkthrough 1: Bulk loading SESSION

Data about data is database Select correct option: True False Partially True None of the Above

Index. Bitmap Heap Scan, 156 Bitmap Index Scan, 156. Rahul Batra 2018 R. Batra, SQL Primer,

B.H.GARDI COLLEGE OF MASTER OF COMPUTER APPLICATION. Ch. 1 :- Introduction Database Management System - 1

Chapter # 7 Introduction to Structured Query Language (SQL) Part I

Indexes (continued) Customer table with record numbers. Source: Concepts of Database Management

Interview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept]

Database Management System 9

THE COPPERBELT UNIVERSITY

CPS221 Lecture: Relational Database Querying and Updating

SQL language. Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c)

Informatics 1: Data & Analysis

CPS221 Lecture: Relational Database Querying and Updating

Informatics 1: Data & Analysis

STRUCTURED QUERY LANGUAGE (SQL)

CS 327E Lecture 2. Shirley Cohen. January 27, 2016

Informatics 1: Data & Analysis

chapter 2 G ETTING I NFORMATION FROM A TABLE

Oracle Database: Introduction to SQL Ed 2

SQL Fundamentals. Chapter 3. Class 03: SQL Fundamentals 1

CMPT 354: Database System I. Lecture 2. Relational Model

Advance Database Systems. Joining Concepts in Advanced SQL Lecture# 4

Using the SQL Editor. Overview CHAPTER 11

SQL Commands & Mongo DB New Syllabus

QUETZALANDIA.COM. 5. Data Manipulation Language

Relational terminology. Databases - Sets & Relations. Sets. Membership

CMPT 354: Database System I. Lecture 3. SQL Basics

Oracle Database 10g: Introduction to SQL

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Mastering phpmyadmiri 3.4 for

GlobAl EDITION. Database Concepts SEVENTH EDITION. David M. Kroenke David J. Auer

CGS 3066: Spring 2017 SQL Reference

30. Structured Query Language (SQL)

Data Manipulation Language (DML)

COSC 304 Introduction to Database Systems SQL DDL. Dr. Ramon Lawrence University of British Columbia Okanagan

EGCI 321: Database Systems. Dr. Tanasanee Phienthrakul

Querying Data with Transact-SQL

Database Management Systems,

Chapter 4. Basic SQL. SQL Data Definition and Data Types. Basic SQL. SQL language SQL. Terminology: CREATE statement

Assignment 6: SQL III Solution

Implementing Table Operations Using Structured Query Language (SQL) Using Multiple Operations. SQL: Structured Query Language

20761B: QUERYING DATA WITH TRANSACT-SQL

SQL IN PL/SQL. In this chapter, you will learn about: Making Use of DML in PL/SQL Page 68 Making Use of Savepoint Page 77

Introduction to SQL Part 1 By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford)

SQL: Concepts. Todd Bacastow IST 210: Organization of Data 2/17/ IST 210

Course Outline Faculty of Computing and Information Technology

Lecture 5. Monday, September 15, 2014

Chapter 4. Basic SQL. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

COMP 430 Intro. to Database Systems. Encapsulating SQL code

Chapter 13 : Informatics Practices. Class XI ( As per CBSE Board) SQL Commands. New Syllabus Visit : python.mykvs.in for regular updates

Sql Server Syllabus. Overview

QQ Group

School of Computing and Information Technology. Examination Paper Autumn Session 2017

Unit Assessment Guide

Databases and SQL programming overview

FIT 100 More Microsoft Access and Relational Databases Creating Views with SQL

UFCEKG 20 2 : Data, Schemas and Applications

SYSTEM CODE COURSE NAME DESCRIPTION SEM

Ministry of Higher Education and Scientific research

MySQL for Beginners Ed 3

SQL Functionality SQL. Creating Relation Schemas. Creating Relation Schemas

Querying Data with Transact-SQL

Oracle Database 11g: SQL and PL/SQL Fundamentals

Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.

Oral Questions and Answers (DBMS LAB) Questions & Answers- DBMS

Simple Quesries in SQL & Table Creation and Data Manipulation

Oracle Database 10g Express

Informatics 1: Data & Analysis

Course Design Document: IS202 Data Management. Version 4.5

Querying Data with Transact-SQL

Oracle 1Z Oracle Database 11g SQL Fundamentals I. Download Full Version :

SQL Data Definition Language: Create and Change the Database Ray Lockwood

Exam code: Exam name: Database Fundamentals. Version 16.0

Introduction to Computer Science and Business

CS317 File and Database Systems

INFORMATION TECHNOLOGY NOTES

Course Outline. Querying Data with Transact-SQL Course 20761B: 5 days Instructor Led

MySQL 5.0 Certification Study Guide

NCSS: Databases and SQL

6.1 Understand Relational Database Management Systems

CISC 3140 (CIS 20.2) Design & Implementation of Software Application II

Database Programming - Section 18. Instructor Guide

Assignment Session : July-March

Transcription:

EE221 Databases Practicals Manual Lab 1 An Introduction to SQL Lab 2 Database Creation and Querying using SQL Assignment Data Analysis, Database Design, Implementation and Relation Normalisation School of Electronic Engineering, Dublin City University, 2007 Authors: C. McArdle & T. Curran

EE221 Databases Lab 1 An Introduction to SQL Objective Prerequisites Procedure To introduce the SQL language and to familiarise the student with writing basic SQL statements and using a DBMS to query a simple database. 1. To complete this lab, you will need to be familiar with the course notes on the Relational Model and Relational Languages. 2. You will need to have read this lab manual, including the SQLite Introduction (Appendix A), in advance of the lab session. During the lab session, complete all the exercises highlighted in boxed text below. Make a note of the results obtained and answer any questions in your lab notebook. Firmly attach any printouts in your lab notebook. Lab notebooks must be handed in to the demonstrator at the end of the lab session. There are 3 hours allocated for completion of this lab. Introduction to SQL SQL (Structured Query Language) is the standard language used for creating, updating and querying relational databases. It is supported by all modern database management systems (e.g. Oracle, IBM DB2, Microsoft Access, Microsoft SQL Server, PostgreeSQL, MySQL, etc.). SQL is based on the relational model introduced in the course notes, but is not a strict implementation of all the relational rules. This means that it is up to the programmer to enforce the necessary relational rules; they are not automatically enforced by the database management system. You will investigate the differences between SQL and the relational model in Lab 2. SQL is a declarative language (as opposed to a procedural language like C, Perl, etc.). This means that the language is used by the programmer to directly describe what end result is required (e.g. what data is required from a query operation), as opposed to explicitly describing all the steps required to retrieve the required data from storage). Thus, SQL is high-level, quite easy to learn, allowing complex tasks on a database to be specified simply. SQL has a defined syntax that specifies how standard keywords can be combined to form valid SQL statements. SQL statements can be divided into three categories, according to their function: EE221 Databases Laboratory Manual Lab 1 Page 1 of 8

1. Data Manipulation: Statements that retrieve, insert, update, edit or delete data stored in database tables. These statements begin with the keywords: SELECT, INSERT, UPDATE or DELETE. 2. Data Definition: Statements that create, modify, or destroy database objects (such as tables). These statements begin with the keywords: CREATE, ALTER or DROP. 3. Data Control: Statements that authorise certain users to view, change or delete data. These statements begin with the keywords: GRANT or REVOKE. We do not consider data control in the lab exercises. SQL statements consist of one or more clauses each of which begins with an SQL keyword. For example, the SQL statement SELECT last_name FROM students WHERE first_name = John ; has three clauses: a SELECT clause, a FROM clause and a WHERE clause. The net result of this statement should be easy to understand: a list of students last names, whose first name is John, will be retrieved from the table named students. student_id first_name last_name 105 Sean Murphy 101 John Smith 109 Mary Douglass 108 Jane Smith 104 John Murphy Example values in a students table last_name Smith Murphy Result of the SQL SELECT statement EE221 Databases Laboratory Manual Lab 1 Page 2 of 8

In the above statement we see the other main elements of the SQL language, namely: Identifiers: the names of tables (students) and columns in tables (last_name and first_name) Literals: quoted strings and numeric values, for example John Delimiters: + -, ( ) = < > <= >= <>. * /? ; In the example above we see the delimiters = and ; used. Note that all SQL statements must end with a semicolon (;). Table names can be qualified using the dot (.) separator. For example, we could have specified the last_name column in the above statement as students.last_name, meaning the last_name column of the students table. Use of qualification may be required when tables in a database happen to use the same column names (e.g. students.last_name and lecturers.last_name in a database containing the two tables students and lecturers). We will now explore the syntax of the most common SQL statements. More detail on the SQL statements supported by the DBMS we will use in the lab may be found at: http://www.sqlite.org/lang.html. A more extensive SQL reference may be found at: http://www.redhat.com/docs/manuals/database/rhdb-7.1- Manual/sql/reference.html Basic SELECT statements The SELECT statement is used to retrieve data from tables in a database. The statement operates on one or more tables in the database and returns a result in the form of one new result table. The basic from of the statement begins with the SELECT clause, which specifies which column values are to be retrieved. It is followed by the FROM clause, which specifies which table to retrieve values from. The WHERE clause is used to filter rows based on a given condition. WHERE is optional and, if omitted, all result table rows are returned. An optional ORDER BY clause may be used to sort the data retrieved. Examples: SELECT * FROM students; SELECT first_name, last_name FROM students; EE221 Databases Laboratory Manual Lab 1 Page 3 of 8

SELECT * FROM students WHERE student_id > 104; SELECT last_name FROM students WHERE (student_id > 102) AND (student_id <110) ORDER BY last_name ASC; SELECT DISTINCT last_name FROM students WHERE (student_id > 102) AND (student_id <110) ORDER BY last_name DESC; SELECT student_id FROM students WHERE first_name IS NULL; The DISTINCT keyword may be used to remove duplicate rows from the result of a query. (Note that the need for the DISTINCT keyword in SQL indicates a variance from the strict relational model. In relational theory all result tables must be valid relations, so duplicate rows are removed from a result automatically.) EXERCISE 1A Copy the lab1 sql text from Appendix B and paste it into a text editor. Save the file as lab1.sql. Read through the file and try to understand the structure of the data in the database. (i) (ii) (iii) (iv) Load your lab1.sql file into SQLite (using the.read command) and then execute each of the six select statements (above) at the command line. Note the result table of each statement in your lab notebook and explain concisely what data each statement is retrieving from the database. Write a SELECT statement to retrieve the student ids of all students with last name Murphy. Is it possible to alter data in a database using a SELECT statement? How would the last select statement above be written using relational algebra? EE221 Databases Laboratory Manual Lab 1 Page 4 of 8

SELECT statements using JOIN A join is a table operation that uses related columns to combine rows from two input tables to form one output (result) table. Often the most interesting database information is stored across multiple tables and requires joining to retrieve it. In SQL, joins are performed by using a JOIN clause (combined with an ON clause) in a SELECT statement. For example, the lab1 database (see Appendix B) contains the tables students and registrations: students student_id first_name last_name 105 Sean Murphy 101 John Smith 109 Mary Douglass 108 Jane Smith 104 John Murphy registrations student_id module_id 101 200 104 200 105 200 104 201 105 201 109 201 101 202 104 202 109 202 The SELECT statement with a JOIN clause, as below, will retrieve the full names of students and the ids of modules for which they are registered: SELECT students.first_name, students.last_name, registrations.module_id FROM students JOIN registrations ON students.student_id=registrations.student_id; Here we have joined the tables students and registrations on the condition that the student_id value is the same in both tables and then selected particular columns from the result of the join. EE221 Databases Laboratory Manual Lab 1 Page 5 of 8

A WHERE clause may be added to filter rows from the result. For example the statement below will retrieve the ids of all modules taken by Sean Murphy. SELECT registrations.module_id FROM students JOIN registrations ON students.student_id=registrations.student_id WHERE students.first_name= Sean AND students.last_name= Murphy ; When tables are joined based on the equality of the values of two columns (as in above cases) the join is called a natural join. There are a number of other types of join. An inner join is similar to a natural join except that any comparison operator may be used to match rows, not just equality. A left outer join returns all rows from the left table, not just the ones with corresponding values in the right table. If there are no corresponding rows in the right table for a given left table row, then the values of the right table rows are NULL values (blank) in the result. EXERCISE 1B (i) Execute the following queries on the lab1 database, name the type of join being performed in each case, and explain the difference in the result: SELECT students.first_name, students.last_name, module_id FROM students JOIN registrations ON students.student_id = registrations.student_id; SELECT students.first_name, students.last_name, module_id FROM students LEFT OUTER JOIN registrations ON students.student_id = registrations.student_id; (ii) Write a query to return the full name of students who are not registered for any module. Execute the query on the lab1 database and note the result. (Hint: the clause WHERE [column_name] IS NULL will be useful for writing this statement.) EE221 Databases Laboratory Manual Lab 1 Page 6 of 8

SELECT statements with more than one JOIN More than two tables may be joined in a single select statement, using multiple JOIN clauses in the SELECT statement. A select statement joining three tables would take the following form: SELECT [columns] FROM [table1] JOIN [table2] ON [join_condition_a] JOIN [table3] ON [join_condition_b]; Conceptually, this statement first joins table1 with table2 based on join_condition_a and then joins the result with table3 based on join_condition_b. [columns] specifies the columns required from the combined joined tables. A WHERE clause may also be used, which will filter rows from the combined result. EXERCISE 1C Using the lab1 database, write an SQL statement that returns the module ids and module names of all modules for which student Mary Douglass is registered. Execute the query on the lab1 database and note the SQL and the result table in your lab book. Other useful SQL statements are described below: The INSERT Statement The SQL INSERT statement allows new rows to be inserted into a table. Values for the columns in the new row may be specified in the same statement. For example, to insert a new student into the students table: INSERT INTO students VALUES(110, Peter, Hall ); The UPDATE Statement The SQL UPDATE statement changes the values of specified columns, for all rows which satisfy a condition in a WHERE clause. For example, to change Peter Hall s student id from 110 to 111: UPDATE students SET student_id=111 WHERE student_id=110; EE221 Databases Laboratory Manual Lab 1 Page 7 of 8

The DELETE Statement The SQL DELETE statement allows rows to be deleted from a table. For example, to delete all registrations for student with id 101: DELETE FROM registrations WHERE student_id=101; The CREATE TABLE Statement The SQL CREATE statement allows new (empty) tables to be created. A name and a data type is specified for each column in the table. Constraints, such as primary keys and foreign keys, may be specified. Note that clauses in the CREATE statement are separated with a comma. An example of a create statement is: CREATE TABLE registrations ( student_id SMALLINT, module_id SMALLINT, CONSTRAINT pk_registrations PRIMARY KEY (student_id, module_id), CONSTRAINT fk_registrations_students FOREIGN KEY (student_id) REFERENCES students (student_id), CONSTRAINT fk_registrations_modules FOREIGN KEY (module_id) REFERENCES modules (module_id) ); The DROP Statement The SQL DROP statement permanently removes a table from the database. For example, to remove the students table from the lab1 database: DROP TABLE students; EXERCISE 1D Using the lab1 database, perform the following update to the database, noting the required SQL statements in you lab notebook: Insert a new student ( James Stevens with ID 110) and register him for modules Maths and Databases. Check your updated data using a query similar to your solution to Exercise 1C. EE221 Databases Laboratory Manual Lab 1 Page 8 of 8

DB Lab 1 APPENDIX A SQLite Introduction You will use the SQLite database management system (DBMS) for all lab exercises. SQLite implements the most important SQL features and has an easy-to-use command-line interface. The programme may be found on Windows in Start/Programmes/SQLite. When it is run you will receive the SQLite command prompt in a DOS box as follows: SQLite version 3.4.1 Enter ".help" for instructions sqlite> SQLite is now running with C:/Temp as the working directory. Any files saved or loaded will be to/from this directory. Two types of command may be entered: 1. SQLite commands: these are commands directly to SQLite, allowing SQL files to be loaded/saved, output formats to be configured, output to be directed to a file, etc. All such commands start with a dot. 2. SQL statements: SQL statements can be entered directly at the command line. Each statement starts with an SQL keyword and ends with a semicolon (as described in the lab manual). Useful SQLite Commands.read [filename].tables.mode tabs.help.dump.dump table.output [filename] load an SQL file into the database show what tables are present in the database show output of queries in an easily read format show a synopsis of all SQLite commands show the SQL to construct the current database show the SQL to construct a particular table send the output to a file instead of to the screen Notes: SQL statements can be copied from the lab manual and pasted directly into SQLite by copying and right clicking to paste at the command prompt. Up and down arrow keys can be used to recall previously executed commands or SQL statements. You will only need to work on one database at a time, which will be stored in a temporary database in SQLite when tables are created. All tables created become part of the same database. To create a database, it is generally best to create an SQL text file and use the.read command to load it into SQLite. SQL queries that you write can also be saved in text files and loaded in the same way. It is then easy to edit the file and reload if corrections are necessary. Further information on SQLite is available at: http://www.sqlite.org EE221 Databases Laboratory Page 1 of 1

DB Lab 1 APPENDIX B SQL for the lab1 database -- -- EE221 Lab1 SQL database -- Records the modules for which students are registered -- DROP TABLE IF EXISTS students; CREATE TABLE students ( student_id SMALLINT, first_name VARCHAR(30), last_name VARCHAR(30), CONSTRAINT pk_students PRIMARY KEY (student_id) ); DROP TABLE IF EXISTS registrations; CREATE TABLE registrations ( student_id SMALLINT, module_id SMALLINT, CONSTRAINT pk_registrations PRIMARY KEY (student_id, module_id), CONSTRAINT fk_registrations_students FOREIGN KEY (student_id) REFERENCES students (student_id), CONSTRAINT fk_registrations_modules FOREIGN KEY (module_id) REFERENCES modules (module_id) ); DROP TABLE IF EXISTS modules; CREATE TABLE modules ( module_id SMALLINT, module_name VARCHAR(50), CONSTRAINT pk_modules PRIMARY KEY (module_id) ); INSERT INTO students VALUES(105, 'Sean', 'Murphy'); INSERT INTO students VALUES(101, 'John', 'Smith'); INSERT INTO students VALUES(109, 'Mary', 'Douglass'); INSERT INTO students VALUES(108, 'Jane', 'Smith'); INSERT INTO students VALUES(104, 'John', 'Murphy'); INSERT INTO registrations VALUES(101, 200); INSERT INTO registrations VALUES(104, 200); INSERT INTO registrations VALUES(105, 200); INSERT INTO registrations VALUES(104, 201); INSERT INTO registrations VALUES(105, 201); INSERT INTO registrations VALUES(109, 201); INSERT INTO registrations VALUES(101, 202); INSERT INTO registrations VALUES(104, 202); INSERT INTO registrations VALUES(109, 202); INSERT INTO modules VALUES(200, 'Maths'); INSERT INTO modules VALUES(201, 'Databases'); INSERT INTO modules VALUES(202, 'Digital'); EE221 Databases Laboratory Page 1 of 1

EE221 Databases Lab 2 Database Creation and Querying using SQL Objectives Prerequisites Procedure (i) To use the SQL language to create and populate database tables and to write more advanced SQL queries. (ii) To identify keys and functional dependencies in relations. (iii) To explore the differences between SQL and the theoretic relational model. 1. To complete this lab, you will need to be familiar with the course notes on the Relational Model, Relational Languages and Relational Design and Functional Dependency. 2. You will need to have previously completed Databases Lab 1. Complete the exercises below. Make a note of the results obtained and answer any questions in your lab notebook. Firmly attach any printouts in your lab notebook. Lab notebooks must be handed in to the demonstrator at the end of the lab session. 3 hours are allocated for completion of this lab. EXERCISE 2A (i) Add the tables below to the lab1 database (given in Appendix 1 of Lab 1) noting the SQL required in your lab notebook (or by attaching a printout in your notebook). (It may be convenient to edit your lab1.sql file to include the new SQL statements and then reload it into SQLite.) Table lecturers lecturer_id first_name last_name 302 James Crilly 303 Anne Joyce 305 Mary Finnegan Table teaches lecturer_id module_id 302 200 302 201 303 200 303 202 305 202 EE221 Databases Laboratory Manual Lab 2 Page 1 of 2

(ii) Identify all relation keys, foreign keys and functional dependencies of each of the five relations in the new database schema. (iii) Using your new database, write an SQL query to retrieve the full names of the lecturers(s) who teach Maths. Note the SQL and the result in your lab book. (iv) Write an SQL query to retrieve the full names of all lecturers who teach Sean Murphy. Note the SQL and the result in your lab book. (v) It would be possible to store all information in the database in one large table. This would have the advantage of not needing to write complex join queries. What would the disadvantages be? EXERCISE 2B Using INSERT and/or UPDATE statements explore how the SQLite implementation of SQL does or does not conform to the relational model, in terms of the following concepts described in the course notes: (i) (ii) (iii) Necessary properties of a relation (primary) keys Entity integrity Referential integrity Explain your method in each case. EE221 Databases Laboratory Manual Lab 2 Page 2 of 2

EE221 - Databases Assignment Data Analysis, Database Design, Implementation and Relation Normalisation Objectives Prerequisites Procedure (i) To analyse the requirements for a database, (ii) design the relational schema using E-R diagrams and (iii) implement the database and related queries in SQL. (iv) To identify the normal form of relations and normalise to a higher normal form, if necessary. To complete this assignment, you will need to be familiar with the course notes on the Relational Model, Data Modelling and E-R Diagrams, Relational Design and Functional Dependency and Normal Forms. Consider the following requirements for a database embedded in a portable music player and complete the exercises below. Make a note of the results obtained and answer any questions in your lab notebook. Firmly attach any printouts in your lab notebook. This exercise is given as an individual assignment. Shared work is not permitted. Lab notebooks must be handed in to the demonstrator on or before the deadline date, which you will be notified of in lectures. Database Requirements A database is required, as part of the software for a portable music player, to store and manipulate information about music files that are stored in the device. The database needs to store information on songs, artists and albums as follows. Music Player Database Requirements Each song has a title and a play length (stored in minutes and seconds). A single song can be associated with a number of artists (e.g. in the case of a duet or co-written song). An artist has a single name. Note that two (or more) different artists may happen to have the same names. Similarly, the titles of two (or more) different songs may happen to be the same. An artist may have different versions of the same song. An album is a collection of songs. The originating track number of each song from the album CD must be stored in the database. Two (or more) albums may have the same name. A song can be part of more than one album (e.g. in the case of an album originally released and a subsequent compilation album). EE221 Databases Laboratory Manual Databases Assignment Page 1 of 2

The following queries will need to be performed on the data in the database: 1. List the titles of all albums in the database in alphabetic order. 2. List all song titles by a chosen artist. 3. List all songs on a particular album, along with their track numbers, in order of track number. Database Design Exercise (i) Draw a basic Entity-Relationship diagram for the database schema, showing only the entities and the relationships (with multiplicities) between them. This E-R diagram can include many-to-many relationships. (ii) Refine your model and draw a second Entity-Relationship diagram for the database schema. This diagram should replace any many-to-many relationships with new association entities and 1-to-many relationships. The E-R diagram should also show all attributes of each entity and identify primary keys and foreign keys in each entity. (iii) List the functional dependencies in each relation. By examining the functional dependencies in each relation, verify that the relations are in 3NF. Normalise to 3NF, if they are not. (iv) Write an SQL file to create your database schema and insert some test data. The test data should hold information on at least 6 tracks, 3 artists and 4 albums (there should be at least one artist with 2 albums). (v) Write an SQL file to perform the queries (1, 2 and 3) listed above. EE221 Databases Laboratory Manual Databases Assignment Page 2 of 2