Leksioni nr 2 Data Base.

Slides:



Advertisements
Similar presentations
Complex Integrity Constraints in SQL. Constraints over a Single Table Table Constraint: Create TABLE Sailors (sid INTEGER, sname CHAR(10), rating INTEGER,
Advertisements

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.
The Relational Model Class 2 Book Chapter 3 Relational Data Model Relational Query Language (DDL + DML) Integrity Constraints (IC) (From ER to Relational)
Midterm Review Lecture 14b. 14 Lectures So Far 1.Introduction 2.The Relational Model 3.Disks and Files 4.Relational Algebra 5.File Org, Indexes 6.Relational.
SPRING 2004CENG 3521 The Relational Model Chapter 3.
1 Relational Model. 2 Relational Database: Definitions  Relational database: a set of relations  Relation: made up of 2 parts: – Instance : a table,
The Relational Model Lecture 3 Book Chapter 3 Relational Data Model Relational Query Language (DDL + DML) Integrity Constraints (IC) From ER to Relational.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 SQL: Queries, Constraints, Triggers Chapter 5.
The Relational Model These slides are based on the slides of your text book.
The Relational Model. Review Why use a DBMS? OS provides RAM and disk.
Algjebra Relacionale & SQL
1 The Relational Model. 2 Why Study the Relational Model? v Most widely used model. – Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. v “Legacy.
FALL 2004CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
1.1 CAS CS 460/660 Relational Model. 1.2 Review E/R Model: Entities, relationships, attributes Cardinalities: 1:1, 1:n, m:1, m:n Keys: superkeys, candidate.
CMPT 258 Database Systems The Relationship Model (Chapter 3)
1 Announcements Reading for next week: Chapter 4 Your first homework will be assigned as soon as your database accounts have been set up.  Expect an .
The Relational Model Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY.
Chapter 3 The Relational Model. Why Study the Relational Model? Most widely used model. Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. “Legacy.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
1 CS122A: Introduction to Data Management Lecture #4 (E-R  Relational Translation) Instructor: Chen Li.
CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
 Database – collection of persistent data  Database Management System (DBMS) – software system that supports creation, population, and querying of a.
SQL Database Management Systems, 3rd ed., Ramakrishnan and Gehrke, Chapter 5.
Relational Algebra Database Management Systems, 3rd ed., Ramakrishnan and Gehrke, Chapter 4.
Database Systems (資料庫系統)
COP Introduction to Database Structures
These slides are based on the slides of your text book.
CS 186, Fall 2006, Lecture 2 R & G, Chap. 3
Teknologji Informative
Relational Algebra Chapter 4, Part A
SH.M.U-2 Lënda:Informatikë Tema:Sistemi operativ (Windows 8)
Introduction to Relational Databases
The Relational Model Lecture 3 INFS614, Fall
Universiteti Shtetëror i Tetovës Fakulteti i Shkencave Matematike-Natyrore Departamenti i Informatikës PROGRAMIM.
SQL: Structured Query Language (‘Sequel’)
Database Systems 10/13/2010 Lecture #4.
Relational Algebra.
Bazat e te dhenave Elemente kryesore te MySQL-se
Database Systems (資料庫系統)
The Relational Model Content based on Chapter 3
Elementet e gjuhës C++.
The Relational Model Chapter 3
The Relational Model Relational Data Model
Relational Databases The Relational Model.
Relational Databases The Relational Model.
CS 405G: Introduction to Database Systems
MS POWERPOINT PREZANTIMET.
The Relational Model Chapter 3
Universiteti AAB Programi: PSIKOLOGJI STATISTIKE T-testi Për grupet e pavarura Për grupet e varura Dr.sc. Merita Shala.
Menaxhimi i perdoruesve dhe grupeve
Relational Calculus.
SQL: The Query Language Part 1
LEKSION 9 Dizenjimi i database-it relacional.
I Love my family!!!.
The Relational Model The slides for this text are organized into chapters. This lecture covers Chapter 3. Chapter 1: Introduction to Database Systems Chapter.
LEKSION 4 Diagrama E-R. Karakteristika te modelit të zgjeruar E-R.
Degëzimet.
Database Systems (資料庫系統)
The Relational Model Chapter 3
Degëzimet.
SQL: Structured Query Language
Database Dr. Roueida Mohammed.
SQL: Structured Query Language
Introduction to Database Systems
CENG 351 File Structures and Data Managemnet
The Relational Model Content based on Chapter 3
The Relational Model Content based on Chapter 3
Operatorët.
The Relational Model Chapter 3
Presentation transcript:

Leksioni nr 2 Data Base

Karakteristika te DB Data Definition Language – DDL: Gjuha standarte per krijimin, manipulimin dhe pyetesorin mbi te dhena eshte nje DBMS. Bashkesia e konstruksioneve qe ofron kushte specifike quhen kushtet e integritetit, duke I dhene mundesi DBMS te refuzoje operacionet qe mund te korruptojne data Konstrukti baze per shfaqjen e te dhenave ne modelin relacional eshte nje “relation”. Nje instance relacionale eshte nje tabele dhe skeme relacionale eshte skema qe jep kokat e kollonave per tabele

Data Definition Language CREATE TABLE Students ( sid CHAR(20), name CHAR(30), login CHAR(20), age INTEGER, gpa REAL ) INSERT INTO Students (sid, name, login, age, gpa) VALUES (53688, `Smith', `smith@ee', 18, 3.2) DELETE FROM Students S WHERE S.name = `Smith‘ UPDATE Students S SET S.age = S.age + 1, S.gpa = S.gpa - 1 WHERE S.sid = 53688 sid name login age gpa 53831 Madayan madayan@music 11 1.8 53832 Guldu guldu@music 12 2.0 53688 Smith smith@ee 18 3.2 53650 Smith smith@math 19 3.8 53666 Jones jones@cs 18 3.4 50000 Dave dave@cs 19 3.3

Integriteti I te dhenave Nje “integrity constraint (IC)” eshte nje kusht qe specifikohet ne nje DB dhe kufizon te drejtat e datave te ruajtura ne nje instance te saj. Nje DBMS detyron IC, duke lejuar vetem instancat e rregullta te ruajtura ne DB. Kur ekzekutohet nje aplikacion DB, DBMS verifikon rastet “hazard” duke mos lejuar ndryshimet qe prekin rregullat IC.

“Key Constrain” Nje “key constraint” eshte nje forme deklarative ku nje grup minimal fushash sherben si nje identifikues unik zakonisht ne e shkurtojme ne thjesht “key” ose “celes Superkey, eshte percaktuar ne modelin relacional te nje DB si nje bashkesi atributesh te nje grupi variablash ku te gjithe atributet e skemes jane te varura funksionalisht. Nje relacion mund te kete disa celesa kandidate. Psh: duke deklaruar {login, age} ky eshte nje celes, qe perdoruesi deklaron se dy student mund te kene te njejtin login ose moshe, por jo te dyja. Nga te gjithe celesat kandidate te disponueshem, nje disenjues database mund te percaktoje nje celes primar. Nje gjuhe query eshte e specializuar per gjenerimin e pyetsoreve.

Tipet e Ndryshme Tipet DISTINCT ne SQL: Nje krahasim I dy vlerave te ndryshme nga domain te ndryshem, arrin te mos realizohet megjithese vlerat jane te perngjashme psh jane numerike, ose vlera string etj. Psh rroga dhe mosha. SQL-92: Problemi ekziston SQL:1999, Problemi zgjidhet.

Projektimi Logical DB Modeli ER eshte nje forme e pershtatshme per projektimin e nje DB ne nivel te larte. Diagrama ER pershkruan nje DB, ka nje standart qe gjeneron nje skeme relacionale DB Bashkesia Relationship hartezohet me m dhe n entitete.

“Algjebra Relacionale” “Relational algebra” eshte nje nga dy format e gjuheve query qe shoqerohet me modelin relacional. Pyetjet ne algebra perbehen nga nje sere operatoresh. “Algjebra relacionale” perfshin operatoret per selektimin e rreshtave nga nje relacion (σ) dhe ne projektimin e kolonave (π). Keto operacione na lejojne te manipulojme data ne nje relacion te vetem

Bashkesia e Operacioneve Operacionet standarte jane te mundshme ne algjebren relacionale: Union (U), intersection (ᴨ), set-difference (−), and cross-product (x) EQUIJOIN: Nje forme speciale I operatorit JOIN (R Φ S) eshte kur kushtet JOIN konsistojne ne formen e barazimit R:name1 = S:name2, qe ka te beje me barazine midis dy fushave R dhe S Operator DIVIDE eshte I nevojshem per te shprehur nje grup pyetjesh per shembull: Find the names of sailors who have reserved all boats. Division operator nuk ka te njejten rendesi si operatoret e tjere – nuk nevojitet shpesh, dhe sistemi database nuk shfrytezon semantiken te division-it duke e impelmentuar ate si nje operator distinct

“Relational Calculus” “Relacionet calculus” eshte nje forme alternative ne “algjebren relacionale”. Ne kundershtim me algebren, qe eshte forme procedurale, calculus eshte forme deklarative, duke lejuar qe te pershkruaje grupin e pergjigjeve pa e trajtuar si mund te llogariten. SQL dhe vecanerisht Query-by-Example (QBE). Varianti I calculus qe jepet ne hollesi quhet tuple relational calculus (TRC) Nje variabel tuple eshte nje variabel vlere qe merret ne tuple. Nje vaiabel domain eshte nje variabel qe ka nje range te gjere vlerash ne varesi te fushes ku operon domain, psh int, char etj.

Disa operator Renaming – Sherben per te bere riemerimin e nje instance me nje sere neninstancash.Keshtu ne vend te nje shprehje te plote algjebrike perdoret ndarja ne pjese me te vogla. Llogjika mbetet e njejta Joins dhe Condition Joins: Equijoin Natural Join Division