QMP 7.1 D/D Channabasaveshwara Institute of Technology (An ISO 9001:2008 Certified Institution) NH 206 (B.H. Road), Gubbi, Tumkur Karnataka.

Size: px
Start display at page:

Download "QMP 7.1 D/D Channabasaveshwara Institute of Technology (An ISO 9001:2008 Certified Institution) NH 206 (B.H. Road), Gubbi, Tumkur Karnataka."

Transcription

1 QMP 7.1 D/D Channabasaveshwara Institute of Technology (An ISO 9001:2008 Certified Institution) NH 206 (B.H. Road), Gubbi, Tumkur Karnataka. Department of Information Science & Engineering SYLLABUS DATABASE APPLICATION LABORATORY (Common to CSE & ISE) Subject Code: 10CSL57 I.A. Marks : 25 Hours/Week : 03 Exam Hours: 03 Total Hours : 42 Exam Marks: 50 I. Consider the following relations: I. Consider the following relations: STUDENT (snum: integer, sname: string, major: string, level: string, age: integer) CLASS (name: string, meets at: string, room: string, d: integer) ENROLLED (snum: integer, cname: string) FACULTY (fid: integer, fname: string, deptid: integer) The meaning of these relations is straightforward; for example, Enrolled has one record per student-class pair such that the student is enrolled in the class. Level is a two character code with 4 different values (example: Junior: JR etc) Write the following queries in SQL. No duplicates should be printed in any of the answers. (i) Find the names of all Juniors (level = JR) who are enrolled in a class taught by Prof.Harshith (ii) Find the names of all classes that either meet in room R128 or have five or more Students enrolled. (iii) Find the names of all students who are enrolled in two classes that meet at the same time. (iv) Find the names of faculty members who teach in every room in which some class is taught. (v) Find the names of faculty members for whom the combined enrollment of the courses that they teach is less than five. ENT (snum: integer, sname: string, major: string, level: string, age: integer) II. The following relations keep track of airline flight information: FLIGHTS (no: integer, from: string, to: string, distance: integer, Departs: time, arrives: time, price: real) AIRCRAFT (aid: integer, aname: string, cruisingrange: integer) CERTIFIED (eid: integer, aid: integer) EMPLOYEES (eid: integer, ename: string, salary: integer) Note that the Employees relation describes pilots and other kinds of employees as well; Every pilot is certified for some aircraft, and only pilots are certified to fly. Write each of the following queries in SQL. (i) Find the names of aircraft such that all pilots certified to operate them have salaries more than Rs.80, 000. (ii) For each pilot who is certified for more than three aircrafts, find the eid and the maximum cruisingrange of the aircraft for which she or he is certified. (iii) Find the names of pilots whose salary is less than the price of the cheapest route from Bengaluru to Frankfurt. (iv) For all aircraft with cruisingrange over 1000 Kms,.find the name of the aircraft and the average salary of all pilots certified for this aircraft. (v) Find the names of pilots certified for some Boeing aircraft. (vi) Find the aids of all aircraft that can be used on routes from Bengaluru to New Delhi. Dept of ISE, CIT, Gubbi Page 1

2 III. Consider the following database of student enrollment in courses and books adopted for each course. STUDENT (regno: string, name: string, major: string, bdate: date) COURSE (course#: int, cname: string, dept: string) ENROLL (regno: string, course#: int, sem: int, marks: int) BOOK_ADOPTION (course#: int, sem: int, book-isbn: int) TEXT (book-isbn: int, book-title: string, publisher: string, author: string) (i) Create the above tables by properly specifying the primary keys and the foreign keys. (ii) Enter atleast five tuples for each relation. (iii) Demonstrate how you add a new text book to the database and make this book be adopted by some department. (iv) Produce a list of text books (include Course#, Book-ISBN, Book-title) in the alphabetical order for courses offered by the CS department that use more than two books. (v) List any department that has all its adopted books published by a specific publisher. (vi) Generation of suitable reports. Create suitable front end for querying and displaying the results. LASS (name: string, meets at: string, room: string, d: integer) IV. The following tables are maintained by a book dealer. AUTHOR (author-id: int, name: string, city: string, country: string) PUBLISHER (publisher-id: int, name: string, city: string, country: string) CATALOG (book-id: int, title: string, author-id: int, publisher-id: int, category-id: int, year: int, price: int) CATEGORY (category-id: int, description: string) ORDER-DETAILS (order-no: int, book-id: int, quantity: int) i. Create the above tables by properly specifying the primary keys and foreign keys. ii. Enter atleast five tuples for each tables. iii. Give the details of the authors who have 2 or more books in the catalog and the price of the books is greater than the average price of the books in the catalog and the year of publication is after iv. Find the author of the book which has maximum sales. v. Demonstrate how you increase the price of books published by a specific publisher by 10%. vi. Generation of suitable reports Create suitable front end for querying and displaying the results. V. Consider the following database for a banking enterprise. BRANCH (branch-name: string, branch-city: string, assets: real) ACCOUNT (accno: int, branch-name: string, balance: real) DEPOSITOR (customer-name: string, accno: int) CUSTOMER (customer-name: string, customer-street: string, customer-city: string) LOAN (loan-number: int, branch-name: string, amount: real) BORROWER (customer-name: string, loan-number: int) i. Create the above tables by properly specifying the primary keys and foreign keys. ii. Enter atleast five tuples for each relation. iii. Find all the customers who have atleast two accounts at the main branch. iv. Find all the customers who have an account at all the branches located in a specific city. v. Demonstrate how you delete all account tuples at every branch located in a specific city. vi. Generation of suitable reports. Create suitable front end for querying and displaying the results. Dept of ISE, CIT, Gubbi Page 2

3 Instructions: 1. The exercises are to be solved in an RDBMS environment like Oracle or DB2. 2. Suitable tuples have to be entered so that queries are executed correctly. 3. Front end may be created using either VB or VAJ or any other similar tool. 4. The student need not create the front end in the examination. The results of the queries may be displayed directly. 5. Relevant queries other than the ones listed along with the exercises may also be asked in the examination. 6. Questions must be asked based on lots. ENROLLED (snum: integer, cname: string) FACULTY (fid: integer, fname: string, deptid: integer) Dept of ISE, CIT, Gubbi Page 3

4 MySQL Database: MySQL is a freely available open source Relational Database Management System (RDBMS) that uses Structured Query Language (SQL). SQL is the most popular language for adding, accessing and managing content in a database. It is most noted for its quick processing, proven reliability, ease and flexibility of use. MySQL is a fast, easy-to-use RDBMS being used for many small and big businesses. MySQL is developed, marketed, and supported by MySQL AB, which is a Swedish company. MySQL is becoming so popular because of many good reasons: MySQL is released under an open-source license. So you have nothing to pay to use it. MySQL is a very powerful program in its own right. It handles a large subset of the functionality of the most expensive and powerful database packages. MySQL uses a standard form of the well-known SQL data language. MySQL 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. MySQL is very friendly to PHP, the most appreciated language for web development. 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 you can increase this (if your operating system can handle it) to a theoretical limit of 8 million terabytes (TB). MySQL occupies very less disk space. MySQL is customizable. The open-source GPL license allows programmers to modify the MySQL software to fit their own specific environments. How to Install MySQL on Ubuntu Using terminal: To install MySQL, run the following command from a terminal prompt: sudo apt-get install mysql-server During the installation process you will be prompted to enter a password(for ex: root) for the MySQL root user. Once the installation is complete, the MySQL server should be started automatically. How to Access the MySQL shell Once you have MySQL installed on your droplet, you can access the MySQL shell by typing the following command into terminal: mysql -u root -p Enter the mysql password: root -u root -p refers to user root password. Login to MySQL as root user(u) with mysql password(p). Points to keep in mind: Dept of ISE, CIT, Gubbi Page 4

5 All MySQL commands end with a semicolon; if the phrase does not end with a semicolon, the command will not execute. Also, although it is not required, MySQL commands are usually written in uppercase and databases, tables, user names, or text are in lowercase to make them easier to distinguish. However, the MySQL command line is not case sensitive. Commands in the command line are not case sensitive. But the tables and database names are case sensitive. The table name stud is not the same as STUD. Summary of MySQL Commands Commands at the Database-Level 1: To Delete the database (irrecoverable!) DROP DATABASE databasename 2: Delete if it exists DROP DATABASE IF EXISTS databasename 3: Create a new database CREATE DATABASE databasename 4: Create only if it does not exists CREATE DATABASE IF NOT EXISTS databasename 5: Show all the databases in this server SHOW DATABASES 6: Set the default (current) database USE databasename 7: Show the default database SELECT DATABASE() 8: Show the CREATE DATABASE statement SHOW CREATE DATABASE databasename Dept of ISE, CIT, Gubbi Page 5

6 Commands at the Table-Level 1: To Delete the table (irrecoverable!) DROP TABLE [IF EXISTS] tablename,... 2: 3: Create a new table CREATE TABLE [IF NOT EXISTS] tablename ( columnname columntype columnattribute,... PRIMARY KEY(columnName), FOREIGN KEY (columnnmae) REFERENCES tablename (columnnmae) ) 3: Show all the tables in the default database SHOW TABLES 4: Describe the details for a table DESCRIBE DESC tablename 5: Modify a table, e.g., ADD COLUMN and DROP COLUMN 1: ALTER TABLE tablename... 2: ALTER TABLE tablename ADD columndefinition 3: ALTER TABLE tablename DROP columnname 4: ALTER TABLE tablename ADD FOREIGN KEY (columnnmae) REFERENCES tablename (columnnmae) 5: ALTER TABLE tablename DROP FOREIGN KEY constraintname 6: Show the CREATE TABLE statement for this tablename SHOW CREATE TABLE tablename Commands at the Row-Level 1: Insert on all Columns INSERT INTO tablename VALUES (column1value, column2value,...) 2: Insert multiple rows INSERT INTO tablename VALUES (column1value, column2value,...), (column1value, column2value,...)... 3: Insert on selected Columns INSERT INTO tablename (column1name,..., columnnname)values (column1value,..., columnnvalue) 4: Deleting particular row DELETE FROM tablename WHERE criteria Dept of ISE, CIT, Gubbi Page 6

7 5: UPDATE tablename SET columnname = expr,... WHERE criteria 6: SELECT * column1name AS alias1,..., columnnname AS aliasn FROM tablename WHERE criteria GROUP BY columnname ORDER BY columnname ASC DESC,... HAVING groupconstraints LIMIT count offset count Others 1: Show the warnings of the previous statement SHOW WARNINGS; Help & Exit Command 1: To get any information about the commands used in the mysql use "help" command. Eg: help insert; help create; 2: Type exit to exit from the MySQL prompt. How to Create and Delete a MySQL Database To check what databases are available show databases; mysql> show databases; database information_schema mysql performance_schema test rows in set (0.01 sec) creating a database create database database name; (in this case, for example, we will call our database "company.") create database company; mysql> show databases; database information_schema company mysql Dept of ISE, CIT, Gubbi Page 7

8 performance_schema test rows in set (0.00 sec) deleting a mysql database drop database database name; drop database database company; how to access a mysql database to open up the database we want to use: use company; To check the overview of the tables that the database contains. show tables; How to create a mysql table To create a employee table inside company database. create table employee ( id int not null primary key auto_increment, name varchar(20), city varchar(30), gender char(1) dob not null date ); This command accomplishes a number of things: 1: It has created a table called employee within the directory, company. 2: We have set up 5 columns in the table id, name, city, gender, dob. 3: The id column has a command (INT NOT NULL PRIMARY KEY AUTO_INCREMENT) that automatically numbers each row. 4: The name column has been limited by the VARCHAR command to be under 20 characters long. 5: The city column records the city that each employee belongs to. The VARCHAR limits text to be under 30 characters. 6: The gender column records the gender of the employee with single character, M or F. 7: The dob column will show the date of birth of the employee. MySQL requires that dates be written as yyyy-mm-dd Dept of ISE, CIT, Gubbi Page 8

9 mysql> SHOW TABLES; Tables_in_events employee row in set (0.01 sec) How to display the table s organization mysql>describe employee; Field Type Null Key Default Extra id int(11) NO PRI NULL auto_increment name varchar(20) YES NULL city varchar(30) YES NULL gender char(1) YES NULL dob date NO rows in set (0.01 sec) How to Add Information to a MySQL Table To add information to a table, the command used is insert. Insert command can be used in many ways, 1: Insert a row with all the column values. Syntax: INSERT INTO tablename VALUES (firstcolumnvalue,..., lastcolumnvalue) mysql>insert INTO employee VALUES (1001, kumar, Bangalore, M, ); 2: Inserting multiple rows in one command. Inserting NULL to the auto_increment column results in max_value + 1 Syntax: INSERT INTO tablename VALUES (row1firstcolumnvalue,..., row1lastcolumnvalue), (row2firstcolumnvalue,..., row2lastcolumnvalue),... mysql>insert INTO employee VALUES (NULL, 'Santhosh', 'Tumkur', "M", ), (NULL, 'vandana', 'Hasan', "F", ); 3: To insert a row with values on selected columns only. Missing value for the auto_increment column also results in max_value + 1 Syntax: INSERT INTO tablename (column1name,..., columnnname) VALUES (column1value,..., columnnvalue) Dept of ISE, CIT, Gubbi Page 9

10 mysql> INSERT INTO employee (name, city) VALUES ('Santhosh', 'Tumkur'),( 'vandana', 'Hasan'); Alternately, use SET to set the values INSERT INTO tablename SET column1=value1, column2=value2,... 4: Missing columns get their default values mysql> INSERT INTO products (name, city) VALUES ('Nuthan', 'Tumkur'); 5: Remove the row mysql> DELETE FROM employee WHERE id = 1003; mysql> select * from employee; id name city gender dob kumar Bangalore M santhosh Tumkur M nuthan Hasan M rows in set (0.00 sec) Querying the Database - SELECT 1: list all the rows of the specified columns. syntax : select column1name, column2name,... from tablename mysql> select name,city from employee; 2: list all the rows of all columns, * is a wildcard denoting all columns syntax: select * from tablename mysql> select * from employee; 3: list rows that meet the specified criteria in where clause syntax: select column1name, column2name,... from tablename where criteria mysql> select name, city from employee where id=105; MySQL Data Types 1: Numeric Data Types: INT : If signed, the allowable range is from to If unsigned, the allowable range is from 0 to You can specify a width of up to 11 digits. TINYINT : If signed, the allowable range is from -128 to 127. If unsigned, the allowable range is from 0 to 255. You can specify a width of up to 4 digits. SMALLINT : If signed, the allowable range is from to If unsigned, the allowable range is from 0 to You can specify a width of up to 5 digits. MEDIUMINT : If signed, the allowable range is from to If unsigned, the allowable range is from 0 to You can specify a width of up to 9 digits. BIGINT : If signed, the allowable range is from to Dept of ISE, CIT, Gubbi Page 10

11 If unsigned, the allowable range is from 0 to You can specify a width of up to 20 digits. FLOAT(M,D) : A floating-point number that cannot be unsigned. You can define the display length (M) and the number of decimals (D). This is not required and will default to 10,2, where 2 is the number of decimals and 10 is the total number of digits (including decimals). Decimal precision can go to 24 places for a FLOAT. DOUBLE(M,D) : A double precision floating-point number that cannot be unsigned. You can define the display length (M) and the number of decimals (D). This is not required and will default to 16,4, where 4 is the number of decimals. Decimal precision can go to 53 places for a DOUBLE. REAL is a synonym for DOUBLE. DECIMAL(M,D) - An unpacked floating-point number that cannot be unsigned. In unpacked decimals, each decimal corresponds to one byte. Defining the display length (M) and the number of decimals (D) is required. NUMERIC is a synonym for DECIMAL. 2: Date and Time Types: DATE - A date in YYYY-MM-DD format, between and For example, December 30th, 1973 would be stored as DATETIME - A date and time combination in YYYY-MM-DD HH:MM:SS format, between :00:00 and :59:59. For example, 3:30 in the afternoon on December 30th, 1973 would be stored as :30:00. TIMESTAMP - A timestamp between midnight, January 1, 1970 and sometime in This looks like the previous DATETIME format, only without the hyphens between numbers; 3:30 in the afternoon on December 30th, 1973 would be stored as ( YYYYMMDDHHMMSS ). TIME - Stores the time in HH:MM:SS format. YEAR(M) - Stores a year in 2-digit or 4-digit format. If the length is specified as 2 (for example YEAR(2)), YEAR can be 1970 to 2069 (70 to 69). If the length is specified as 4, YEAR can be 1901 to The default length is 4. 3: String Types: CHAR(M) - A fixed-length string between 1 and 255 characters in length (for example CHAR(5)), right-padded with spaces to the specified length when stored. Defining a length is not required, but the default is 1. VARCHAR(M) - A variable-length string between 1 and 255 characters in length; for example VARCHAR(25). You must define a length when creating a VARCHAR field. BLOB or TEXT - A field with a maximum length of characters. BLOBs are "Binary Large Objects" and are used to store large amounts of binary data, such as images or other types of files. Fields defined as TEXT also hold large amounts of data; the difference between the two is that sorts and comparisons on stored data are case sensitive on BLOBs and are not case sensitive in TEXT fields. You do not specify a length with BLOB or TEXT. TINYBLOB or TINYTEXT - A BLOB or TEXT column with a maximum length of 255 characters. You do not specify a length with TINYBLOB or TINYTEXT. MEDIUMBLOB or MEDIUMTEXT - A BLOB or TEXT column with a maximum length of characters. You do not specify a length with MEDIUMBLOB or MEDIUMTEXT. LONGBLOB or LONGTEXT - A BLOB or TEXT column with a maximum length of Dept of ISE, CIT, Gubbi Page 11

12 characters. You do not specify a length with LONGBLOB or LONGTEXT. ENUM - An enumeration, which is a fancy term for list. When defining an ENUM, you are creating a list of items from which the value must be selected (or it can be NULL). For example, if you wanted your field to contain "A" or "B" or "C", you would define your ENUM as ENUM ('A', 'B', 'C') and only those values (or NULL) could ever populate that field. DATABASE 1 : College_database DESCRIPTION: The following relations keep track of students, their enrollment for classes along with faculty information. Student (snum: integer, sname: string, major: string, level: string, age: integer) Class (name: string, meets at: string, room: string, d: integer) Enrolled (snum: integer, cname: string) Faculty (fid: integer, fname: string, deptid: integer) NOTE: The meaning of these relations is straight forward.for example, Enrolled has one record per student-class pair such that the student is enrolled in the class. Level is a two character code with 4 different values (example: Junior: JR etc) Queries: Write the following queries in SQL. No duplicates should be printed in any of the answers. 1. Find the names of all juniors (level=jr) who are enrolled for class taught by professor Harshith. 2. Find the names of all classes that either meet in room128 or have 5 or more students enrolled. 3. Find the names of all students who are enrolled in two classes that meet at same time. 4. Find the names of faculty members who teach in every room in which some class is taught. 5. Find the names of the faculty members for whom the combined enrollment of the classes that they teach is less than five. Dept of ISE, CIT, Gubbi Page 12

13 ER Diagram Meets Snum Snam Snum Cname Fid Room STUDENT Enro CLASS Level Majo Cname Teach Age Deptid FACULTY Fid Fname mysqll> create table student ( mysql> create table faculty ( ); snum integer primary key, sname varchar(15), major varchar(10), level1 varchar(2), age integer ); fid integer primary key, fname varchar(15), deptid integer Dept of ISE, CIT, Gubbi Page 13

14 mysql > create table class ( ); cname varchar(10) primary key, meetsat varchar(4), room varchar(5), fid integer, foreign key(fid) references faculty(fid) mysql > create table enrolled ( snum integer, cname varchar(10), foreign key(snum) references student(snum), foreign key(cname) references class(cname), primary key(snum,cname) ); mysql > desc student; Field Type Null Key Default Extra snum int(11) NO PRI NULL sname varchar(15) YES NULL major varchar(10) YES NULL level1 varchar(2) YES NULL age int(11) YES NULL rows in set (0.00 sec) mysql > insert into student values (1, arthi, os, jr, 21); mysql >insert into student values (2, bhavesh, is, sr, 22); mysql >insert into student values (3, chanasya, ec, jr, 21); mysql >insert into student values (4, sowmya, cs, sr, 23); mysql >insert into student values (5, sanjay, ec, jr, 21); mysql >insert into student values (10, giri, ccn, jr, 20); mysql >insert into student values (20, asha, os, jr, 30); mysql> select * from stud; snum sname major level1 age arun os jr 21 2 bhanu ls sr 22 3 chanasya ec jr 21 4 sowmya cs sr 23 5 gowri ccn jr 20 6 asha os jr rows in set (0.00 sec) Dept of ISE, CIT, Gubbi Page 14

15 mysql > desc faculty; Field Type Null Key Default Extra fid int(11) NO PRI NULL fname varchar(15) YES NULL deptid int(11) YES NULL rows in set (0.00 sec) mysql > insert into faculty values(11, bharathi,111); mysql > insert into faculty values(22, nirmala,222); mysql > insert into faculty values(33, prof.harshith,333); mysql > insert into faculty values(44, bhavana,111); mysql > insert into faculty values(55, usha,111); mysql> select * from faculty; fid fname deptid bharathi nirmala prof.harshith bhavana usha rows in set (0.00 sec) mysql > desc class; Field Type Null Key Default Extra cname varchar(10) NO PRI NULL meetsat varchar(4) YES NULL room varchar(5) YES NULL fid int(11) YES MUL NULL rows in set (0.00 sec) mysql > insert into class values( ccna, 10:00, r126,33); mysql > insert into class values( cobol, 10:00, r127,22); mysql > insert into class values( dotnet, 9:00, r101,33); mysql > insert into class values( java, 11:15, r126,22); mysql > insert into class values( jcp, 12:15, r128,22); mysql > insert into class values( oops, 12:15, r127,22); mysql > insert into class values( oracle, 12:15, r128,11); mysql > insert into class values( testiing, 11:15, r101,22); Dept of ISE, CIT, Gubbi Page 15

16 mysql> select * from class; cname meetsat room fid ccna 10:0 r cobol 10:0 r dotnet 9:00 r java 11:1 r jcp 12:1 r oops 12:1 r oracle 12:1 r testiing 11:1 r rows in set (0.00 sec) mysql > desc enrolled; Field Type Null Key Default Extra snum int(11) NO PRI 0 cname varchar(10) NO PRI rows in set (0.00 sec) mysql > insert into enrolled values(1,'cobol'); mysql > insert into enrolled values(2,'cobol'); mysql > insert into enrolled values(3,'cobol'); mysql > insert into enrolled values(4,'cobol'); mysql > insert into enrolled values(1,'dotnet'); mysql > insert into enrolled values(1,'jcp'); mysql > insert into enrolled values(5,'jcp'); mysql > insert into enrolled values(3,'oracle'); mysql > insert into enrolled values(5,'cobol'); mysql > insert into enrolled values(4,'ccna'); mysql > insert into enrolled values(3,'testing'); mysql > insert into enrolled values(3,'java'); mysql> select * from enrolled; snum cname ccna 1 cobol 2 cobol 3 cobol 4 cobol 5 cobol Dept of ISE, CIT, Gubbi Page 16

17 1 dotnet 3 java 1 jcp 5 jcp 3 oracle 5 oracle 3 testing rows in set (0.00 sec) 1. Find the names of all Juniors (level = JR) who are enrolled in a class taught by Prof. Harshith mysql > select distinct s.sname from student s, class c, enrolled e, faculty f where s.snum = e.snum and e.cname = c.cname and c.fid = f.fid and f.fname = 'prof.harshith' and s.level1 = 'jr'; sname arun row in set (0.00 sec) 2. Find the names of all classes that either meet in room R128 or have five or more Students enrolled. mysql > select c.cname from class c where c.room = 'r128' or c.cname in (select e.cname from enrolled e group by e.cname having count(*) >= 5); cname cobol jcp oracle rows in set (0.00 sec) 3. Find the names of all students who are enrolled in two classes that meet at the same time. mysql > select distinct s.sname from student s where s.snum in (select e1.snum from enrolled e1, enrolled e2, class c1, class c2 where e1.snum = e2.snum and e1.cname<>e2.cname and e1.cname=c1.cname and e2.cname=c2.cname and c1.meetsat = c2.meetsat); sname Dept of ISE, CIT, Gubbi Page 17

18 sowmya gowri rows in set (0.00 sec) 4. Find the names of faculty members who teach in every room in which some class is taught. mysql > select fname, count (distinct room) from class c, enrolled e, faculty f where c.fid=f.fid and c.cname=e.cname group by fname having count(distinct room) in (select count(distinct room) from class c, enrolled e where e.cname=c.cname); fname count(distinct room) nirmala row in set (0.00 sec) 5. Find the names of faculty members for whom the combined enrollment of the courses that they teach is less than five. mysql > select distinct f.fname from class c, enrolled e, faculty f where c.fid=f.fid and c.cname=e.cname group by f.fname having count(*)<5; fname bharathi prof.harshith rows in set (0.00 sec) Dept of ISE, CIT, Gubbi Page 18

19 DATABASE 2 : Airline_Flight_database DESCRIPTION: The following relations keep track of airline flight information: Flights (no: integer, from: string, to: string, distance: integer, Departs: time, arrives: time, price: real) Aircraft (aid: integer, aname: string, cruisingrange: integer) Certified (eid: integer, aid: integer) Employees (eid: integer, ename: string, salary: integer) Note that the Employees relation describes pilots and other kinds of employees as well; Every pilot is certified for some aircraft, and only pilots are certified to fly. Write each of the following queries in SQL. i. Find the names of aircraft such that all pilots certified to operate them have salaries more than Rs.80, 000. ii. For each pilot who is certified for more than three aircrafts, find the eid and the maximum cruisingrange of the aircraft for which she or he is certified. iii. Find the names of pilots whose salary is less than the price of the cheapest route from Bengaluru to Frankfurt. iv. For all aircraft with cruisingrange over 1000 Kms,.find the name of the aircraft and the average salary of all pilots certified for this aircraft. v. Find the names of pilots certified for some Boeing aircraft. vi. Find the aids of all aircraft that can be used on routes from Bengaluru to New Delhi. Dept of ISE, CIT, Gubbi Page 19

20 ER Diagram : mysql > create table flights ( mysql > create table aircraft ( no int primary key, fro varchar(15), too varchar(15), distance integer, departs char(6), arrives char(6), price real ); aid int primary key, aname varchar(15), crurange integer ); mysql > create table employees ( eid int primary key, cname varchar(10), salary integer ); Dept of ISE, CIT, Gubbi Page 20

21 mysql > create table certified ( eid int, aid int, foreign key(eid) references employees(eid), foreign key(aid) references aircraft(aid), primary key(eid,aid) ); mysql>describe flights; Field Type Null Key Default Extra no int(11) NO PRI NULL fro varchar(15) YES NULL too varchar(15) YES NULL distance int(11) YES NULL departs char(6) YES NULL arrives char(6) YES NULL price double YES NULL rows in set (0.00 sec) mysql>insert into flights values(4,'bangalore','australia',3000, 09:30, 12:00,150000); mysql > insert into flights values(2,'delhi','new jersey',4000, 01:30, 09:00,120000); mysql > insert into flights values(3,'hyderbad','bangalore',700, 02:30, 03:30,5000); mysql > insert into flights values(5,'angalore','kolkota',1200, 04:30, 06:30,10000); mysql> insert into flights values(6,'bangalore','newdelhi',2000, 05:30, 07:30,15000); mysql> insert into flights values(6,'bangalore','frankfrut',4000, 06:30, 11:30,20000); mysql>select * from Flights; no fro too distance departs arrives price delhi new jersey :30 09: hyderbad bangalore :30 03: bangalore australia bangalore kolkota :30 06: bangalore newdelhi :30 07: bangalore frankfrut :30 11: rows in set (0.00 sec) Dept of ISE, CIT, Gubbi Page 21

22 mysql>describe aircraft; Field Type Null Key Default Extra aid int(11) NO PRI NULL aname varchar(15) YES NULL crurange int(11) YES NULL rows in set (0.00 sec) mysql > insert into aircraft values(11, 'airindia', 4000); mysql > insert into aircraft values(22, 'boeing120', 5000); mysql > insert into aircraft values(33, 'kingfisher', 3000); mysql > insert into aircraft values(44, 'jetairways', 4000); mysql > insert into aircraft values(55, 'boeing240', 6000); mysql > insert into aircraft values(66, 'bharath', 600); mysql > insert into aircraft values(77, 'bharath160', 800); mysql>select * from Aircraft; aid aname crurange airindia boeing kingfisher jetairways boeing bharath bharath rows in set (0.00 sec) mysql>describe employees; Field Type Null Key Default Extra eid int(11) NO PRI NULL cname varchar(10) YES NULL salary int(11) YES NULL rows in set (0.01 sec) mysql > insert into employees values(123, kumar, 80000); mysql > insert into employees values(201, muruli, ); mysql > insert into employees values(301, alexander, ); mysql > insert into employees values(401, mathew, 60000); Dept of ISE, CIT, Gubbi Page 22

23 mysql > insert into employees values(501, philomina, 2000); mysql>select * from Employees; eid cname salary kumar muruli alexander mathew philomina rows in set (0.01 sec) [ mysql>describe certified; Field Type Null Key Default Extra eid int(11) NO PRI 0 aid int(11) NO PRI rows in set (0.01 sec) mysql > insert into certified values(123, 11); mysql > insert into certified values(201, 22); mysql > insert into certified values(201, 33); mysql > insert into certified values(301, 33); mysql > insert into certified values(123, 44); mysql > insert into certified values(401, 44); mysql > insert into certified values(501,44); mysql > insert into certified values(123,55); mysql > insert into certified values(123, 66); mysql>select * from certified; eid aid Dept of ISE, CIT, Gubbi Page 23

24 rows in set (0.00 sec) 1: Find the names of aircraft such that all pilots certified to operate them have salaries more than Rs.80, 000. mysql >select distinct a.aname from aircraft a,certified c,employees e where a.aid=c.aid and c.eid=e.eid and not exists (select * from employees e1 where e1.eid=e.eid and e1.salary<80000); aname boeing120 kingfisher rows in set (0.00 sec) 2. For each pilot who is certified for more than three aircrafts, find the eid and the maximum cruisingrange of the aircraft for which she or he is certified. mysql > select c.eid, max(a.crurange) from certified c, aircraft a where c.aid = a.aid group by c.eid having count(*) > 3; eid max(a.crurange) row in set (0.00 sec) 3. Find the names of pilots whose salary is less than the price of the cheapest route from Bengaluru to Frankfurt. mysql > select distinct e.cname from employees e where e.salary < ( select min(f.price) from flights f where f.fro= 'bangalore' and f.too= 'frankfrut'); cname Dept of ISE, CIT, Gubbi Page 24

25 philomina row in set (0.00 sec) 4. For all aircraft with cruisingrange over 1000 Kms,.find the name of the aircraft and the average salary of all pilots certified for this aircraft. mysql >select a.aid, avg (e.salary) from aircraft a, certified c, employees e where a.aid = c.aid and c.eid = e.eid and a.crurange > 1000 group by a.aid, a.aname); aid avg (e.salary) rows in set (0.00 sec) 5. Find the names of pilots certified for some Boeing aircraft. mysql > select distinct e.cname from employees e, certified c, aircraft a where e.eid = c.eid and c.aid=a.aid and a.aname like 'boeing%'; cname kumar muruli rows in set (0.00 sec) 6. Find the aids of all aircraft that can be used on routes from Bengaluru to New Delhi. mysql > select a.aid from aircraft a where a.crurange > ( select min(f.distance) from flights f where f.frm='bengaluru' and f.too='newdelhi'); aid Dept of ISE, CIT, Gubbi Page 25

26 rows in set (0.00 sec) Dept of ISE, CIT, Gubbi Page 26

27 DATABASE 3 : Student_Enrollment_database DESCRIPTION: Consider the following database of student enrollment in courses and books adopted for each course. STUDENT (regno: string, name: string, major: string, bdate: date) COURSE (course#: int, cname: string, dept: string) ENROLL (regno: string, course#: int, sem: int, marks: int) BOOK_ADOPTION (course#: int, sem: int, book-isbn: int) TEXT (book-isbn: int, book-title: string, publisher: string, author: string) 1: Create the above tables by properly specifying the primary keys and the foreign keys. 2: Enter at least five tuples for each relation. 3: Demonstrate how you add a new text book to the database and make this book be adopted by some department. 4: Produce a list of text books (include Course#, Book-ISBN, Book-title) in the alphabetical order for courses offered by the CS department that use more than two books. 5: List any department that has all its adopted books published by a specific publisher. 6: Generation of suitable reports. 7: Create suitable front end for querying and displaying the results. ER-Diagram: Regno Name Marks Course_no Cname STUDENT ENROLL COURSE Major Bdate Sem Dept BOOKADAPTION SEM Publisher TEXT Author Book_Isbn booktitle Dept of ISE, CIT, Gubbi Page 27

28 mysql>create table student ( regno varchar(20) primary key not null, sname varchar(20), major varchar(20), bdate date ); mysql>create table course ( cno int primary key not null, cname varchar(20), dept varchar(20) ); mysql>create table enroll ( regno varchar(20), cno int, sem int, marks int, primary key(regno,cno), foreign key (regno) references student (regno), foreign key (cno) references course (cno) ); mysql>create table text ( book_isbn int primary key not null, book_title varchar(20), pubisher varchar(20), author varchar(20) ); mysql>create table book_adoption ( cno int, sem int, book_isbn int, primary key(cno,book_isbn), foreign key (cno) references course (cno), foreign key (book_isbn) references text (book_isbn) ); mysql>describe student; Field Type Null Key Default Extra regno varchar(20) NO PRI NULL sname varchar(20) YES NULL major varchar(20) YES NULL bdate date YES NULL Dept of ISE, CIT, Gubbi Page 28

29 rows in set (0.00 sec) mysql>insert into student values ('1cg04is012','asha','networks', ); mysql>insert into student values ('1cg04is030','anitha','fafl', ); mysql>insert into student values ('1cg04is064','chandrika','ada', ); mysql>insert into student values ('1cg04is105','Kumar','coding', ); mysql> insert into student values ('1cg04is110','Gagan','coding', ); mysql> select * from student; regno sname major bdate cg04is012 asha networks cg04is030 anitha fafl cg04is064 chandrika ada cg04is105 Kumar coding cg04is110 Gangan coding rows in set (0.00 sec) mysql>describe course; Field Type Null Key Default Extra cno int(11) NO PRI NULL cname varchar(20) YES NULL dept varchar(20) YES NULL rows in set (0.00 sec) mysql>insert into course values (1,'network','ec'); mysql>insert into course values (2,'fafl','cs'); mysql>insert into course values (3,'ada','cs'); mysql>insert into course values (4,'coding','ec'); mysql>insert into course values (5,'datastr','cs'); mysql>insert into course values (6,'testing','ec'); mysql>select * from course; cno cname dept network ec 2 fafl cs 3 ada cs 4 coding ec 5 datastr cs Dept of ISE, CIT, Gubbi Page 29

30 6 testing ec rows in set (0.00 sec) mysql>describe enroll; Field Type Null Key Default Extra regno varchar(20) NO PRI cno int(11) NO PRI 0 sem int(11) YES NULL marks int(11) YES NULL rows in set (0.01 sec) mysql>insert into enroll values ('1cg04is012',1,6,85); mysql>insert into enroll values ('1cg04is030',2,6,90); mysql>insert into enroll values ('1cg04is064',3,6,92); mysql>insert into enroll values ('1cg04is105',4,6,95); mysql>insert into enroll values ('1cg04is110',5,4,90); mysql>select * from enroll; regno cno sem marks cg04is cg04is cg04is cg04is cg04is rows in set (0.00 sec) mysql>desc text; Field Type Null Key Default Extra book_isbn int(11) NO PRI NULL book_title varchar(20) YES NULL pubisher varchar(20) YES NULL author varchar(20) YES NULL rows in set (0.00 sec) mysql>insert into text values (111,'comp net','tmg','garcia'); mysql>insert into text values (222,'algo des','pearson','leviten'); mysql>insert into text values (333,'automata','pearson','ullman'); Dept of ISE, CIT, Gubbi Page 30

31 mysql>insert into text values (444,'data str','pearson','tbaum'); mysql>insert into text values (555,'usp','pearson','yash'); mysql>insert into text values (666,'algo2','pearson','leviten'); mysql>insert into text values (777,'networks','pearson','garcia'); mysql>insert into text values (888,'swtesting','sapna,'sapna'); mysql>select * from text; book_isbn book_title pubisher author comp net tmg garcia 222 algo des pearson leviten 333 automata pearson ullman 444 data str pearson tbaum 555 usp pearson yash 666 algo2 pearson leviten 777 networks pearson garcia 888 swtesting sapna sapna rows in set (0.00 sec) mysql>desc book_adoption; Field Type Null Key Default Extra cno int(11) NO PRI 0 sem int(11) YES NULL book_isbn int(11) NO PRI rows in set (0.01 sec) mysql>insert into book_adoption values (01,6,111); mysql>insert into book_adoption values (02,6,333); mysql>insert into book_adoption values (02,6,666); mysql>insert into book_adoption values (02,6,111); mysql>insert into book_adoption values (03,6,222); mysql>insert into book_adoption values (03,5,555); mysql>insert into book_adoption values (04,6,555); mysql>insert into book_adoption values (05,3,444); mysql>insert into book_adoption values (01,6,666); mysql>insert into book_adoption values (01,6,777); mysql>insert into book_adoption values (03,6, 777); mysql>insert into book_adoption values (04,6, 777); mysql>insert into book_adoption values (06,6, 888); mysql>select * from book_adoption; Dept of ISE, CIT, Gubbi Page 31

32 cno sem book_isbn rows in set (0.00 sec) 1: Demonstrate how you add a new text book to the database and make this book be adopted by some department. mysql>insert into text values ( 999, multimedia, phi, navathe ); mysql>insert into book_adoption values (6,3,999); mysql>select * from text; book_isbn book_title pubisher author comp net tmg garcia 222 algo des pearson leviten 333 automata pearson ullman 444 data str pearson tbaum 555 usp pearson yash 666 algo2 pearson leviten 777 networks pearson garcia 888 swtesting sapna sapna 999 multimedia phi navathe rows in set (0.01 sec) 2: Produce a list of text books (include Course#, Book-ISBN, Book-title) in the alphabetical order for courses offered by the CS department that use more than two books. mysql>select c.cno, t.book_isbn, t.book_title from course c, book_adoption b, text t where c.cno=b.cno and t.book_isbn=b.book_isbn and c.dept='cs' Dept of ISE, CIT, Gubbi Page 32

33 [ Database Applications Laboratory and c.cno in ( select cno from book_adoption group by cno having count(*)>2) order by c.cno, t.book_title; cno book_isbn book_title algo automata comp net algo des networks usp rows in set (0.00 sec) 3: List any department that has all its adopted books published by a specific publisher.p mysql>select distinct c.dept from course c where c.dept in ( select c.dept from course c,book_adoption b,text t where c.cno=b.cno and t.book_isbn=b.book_isbn and t.publisher='sapna') and c.dept not in (select c.dept from course c,book_adoption b,text t where c.cno=b.cno and t.book_isbn=b.book_isbn and t.publisher!='sapna'); dept count(distinct b.book_isbn) ec row in set (0.00 sec) Dept of ISE, CIT, Gubbi Page 33

34 DATABASE 4 : Book_dealer_database DESCRIPTION: The following tables are maintained by a book dealer. AUTHOR (author-id: int, name: string, city: string, country: string) PUBLISHER (publisher-id: int, name: string, city: string, country: string) CATALOG (book-id: int, title: string, author-id: int, publisher-id: int, category-id: int, year: int, price: int) CATEGORY (category-id: int, description: string) ORDER-DETAILS (order-no: int, book-id: int, quantity: int) 1: Create the above tables by properly specifying the primary keys and foreign keys. 2: Enter at least five tuples for each tables. 3: Give the details of the authors who have 2 or more books in the catalog and the price of the books is greater than the average price of the books in the catalog and the year of publication is after : Find the author of the book which has maximum sales. 5: Demonstrate how you increase the price of books published by a specific publisher by 10%. 6: Generation of suitable reports. ER-Diagram: Author-id Name Title Year Publisher-id Name AUTHOR CATALOG PUBLISHER City Country Price city country Category-id CATEGORY Description N ORDER-DETAILS quantity 1 ORDER orderno Dept of ISE, CIT, Gubbi Page 34

35 mysql> create table author ( authorid number(5), name varchar(20), city varchar(20), country varchar(10), primary key(authorid) ); mysql> create table publisher ( publisherid number(5), name char(20), city char(20), country char(20), primary key(publisherid) ); mysql> create table catagory ( catagoryid number(5), description varchar(20), primary key (catagoryid) ); mysql> create table catalog ( bookid number(5), title varchar(20), authorid number(5), publisherid number(5), catagoryid number(5), year number(5), price number(4), primary key(bookid), foreign key (authorid) references author(authorid), foreign key (publisherid) references publisher (publisherid), foreign key (catagoryid) references catagory(catagoryid) ); mysql> create table order_details ( ono int primary key, bookid int, quantity int, foreign key (bookid) references catalog(bookid) ); mysql>desc author; Field Type Null Key Default Extra authorid int(11) NO PRI 0 name varchar(20) YES NULL city varchar(20) YES NULL country varchar(10) YES NULL Dept of ISE, CIT, Gubbi Page 35

36 rows in set (0.00 sec) mysql> insert into author values(1,'harish','delhi','india'); mysql> insert into author values(2,'balu','bangalore','india'); mysql> insert into author values(3,'gopal','goa','india'); mysql> insert into author values(4,'sagar','kerala','india'); mysql> insert into author values(5,'trivedi','washington','usa'); mysql> select * from author; authorid name city country harish delhi india 2 balu bangalore india 3 gopal goa india 4 sagar kerala india 5 trivedi washington usa rows in set (0.00 sec) mysql> desc publisher; Field Type Null Key Default Extra publisherid int(11) NO PRI 0 name char(20) YES NULL city char(20) YES NULL country char(20) YES NULL rows in set (0.00 sec) mysql> insert into publisher values(10,'pearson','goa','india'); mysql> insert into publisher values(11,'sapna','kerala','india'); mysql> insert into publisher values(12,'sapna','bangalore','india'); mysql> insert into publisher values(13,'sagar','kolkata','india'); mysql> insert into publisher values(14,'tata','washington','usa'); mysql> select * from publisher; publisherid name city country pearson goa india 11 sapna kerala india 12 sapna bangalore india 13 sagar kolkata india 14 tata washington usa rows in set (0.01 sec) Dept of ISE, CIT, Gubbi Page 36

Lab # 2 Hands-On. DDL Basic SQL Statements Institute of Computer Science, University of Tartu, Estonia

Lab # 2 Hands-On. DDL Basic SQL Statements Institute of Computer Science, University of Tartu, Estonia Lab # 2 Hands-On DDL Basic SQL Statements Institute of Computer Science, University of Tartu, Estonia Part A: Demo by Instructor in Lab a. Data type of MySQL b. CREATE table c. ALTER table (ADD, CHANGE,

More information

Chapter 3 Introduction to relational databases and MySQL

Chapter 3 Introduction to relational databases and MySQL Chapter 3 Introduction to relational databases and MySQL Murach's PHP and MySQL, C3 2014, Mike Murach & Associates, Inc. Slide 1 Objectives Applied 1. Use phpmyadmin to review the data and structure of

More information

MySQL Introduction. By Prof. B.A.Khivsara

MySQL Introduction. By Prof. B.A.Khivsara MySQL Introduction By Prof. B.A.Khivsara Note: The material to prepare this presentation has been taken from internet and are generated only for students reference and not for commercial use. Introduction

More information

The M in LAMP: MySQL CSCI 470: Web Science Keith Vertanen Copyright 2014

The M in LAMP: MySQL CSCI 470: Web Science Keith Vertanen Copyright 2014 The M in LAMP: MySQL CSCI 470: Web Science Keith Vertanen Copyright 2014 MySQL Setup, using console Data types Overview Creating users, databases and tables SQL queries INSERT, SELECT, DELETE WHERE, ORDER

More information

CSCI-UA: Database Design & Web Implementation. Professor Evan Sandhaus

CSCI-UA: Database Design & Web Implementation. Professor Evan Sandhaus CSCI-UA:0060-02 Database Design & Web Implementation Professor Evan Sandhaus sandhaus@cs.nyu.edu evan@nytimes.com Lecture #10: Open Office Base, Life on the Console, MySQL Database Design and Web Implementation

More information

TINYINT[(M)] [UNSIGNED] [ZEROFILL] A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255.

TINYINT[(M)] [UNSIGNED] [ZEROFILL] A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255. MySQL: Data Types 1. Numeric Data Types ZEROFILL automatically adds the UNSIGNED attribute to the column. UNSIGNED disallows negative values. SIGNED (default) allows negative values. BIT[(M)] A bit-field

More information

Deepak Bhinde PGT Comp. Sc.

Deepak Bhinde PGT Comp. Sc. Deepak Bhinde PGT Comp. Sc. SQL Elements in MySQL Literals: Literals refers to the fixed data value. It may be Numeric or Character. Numeric literals may be integer or real numbers and Character literals

More information

MySQL by Examples for Beginners

MySQL by Examples for Beginners yet another insignificant programming notes... HOME MySQL by Examples for Beginners Read "How to Install MySQL and Get Started" on how to install, customize, and get started with MySQL. 1. Summary of MySQL

More information

CSCI-UA: Database Design & Web Implementation. Professor Evan Sandhaus

CSCI-UA: Database Design & Web Implementation. Professor Evan Sandhaus CSCI-UA:0060-02 Database Design & Web Implementation Professor Evan Sandhaus sandhaus@cs.nyu.edu evan@nytimes.com Lecture #15: Post Spring Break Massive MySQL Review Database Design and Web Implementation

More information

Introduction to SQL on GRAHAM ED ARMSTRONG SHARCNET AUGUST 2018

Introduction to SQL on GRAHAM ED ARMSTRONG SHARCNET AUGUST 2018 Introduction to SQL on GRAHAM ED ARMSTRONG SHARCNET AUGUST 2018 Background Information 2 Background Information What is a (Relational) Database 3 Dynamic collection of information. Organized into tables,

More information

Data Types in MySQL CSCU9Q5. MySQL. Data Types. Consequences of Data Types. Common Data Types. Storage size Character String Date and Time.

Data Types in MySQL CSCU9Q5. MySQL. Data Types. Consequences of Data Types. Common Data Types. Storage size Character String Date and Time. - Database P&A Data Types in MySQL MySQL Data Types Data types define the way data in a field can be manipulated For example, you can multiply two numbers but not two strings We have seen data types mentioned

More information

Create Basic Databases and Integrate with a Website Lesson 1

Create Basic Databases and Integrate with a Website Lesson 1 Create Basic Databases and Integrate with a Website Lesson 1 Getting Started with Web (SQL) Databases In order to make a web database, you need three things to work in cooperation. You need a web server

More information

Data and Tables. Bok, Jong Soon

Data and Tables. Bok, Jong Soon Data and Tables Bok, Jong Soon Jongsoon.bok@gmail.com www.javaexpert.co.kr Learning MySQL Language Structure Comments and portability Case-sensitivity Escape characters Naming limitations Quoting Time

More information

Overview of MySQL Structure and Syntax [2]

Overview of MySQL Structure and Syntax [2] PHP PHP MySQL Database Overview of MySQL Structure and Syntax [2] MySQL is a relational database system, which basically means that it can store bits of information in separate areas and link those areas

More information

Simple Quesries in SQL & Table Creation and Data Manipulation

Simple Quesries in SQL & Table Creation and Data Manipulation Simple Quesries in SQL & Table Creation and Data Manipulation Based on CBSE Curriculum Class -11 By- Neha Tyagi PGT CS KV 5 Jaipur II Shift Jaipur Region Neha Tyagi, PGT CS II Shift Jaipur Introduction

More information

CS 4320 SQL Fun. With Justin Miron

CS 4320 SQL Fun. With Justin Miron CS 4320 SQL Fun With Justin Miron (jmm825@cornell.edu) The Scenario Students(snum INTEGER, sname NVARCHAR(50), major NVARCHAR(50), level NVARCHAR(50), age INTEGER) Class(class_id INTEGER, cname NVARCHAR(50),

More information

More MySQL ELEVEN Walkthrough examples Walkthrough 1: Bulk loading SESSION

More MySQL ELEVEN Walkthrough examples Walkthrough 1: Bulk loading SESSION SESSION ELEVEN 11.1 Walkthrough examples More MySQL This session is designed to introduce you to some more advanced features of MySQL, including loading your own database. There are a few files you need

More information

Consider the following database of BOOK DEALER and the tables are maintained by a book dealer.

Consider the following database of BOOK DEALER and the tables are maintained by a book dealer. 4. BOOK DEALER DATABASE Consider the following database of BOOK DEALER and the tables are maintained by a book dealer. AUTHOR(authorid: int, name: string, city: string, country:string) PUBLISHER(publisherid:

More information

General References on SQL (structured query language) SQL tutorial.

General References on SQL (structured query language) SQL tutorial. Week 8 Relational Databases Reading DBI - Database programming with Perl Appendix A and B, Ch 1-5 General References on SQL (structured query language) SQL tutorial http://www.w3schools.com/sql/default.asp

More information

Careerarm.com. 1. What is MySQL? MySQL is an open source DBMS which is built, supported and distributed by MySQL AB (now acquired by Oracle)

Careerarm.com. 1. What is MySQL? MySQL is an open source DBMS which is built, supported and distributed by MySQL AB (now acquired by Oracle) 1. What is MySQL? MySQL is an open source DBMS which is built, supported and distributed by MySQL AB (now acquired by Oracle) 2. What are the technical features of MySQL? MySQL database software is a client

More information

Assignment 3: SQL SELECT Queries

Assignment 3: SQL SELECT Queries Assignment 3: SQL SELECT Queries Install MySQL on your computer ("sudo apt-get install mysql-server" on Ubuntu Linux / or follow instructions for your o/s installs). Put the following lines in ~/.my.cnf

More information

Unit 1 - Chapter 4,5

Unit 1 - Chapter 4,5 Unit 1 - Chapter 4,5 CREATE DATABASE DatabaseName; SHOW DATABASES; USE DatabaseName; DROP DATABASE DatabaseName; CREATE TABLE table_name( column1 datatype, column2 datatype, column3 datatype,... columnn

More information

CS 461: Database Systems. Final Review. Julia Stoyanovich

CS 461: Database Systems. Final Review. Julia Stoyanovich CS 461: Database Systems Final Review (stoyanovich@drexel.edu) Final exam logistics When: June 6, in class The same format as the midterm: open book, open notes 2 hours in length The exam is cumulative,

More information

Chapter 9: Working with MySQL

Chapter 9: Working with MySQL Chapter 9: Working with MySQL Informatics Practices Class XI (CBSE Board) Revised as per CBSE Curriculum 2015 Visit www.ip4you.blogspot.com for more. Authored By:- Rajesh Kumar Mishra, PGT (Comp.Sc.) Kendriya

More information

MySQL Creating a Database Lecture 3

MySQL Creating a Database Lecture 3 MySQL Creating a Database Lecture 3 Robb T Koether Hampden-Sydney College Mon, Jan 23, 2012 Robb T Koether (Hampden-Sydney College) MySQL Creating a DatabaseLecture 3 Mon, Jan 23, 2012 1 / 31 1 Multiple

More information

SQL Commands & Mongo DB New Syllabus

SQL Commands & Mongo DB New Syllabus Chapter 15 : Computer Science Class XI ( As per CBSE Board) SQL Commands & Mongo DB New Syllabus 2018-19 SQL SQL is an acronym of Structured Query Language.It is a standard language developed and used

More information

Integrity constraints, relationships. CS634 Lecture 2

Integrity constraints, relationships. CS634 Lecture 2 Integrity constraints, relationships CS634 Lecture 2 Foreign Keys Defined in Sec. 3.2.2 without mentioning nulls. Nulls covered in Sec. 5.6 First example: nice not-null foreign key column: create table

More information

Data Definition Language with mysql. By Kautsar

Data Definition Language with mysql. By Kautsar Data Definition Language with mysql By Kautsar Outline Review Create/Alter/Drop Database Create/Alter/Drop Table Create/Alter/Drop View Create/Alter/Drop User Kautsar -2 Review Database A container (usually

More information

Basis Data Terapan. Yoannita

Basis Data Terapan. Yoannita Basis Data Terapan Yoannita SQL Server Data Types Character strings: Data type Description Storage char(n) varchar(n) varchar(max) text Fixed-length character string. Maximum 8,000 characters Variable-length

More information

SQL Data Definition and Data Manipulation Languages (DDL and DML)

SQL Data Definition and Data Manipulation Languages (DDL and DML) .. Cal Poly CPE/CSC 365: Introduction to Database Systems Alexander Dekhtyar.. SQL Data Definition and Data Manipulation Languages (DDL and DML) Note: This handout instroduces both the ANSI SQL synatax

More information

Basic SQL. Dr Fawaz Alarfaj. ACKNOWLEDGEMENT Slides are adopted from: Elmasri & Navathe, Fundamentals of Database Systems MySQL Documentation

Basic SQL. Dr Fawaz Alarfaj. ACKNOWLEDGEMENT Slides are adopted from: Elmasri & Navathe, Fundamentals of Database Systems MySQL Documentation Basic SQL Dr Fawaz Alarfaj Al Imam Mohammed Ibn Saud Islamic University ACKNOWLEDGEMENT Slides are adopted from: Elmasri & Navathe, Fundamentals of Database Systems MySQL Documentation MIDTERM EXAM 2 Basic

More information

Downloaded from

Downloaded from Lesson 16: Table and Integrity Constraints Integrity Constraints are the rules that a database must follow at all times. Various Integrity constraints are as follows:- 1. Not Null: It ensures that we cannot

More information

Chapter-14 SQL COMMANDS

Chapter-14 SQL COMMANDS Chapter-14 SQL COMMANDS What is SQL? Structured Query Language and it helps to make practice on SQL commands which provides immediate results. SQL is Structured Query Language, which is a computer language

More information

Basic SQL. Basic SQL. Basic SQL

Basic SQL. Basic SQL. Basic SQL Basic SQL Dr Fawaz Alarfaj Al Imam Mohammed Ibn Saud Islamic University ACKNOWLEDGEMENT Slides are adopted from: Elmasri & Navathe, Fundamentals of Database Systems MySQL Documentation Basic SQL Structured

More information

Table Joins and Indexes in SQL

Table Joins and Indexes in SQL Table Joins and Indexes in SQL Based on CBSE Curriculum Class -11 By- Neha Tyagi PGT CS KV 5 Jaipur II Shift Jaipur Region Neha Tyagi, PGT CS II Shift Jaipur Introduction Sometimes we need an information

More information

Exact Numeric Data Types

Exact Numeric Data Types SQL Server Notes for FYP SQL data type is an attribute that specifies type of data of any object. Each column, variable and expression has related data type in SQL. You would use these data types while

More information

Chapter 8 How to work with data types

Chapter 8 How to work with data types Chapter 8 How to work with data types Murach's MySQL, C8 2015, Mike Murach & Associates, Inc. Slide 1 Objectives Applied Code queries that convert data from one data type to another. Knowledge Describe

More information

SQL Introduction. CS 377: Database Systems

SQL Introduction. CS 377: Database Systems SQL Introduction CS 377: Database Systems Recap: Last Two Weeks Requirement analysis Conceptual design Logical design Physical dependence Requirement specification Conceptual data model (ER Model) Representation

More information

Module 3 MySQL Database. Database Management System

Module 3 MySQL Database. Database Management System Module 3 MySQL Database Module 3 Contains 2 components Individual Assignment Group Assignment BOTH are due on Mon, Feb 19th Read the WIKI before attempting the lab Extensible Networking Platform 1 1 -

More information

Downloaded from

Downloaded from UNIT 3 CHAPTER 13: DATABASE FUNDAMENTALS - MYSQL REVISION TOUR Database: Collection of logically related data stored in a structure format. DBMS: Software used to manage databases is called Data Base Management

More information

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

SQL: Concepts. Todd Bacastow IST 210: Organization of Data 2/17/ IST 210 SQL: Concepts Todd Bacastow IST 210: Organization of Data 2/17/2004 1 Design questions How many entities are there? What are the major entities? What are the attributes of each entity? Is there a unique

More information

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

Chapter 4. Basic SQL. SQL Data Definition and Data Types. Basic SQL. SQL language SQL. Terminology: CREATE statement Chapter 4 Basic SQL Basic SQL SQL language Considered one of the major reasons for the commercial success of relational databases SQL Structured Query Language Statements for data definitions, queries,

More information

Database Management Systems

Database Management Systems ADIKAVI NANNAYA UNIVERSITY CBCS/SEMESTER SYSTEM IV SEMESTER BACHELOR OF COMPUTER APPLICATIONS (w.e.f. 2015-16 Admitted Batch) Database Management Systems Unit-I: Database Systems Introduction and Fundamentals:

More information

SQL Structured Query Language Introduction

SQL Structured Query Language Introduction SQL Structured Query Language Introduction Rifat Shahriyar Dept of CSE, BUET Tables In relational database systems data are represented using tables (relations). A query issued against the database also

More information

SQL - Basics. SQL Overview

SQL - Basics. SQL Overview SQL - Basics Davood Rafiei 1 SQL Overview Structured Query Language standard query language for relational system. developed in IBM Almaden (system R) Some features Declarative: specify the properties

More information

SQL Lab Query 5. More SQL Aggregate Queries, Null Values. SQL Lab Query 8. SQL Lab Query 5. SQL Lab Query 8. SQL Lab Query 9

SQL Lab Query 5. More SQL Aggregate Queries, Null Values. SQL Lab Query 8. SQL Lab Query 5. SQL Lab Query 8. SQL Lab Query 9 SQL Lab Query 5 Sailors sid sname rating age Reserves sid bid day Boats bid name color More SQL Aggregate Queries, Null Values Slides based on Database Management Systems 3 rd ed, Ramakrishnan and Gehrke

More information

MySQL Introduction. By Prof. B.A.Khivsara

MySQL Introduction. By Prof. B.A.Khivsara MySQL Introduction By Prof. B.A.Khivsara Note: The material to prepare this presentation has been taken from internet and are generated only for students reference and not for commercial use. Outline Design

More information

SQL - Lecture 3 (Aggregation, etc.)

SQL - Lecture 3 (Aggregation, etc.) SQL - Lecture 3 (Aggregation, etc.) INFS 614 INFS614 1 Example Instances S1 S2 R1 sid bid day 22 101 10/10/96 58 103 11/12/96 sid sname rating age 22 dustin 7 45.0 31 lubber 8 55.5 58 rusty 10 35.0 sid

More information

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

Chapter 13 : Informatics Practices. Class XI ( As per CBSE Board) SQL Commands. New Syllabus Visit : python.mykvs.in for regular updates Chapter 13 : Informatics Practices Class XI ( As per CBSE Board) SQL Commands New Syllabus 2018-19 SQL SQL is an acronym of Structured Query Language.It is a standard language developed and used for accessing

More information

INTRODUCTION TO MYSQL MySQL : It is an Open Source RDBMS Software that uses Structured Query Language. It is available free of cost. Key Features of MySQL : MySQL Data Types: 1. High Speed. 2. Ease of

More information

Programming and Database Fundamentals for Data Scientists

Programming and Database Fundamentals for Data Scientists Programming and Database Fundamentals for Data Scientists Database Fundamentals Varun Chandola School of Engineering and Applied Sciences State University of New York at Buffalo Buffalo, NY, USA chandola@buffalo.edu

More information

Downloaded from

Downloaded from Unit-III DATABASES MANAGEMENT SYSTEM AND SQL DBMS & Structured Query Language Chapter: 07 Basic Database concepts Data : Raw facts and figures which are useful to an organization. We cannot take decisions

More information

SQL OVERVIEW. CS121: Relational Databases Fall 2017 Lecture 4

SQL OVERVIEW. CS121: Relational Databases Fall 2017 Lecture 4 SQL OVERVIEW CS121: Relational Databases Fall 2017 Lecture 4 SQL 2 SQL = Structured Query Language Original language was SEQUEL IBM s System R project (early 1970 s) Structured English Query Language Caught

More information

QQ Group

QQ Group QQ Group: 617230453 1 Extended Relational-Algebra-Operations Generalized Projection Aggregate Functions Outer Join 2 Generalized Projection Extends the projection operation by allowing arithmetic functions

More information

*this is a guide that was created from lecture videos and is used to help you gain an understanding of what is mysql used for.

*this is a guide that was created from lecture videos and is used to help you gain an understanding of what is mysql used for. mysql. 1 what is mysql used for. *this is a guide that was created from lecture videos and is used to help you gain an understanding of what is mysql used for. MySQL Installation MySQL is an open source

More information

Lecture 07. Spring 2018 Borough of Manhattan Community College

Lecture 07. Spring 2018 Borough of Manhattan Community College Lecture 07 Spring 2018 Borough of Manhattan Community College 1 SQL Identifiers SQL identifiers are used to identify objects in the database, such as table names, view names, and columns. The ISO standard

More information

Entity-Relationship Modelling. Entities Attributes Relationships Mapping Cardinality Keys Reduction of an E-R Diagram to Tables

Entity-Relationship Modelling. Entities Attributes Relationships Mapping Cardinality Keys Reduction of an E-R Diagram to Tables Entity-Relationship Modelling Entities Attributes Relationships Mapping Cardinality Keys Reduction of an E-R Diagram to Tables 1 Entity Sets A enterprise can be modeled as a collection of: entities, and

More information

Vidya Pratishthan s College Of Engineering, Baramati. Laboratory Manual Database Management System Laboratory

Vidya Pratishthan s College Of Engineering, Baramati. Laboratory Manual Database Management System Laboratory Vidya Pratishthan s College Of Engineering, Baramati Laboratory Manual Database Management System Laboratory Third Year - Information Technology (2012) Examination Scheme Practical: 50 marks Oral: 50 Marks

More information

MySQL: an application

MySQL: an application Data Types and other stuff you should know in order to amaze and dazzle your friends at parties after you finally give up that dream of being a magician and stop making ridiculous balloon animals and begin

More information

THE UNIVERSITY OF AUCKLAND

THE UNIVERSITY OF AUCKLAND VERSION 1 COMPSCI 280 THE UNIVERSITY OF AUCKLAND SECOND SEMESTER, 2015 Campus: City COMPUTER SCIENCE Enterprise Software Development (Time allowed: 40 minutes) NOTE: Enter your name and student ID into

More information

CSCC43H: Introduction to Databases. Lecture 4

CSCC43H: Introduction to Databases. Lecture 4 CSCC43H: Introduction to Databases Lecture 4 Wael Aboulsaadat Acknowledgment: these slides are partially based on Prof. Garcia-Molina & Prof. Ullman slides accompanying the course s textbook. CSCC43: Introduction

More information

Database Systems Laboratory 2 SQL Fundamentals

Database Systems Laboratory 2 SQL Fundamentals Database Systems Laboratory 2 another from another School of Computer Engineering, KIIT University 2.1 1 2 3 4 5 6 7 8 another from another 9 another 10 from another 11 2.2 Student table Roll Name City

More information

HOW TO CREATE AND MAINTAIN DATABASES AND TABLES. By S. Sabraz Nawaz Senior Lecturer in MIT FMC, SEUSL

HOW TO CREATE AND MAINTAIN DATABASES AND TABLES. By S. Sabraz Nawaz Senior Lecturer in MIT FMC, SEUSL HOW TO CREATE AND MAINTAIN DATABASES AND TABLES By S. Sabraz Nawaz Senior Lecturer in MIT FMC, SEUSL What is SQL? SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate

More information

Database Foundations. 6-3 Data Definition Language (DDL) Copyright 2015, Oracle and/or its affiliates. All rights reserved.

Database Foundations. 6-3 Data Definition Language (DDL) Copyright 2015, Oracle and/or its affiliates. All rights reserved. Database Foundations 6-3 Roadmap You are here Introduction to Oracle Application Express Structured Query Language (SQL) Data Definition Language (DDL) Data Manipulation Language (DML) Transaction Control

More information

Conceptual Design. The Entity-Relationship (ER) Model

Conceptual Design. The Entity-Relationship (ER) Model Conceptual Design. The Entity-Relationship (ER) Model CS430/630 Lecture 12 Slides based on Database Management Systems 3 rd ed, Ramakrishnan and Gehrke Relationship Set Representation ssn name lot since

More information

Designing Tables for an Oracle Database System. From theory to practice

Designing Tables for an Oracle Database System. From theory to practice Designing Tables for an Oracle Database System Database Course, Fall 2004 From theory to practice The Entity- Relationship model: a convenient way of representing the world. The Relational model: a model

More information

VIEW OTHER QUESTION PAPERS

VIEW OTHER QUESTION PAPERS VIEW OTHER QUESTION PAPERS E B4E0562 Reg No.: Name: Total Pages: 2 APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY FOURTH SEMESTER B.TECH DEGREE EXAMINATION, JULY 2017 Course Code: CS208 Course Name: PRINCIPLES

More information

This lab will introduce you to MySQL. Begin by logging into the class web server via SSH Secure Shell Client

This lab will introduce you to MySQL. Begin by logging into the class web server via SSH Secure Shell Client Lab 2.0 - MySQL CISC3140, Fall 2011 DUE: Oct. 6th (Part 1 only) Part 1 1. Getting started This lab will introduce you to MySQL. Begin by logging into the class web server via SSH Secure Shell Client host

More information

1) Introduction to SQL

1) Introduction to SQL 1) Introduction to SQL a) Database language enables users to: i) Create the database and relation structure; ii) Perform insertion, modification and deletion of data from the relationship; and iii) Perform

More information

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

SQL Data Definition Language: Create and Change the Database Ray Lockwood Introductory SQL SQL Data Definition Language: Create and Change the Database Pg 1 SQL Data Definition Language: Create and Change the Database Ray Lockwood Points: DDL statements create and alter the

More information

Draft. Students Table. FName LName StudentID College Year. Justin Ennen Science Senior. Dan Bass Management Junior

Draft. Students Table. FName LName StudentID College Year. Justin Ennen Science Senior. Dan Bass Management Junior Chapter 6 Introduction to SQL 6.1 What is a SQL? When would I use it? SQL stands for Structured Query Language. It is a language used mainly for talking to database servers. It s main feature divisions

More information

CIS 363 MySQL. Chapter 4 MySQL Connectors Chapter 5 Data Types Chapter 6 Identifiers

CIS 363 MySQL. Chapter 4 MySQL Connectors Chapter 5 Data Types Chapter 6 Identifiers CIS 363 MySQL Chapter 4 MySQL Connectors Chapter 5 Data Types Chapter 6 Identifiers Ch. 4 MySQL Connectors *** Chapter 3 MySQL Query Browser is Not covered on MySQL certification exam. For details regarding

More information

Introduction to MySQL /MariaDB and SQL Basics. Read Chapter 3!

Introduction to MySQL /MariaDB and SQL Basics. Read Chapter 3! Introduction to MySQL /MariaDB and SQL Basics Read Chapter 3! http://dev.mysql.com/doc/refman/ https://mariadb.com/kb/en/the-mariadb-library/documentation/ MySQL / MariaDB 1 College Database E-R Diagram

More information

V SEMESTER SOFTWARE ENGINEERING. Subject Code: 10IS51 I.A. Marks : 25 Hours/Week : 04 Exam Hours: 03 Total Hours : 52 Exam Marks: 100 PART A

V SEMESTER SOFTWARE ENGINEERING. Subject Code: 10IS51 I.A. Marks : 25 Hours/Week : 04 Exam Hours: 03 Total Hours : 52 Exam Marks: 100 PART A V SEMESTER SOFTWARE ENGINEERING Subject Code: 10IS51 I.A. Marks : 25 Hours/Week : 04 Exam Hours: 03 Total Hours : 52 Exam Marks: 100 PART A UNIT 1 Overview: Introduction: FAQ's about software engineering,

More information

Principles of Data Management

Principles of Data Management Principles of Data Management Alvin Lin August 2018 - December 2018 Structured Query Language Structured Query Language (SQL) was created at IBM in the 80s: SQL-86 (first standard) SQL-89 SQL-92 (what

More information

The DBMS accepts requests for data from the application program and instructs the operating system to transfer the appropriate data.

The DBMS accepts requests for data from the application program and instructs the operating system to transfer the appropriate data. Managing Data Data storage tool must provide the following features: Data definition (data structuring) Data entry (to add new data) Data editing (to change existing data) Querying (a means of extracting

More information

ASSIGNMENT NO 2. Objectives: To understand and demonstrate DDL statements on various SQL objects

ASSIGNMENT NO 2. Objectives: To understand and demonstrate DDL statements on various SQL objects ASSIGNMENT NO 2 Title: Design and Develop SQL DDL statements which demonstrate the use of SQL objects such as Table, View, Index, Sequence, Synonym Objectives: To understand and demonstrate DDL statements

More information

CSC Web Programming. Introduction to SQL

CSC Web Programming. Introduction to SQL CSC 242 - Web Programming Introduction to SQL SQL Statements Data Definition Language CREATE ALTER DROP Data Manipulation Language INSERT UPDATE DELETE Data Query Language SELECT SQL statements end with

More information

Applied Databases. Sebastian Maneth. Lecture 7 Simple SQL Queries. University of Edinburgh - February 6 st, 2017

Applied Databases. Sebastian Maneth. Lecture 7 Simple SQL Queries. University of Edinburgh - February 6 st, 2017 Applied Databases Lecture 7 Simple SQL Queries Sebastian Maneth University of Edinburgh - February 6 st, 2017 Outline 2 1. Structured Querying Language (SQL) 2. Creating Tables 3. Simple SQL queries SQL

More information

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

tablename ORDER BY column ASC tablename ORDER BY column DESC sortingorder, } The WHERE and ORDER BY clauses can be combined in one } The result of a query can be sorted in ascending or descending order using the optional ORDER BY clause. The simplest form of an ORDER BY clause is SELECT columnname1, columnname2, FROM tablename ORDER

More information

Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications. Today's Party. Example Database. Faloutsos/Pavlo CMU /615

Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications. Today's Party. Example Database. Faloutsos/Pavlo CMU /615 Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications C. Faloutsos A. Pavlo Lecture#6: Fun with SQL (part2) Today's Party DDLs Complex Joins Views Nested Subqueries Triggers Database

More information

DS Introduction to SQL Part 1 Single-Table Queries. By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford)

DS Introduction to SQL Part 1 Single-Table Queries. By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford) DS 1300 - Introduction to SQL Part 1 Single-Table Queries By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford) Overview 1. SQL introduction & schema definitions 2. Basic single-table

More information

NCSS: Databases and SQL

NCSS: Databases and SQL NCSS: Databases and SQL Tim Dawborn Lecture 1, January, 2016 Motivation SQLite SELECT WHERE JOIN Tips 2 Outline 1 Motivation 2 SQLite 3 Searching for Data 4 Filtering Results 5 Joining multiple tables

More information

A practical introduction to database design

A practical introduction to database design A practical introduction to database design Dr. Chris Tomlinson Bioinformatics Data Science Group, Room 126, Sir Alexander Fleming Building chris.tomlinson@imperial.ac.uk Computer Skills Classes 17/01/19

More information

Intro to Database Commands

Intro to Database Commands Intro to Database Commands SQL (Structured Query Language) Allows you to create and delete tables Four basic commands select insert delete update You can use clauses to narrow/format your result sets or

More information

MTAT Introduction to Databases

MTAT Introduction to Databases MTAT.03.105 Introduction to Databases Lecture #3 Data Types, Default values, Constraints Ljubov Jaanuska (ljubov.jaanuska@ut.ee) Lecture 1. Summary SQL stands for Structured Query Language SQL is a standard

More information

Chapter 3: Introduction to SQL. Chapter 3: Introduction to SQL

Chapter 3: Introduction to SQL. Chapter 3: Introduction to SQL Chapter 3: Introduction to SQL Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 3: Introduction to SQL Overview of The SQL Query Language Data Definition Basic Query

More information

Applied Databases. Sebastian Maneth. Lecture 7 Simple SQL Queries. University of Edinburgh - February 1 st, 2016

Applied Databases. Sebastian Maneth. Lecture 7 Simple SQL Queries. University of Edinburgh - February 1 st, 2016 Applied Databases Lecture 7 Simple SQL Queries Sebastian Maneth University of Edinburgh - February 1 st, 2016 Outline 2 1. Structured Querying Language (SQL) 2. Creating Tables 3. Simple SQL queries SQL

More information

D B M G. SQL language: basics. Managing tables. Creating a table Modifying table structure Deleting a table The data dictionary Data integrity

D B M G. SQL language: basics. Managing tables. Creating a table Modifying table structure Deleting a table The data dictionary Data integrity SQL language: basics Creating a table Modifying table structure Deleting a table The data dictionary Data integrity 2013 Politecnico di Torino 1 Creating a table Creating a table (1/3) The following SQL

More information

2011 DATABASE MANAGEMENT SYSTEM

2011 DATABASE MANAGEMENT SYSTEM Name :. Roll No. :..... Invigilator s Signature :.. CS/B.TECH(IT)/SEM-6/IT-604/2011 2011 DATABASE MANAGEMENT SYSTEM Time Allotted : 3 Hours Full Marks : 70 The figures in the margin indicate full marks.

More information

Operating systems fundamentals - B07

Operating systems fundamentals - B07 Operating systems fundamentals - B07 David Kendall Northumbria University David Kendall (Northumbria University) Operating systems fundamentals - B07 1 / 33 What is SQL? Structured Query Language Used

More information

Advanced SQL. Nov 21, CS445 Pacific University 1

Advanced SQL. Nov 21, CS445 Pacific University 1 Advanced SQL Nov 21, 2017 http://zeus.cs.pacificu.edu/chadd/cs445f17/advancedsql.tar.gz Pacific University 1 Topics Views Triggers Stored Procedures Control Flow if / case Binary Data Pacific University

More information

From theory to practice. Designing Tables for an Oracle Database System. Sqlplus. Sqlplus. Technicalities. Add the following to your.

From theory to practice. Designing Tables for an Oracle Database System. Sqlplus. Sqlplus. Technicalities. Add the following to your. From theory to practice Designing Tables for an Oracle Database System The Entity-Relationship model: a convenient way of representing the world. The Relational model: a model for organizing data using

More information

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

CS 327E Lecture 2. Shirley Cohen. January 27, 2016 CS 327E Lecture 2 Shirley Cohen January 27, 2016 Agenda Announcements Homework for today Reading Quiz Concept Questions Homework for next time Announcements Lecture slides and notes will be posted on the

More information

Islamic University of Gaza Faculty of Engineering Department of Computer Engineering Fall 2011 ECOM 4113: Database System Lab Eng.

Islamic University of Gaza Faculty of Engineering Department of Computer Engineering Fall 2011 ECOM 4113: Database System Lab Eng. Islamic University of Gaza Faculty of Engineering Department of Computer Engineering Fall 2011 ECOM 4113: Database System Lab Eng. Ahmed Abumarasa Database Lab Lab 2 Database Table Introduction: The previous

More information

15CSL58: DATABASE MANAGEMENT LABORATORY

15CSL58: DATABASE MANAGEMENT LABORATORY 15CSL58: DATABASE MANAGEMENT LABORATORY Subject Code: 15CSL58 I.A. Marks: 20 Hours/Week: L(1)+P(2) Exam Hours: 03 Total Hours: 40 Exam Marks: 80 Course objectives: This course will enable students to Foundation

More information

SQL Data Manipulation Language. Lecture 5. Introduction to SQL language. Last updated: December 10, 2014

SQL Data Manipulation Language. Lecture 5. Introduction to SQL language. Last updated: December 10, 2014 Lecture 5 Last updated: December 10, 2014 Throrought this lecture we will use the following database diagram Inserting rows I The INSERT INTO statement enables inserting new rows into a table. The basic

More information

Department of Computer Science University of Cyprus. EPL342 Databases. Lab 2

Department of Computer Science University of Cyprus. EPL342 Databases. Lab 2 Department of Computer Science University of Cyprus EPL342 Databases Lab 2 ER Modeling (Entities) in DDS Lite & Conceptual Modeling in SQL Server 2008 Panayiotis Andreou http://www.cs.ucy.ac.cy/courses/epl342

More information

Database Management Systems,

Database Management Systems, Database Management Systems Database Design (2) 1 Topics Data Base Design Logical Design (Review) Physical Design Entity Relationship (ER) Model to Relational Model Entity Relationship Attributes Normalization

More information

Structure Query Language (SQL)

Structure Query Language (SQL) Structure Query Language (SQL) 1 Example to Select all Records from Table A special character asterisk * is used to address all the data(belonging to all columns) in a query. SELECT statement uses * character

More information