Programming with data Lab 8

Slides:



Advertisements
Similar presentations
ER Model For a college DB
Advertisements

Introduction to SQL 1 Lecture 5. Introduction to SQL 2 Note in different implementations the syntax might slightly differ different features might be.
R ELATIONAL M ODEL TO SQL Data Model. 22 C ONCEPTUAL D ESIGN : ER TO R ELATIONAL TO SQL How to represent Entity sets, Relationship sets, Attributes, Key.
Logical DB Design: ER to Relational Entity sets to tables. Employees ssn name lot CREATE TABLE Employees (ssn CHAR (11), name CHAR (20), lot INTEGER, PRIMARY.
ER Modeling Case Studies
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
Employee database: Conceptual Schema in ERD Chapter 3, page 62.
CSE 190: Internet E-Commerce Lecture 10: Data Tier.
Information Resources Management February 13, 2001.
Introduction to Information and Computer Science Databases and SQL Lecture b This material (Comp4_Unit6b) was developed by Oregon Health & Science University,
Database Systems Marcus Kaiser School of Computing Science Newcastle University.
Database. Basic Definitions Database: A collection of related data. Database Management System (DBMS): A software package/ system to facilitate the creation.
Databases in Visual Studio. Database in VisualStudio An MS SQL database are built in Visual studio The Name can be something like ”(localdb)\Projects”
SQL Structured Query Language Programming Course.
1 n 1 n 1 1 n n Schema for part of a business application relational database.
Assignements. CSC343: Intro. to Databases2 Exercise 1 Superkeys: Candidate keys: Primary key:
Databases MIS 21. Some database terminology  Database: integrated collection of data  Database Management System (DBMS): environment that provides mechanisms.
Database Management System Quiz 1. A company needs to store information about: the employees identified by EmpNo, Name, Salary and Phone; departments.
Chapter 7 Data Modeling with Entity Relationship Diagrams
Database Management COP4540, SCS, FIU Database Modeling Using the Entity-Relationship Model (Continued)
 Entity-relationship models (ERM) Entity-relationship models (ERM)  Simple E-R Diagram Simple E-R Diagram  Weak Entity Weak Entity  Strong Entity.
SE305 Database System Technology 23/10/2014 Quiz-2.
COMP3030 Database Management System Final Review
Understand Primary, Foreign, and Composite Keys Database Administration Fundamentals LESSON 4.2.
SQL Exercises – Part I April
EntityRelationshipDiagrams. Entity Relationship Models The E-R (entity-relationship) data model views the real world as a set of basic objects (entities)
Introduction to Database SEM I, AY Department of Information Technology Salalah College of Technology Chapter No.3 SQL.
Simple Queries DBS301 – Week 1. Objectives Basic SELECT statement Computed columns Aliases Concatenation operator Use of DISTINCT to eliminate duplicates.
CCT395, Week 6 Implementing a Database with SQL and a Case Study Exercise This presentation is licensed under Creative Commons Attribution License, v.
Order Database – ER Diagram
Assignements.
The Entity-Relationship Model
CS320 Web and Internet Programming SQL and MySQL
Order Database – ER Diagram
COP5725 Database Management ER DIAGRAM AND RELATIONAL DATA MODEL
COP 4540 Database Management
IST 210: Organization of Data
Database Concepts Relational Databases Start ….
ER Diagram Practical Example
Using SQL Server through Command Prompt
A Table with a View: Database Queries
Order Database – ER Diagram
Order Database – ER Diagram
SQL-lab Download sql script file sailors.txt
Payroll Management System
CIS 336 Competitive Success/snaptutorial.com
CIS 336 Education for Service-- snaptutorial.com.
CIS 336 Teaching Effectively-- snaptutorial.com
CIS 336 PAPERS Education for Service-- cis336papers.com.
Generalization.
SQL – Column constraints
Order Database – ER Diagram
Entity Relationship Diagrams ERDs
Entity-Relationship Modeling "Extended"
DATABASE SQL= Structure Query Language مبادئ قواعد بيانات
Database Design Agenda
Order Database – ER Diagram
A Table with a View: Database Queries
CS3220 Web and Internet Programming SQL and MySQL
Day 2 - Basic Database Backbone
IST 318 Database Administration
Summary Data Modeling SDLC What is Data Modeling
E.R. Examples.
CS3220 Web and Internet Programming SQL and MySQL
A Table with a View: Database Queries
កម្មវិធីបង្រៀន SQL Programming ជាភាសាខ្មែរ Online SQL Training Course
Entity-Relationship Modeling "Extended"
Entity-Relationship Modeling "Extended"
Practice Project Practice to know SQL
Presentation transcript:

Programming with data Lab 8 Wednesday, 5 December 2018 Stelios Sotiriadis Prof. Alessandro Provetti

Study the following Entity relationshp diagram How to create an ER diagram: Create boxes for each entity Model the relationships between each by drawing lines to connect related entities. Identify relevant attributes within each entity. Review your model.

In class activity: Design a database (DB) system Create small teams and work together to design a DB system You task is to design an ER diagram for an online book store. Identify at least 5 tables Create the relationships between the tables A yellow team meet with one blue team to discuss their findings

SQL Queries Class8-sql-exercise-1.txt

1 Create the following tables

1 Create the following tables Create a table called department. Entities: DeptName varchar(24) not null primary key, Address varchar(24), City varchar(24) Create a table called employee. Entities: employeeID integer primary key, FirstName varchar(24) not null, Surname varchar(24) not null, Dept varchar(24) not null REFERENCES department(DeptName), Office integer, Salary Integer, City varchar(24)

2 Insert data (Class8-sql-exercise-1.txt) INSERT ALL INTO department (DeptName, Address, City) VALUES ('Administration','Bond Street','London') INTO department (DeptName, Address, City) VALUES ('Production','Rue Victor Hugo','Toulouse') INTO department (DeptName, Address, City) VALUES ('Distribution','Pond Street','Brighton') INTO department (DeptName, Address, City) VALUES ('Planning','Bond Street','London') INTO department (DeptName, Address, City) VALUES ('Research','Sunset Street','San Jose') SELECT * FROM dual; INTO employee (employeeID, FirstName, Surname, Dept, Office, Salary, City) VALUES (100,'Mary','Brown','Administration',10,45,'London') INTO employee (employeeID, FirstName, Surname, Dept, Office, Salary, City) VALUES (101,'Charles','White','Production',20,36,'Toulouse') INTO employee (employeeID, FirstName, Surname, Dept, Office, Salary, City) VALUES (102,'Gus','Green','Administration',20,40,'Toulouse') INTO employee (employeeID, FirstName, Surname, Dept, Office, Salary, City) VALUES (103,'Jackson','Neri','Distribution',16,45,'Toulouse') INTO employee (employeeID, FirstName, Surname, Dept, Office, Salary, City) VALUES (104,'Charles','Brown','Planning',14,80,'Toulouse') INTO employee (employeeID, FirstName, Surname, Dept, Office, Salary, City) VALUES (105,'Laurence','Chen','Planning',7,73,'Toulouse') INTO employee (employeeID, FirstName, Surname, Dept, Office, Salary, City) VALUES (106,'Pauline','Bradshaw','Administration',75,40,'Toulouse') INTO employee (employeeID, FirstName, Surname, Dept, Office, Salary, City) VALUES (107,'Alice','Jackson','Production',20,46,'Toulouse')

3 Run the following queries: Find the salaries of employees named Brown. Find all the information relating to employees named Brown. Find the monthly salary of the employees named White. Find the names of the employees and the cities in which they work (Simple join query) Find the names of the employees and the cities in which they work (using an alias)

3 Run the following queries: Find the first names and surnames of the employees who work in office number 20 of the Administration department Find the first names and surnames of the employees who work in either the Administration or the Production department. Find the first names of the employees named Brown who work in the Administration department or the Production department Find the employees with surnames that have ‘r’ as the second letter and end in ‘n’ Find the names of the employees and the cities in which they work.