RDBMS Seminar
RDBMS Seminar
RDBMS Seminar
Ali Adams
Abu Dhabi Mens College Higher Colleges of Technology
Information Management
Data Information Knowledge Decision
27 age = 27 if age>25 risk is low set premium to low
Functions of DBMS
Create, alter and delete tables Add, update, and delete records Extract information from data Maintain data integrity and security Add, update and delete users Grant and revoke user privileges Data sharing & concurrency control Provide API for application builders
Logical design
Build a conceptual data-model of the natural form of the data using dataEAR diagrams and normalize it.
Physical Design
Map the conceptual model into tables, fields, keys, indexes, etc for a preferred DBMS.
Testing
Test for functionality correctness and then for design efficiency under the predicted usage level.
Implementation
Deploy the database within its target environment, write user documentation and train users.
Maintenance
Iron out any bugs, and schema-evolve the database as the organization schemaevolves.
Types of databases
Hierarchical
The hierarchical data-model is essentially a tree structure datathat allows each parent entity to own several child entities, but each child belongs to only one parent. parent.
Types of databases
Network
model except that child records are allowed to belong to many parent records, and thus any problem of multiple ownership is overcome.
Types of databases
Relational
The Relational data-model is based on set-theory which datasetis tabular and alphanumeric in nature.
ObjectObject-Oriented Databases
Types of databases
ObjectObject-Oriented
Departments Employees
Nested structure of
objects maintained
Supports class
hierarchy, inheritance and aggregation
Types of databases
Object Relational
Types of databases
Web Databases (XDBMS)
designers to specify their own extensions to the language and define their own data-types. data-
The order of columns and rows has no Primary keys used to directly access rows in
tables
Entity relationships
Primary Key (underlined) (underlined) Foreign Keys (italic) (italic)
Table Definitions:
PROPERTY (Uprn#, Name, Address, Value, ConArea# ) ( , CON_AREA (ConArea#, DateDec, Name ) (ConArea#,
Entity relationships
PROPERTY table
Uprn# Name Address Value ConArea# ConArea#
1 2 3 4 5
Mayes Jacobs St. Briggs Rural St. Reeves Canal St. Petch Peace Park Cornelius Hope Crescent
1 null 2 1 2
Find conservation area of property 3 ? Find the row with Uprn#= 3 in the Property table Read the value of ConArea# field for this row Search the Con_Area table for a matching ConArea# value Read the name of the conservation area from Con_Area table.
CON_AREA table
ConArea# DateDec Name
1 2
1970 1975
SELECT
SELECT FROM Property WHERE Value >= 50,000 as Expensive_Property
EXPENSIVE_PROPERTY Uprn# Name Address Value 2 Briggs Rural St 60000 4 Petch Peace Park 55000
PROJECT
PROJECT Occupier, Address FROM Property as Address
ADDRESS
Occupier Mayes Briggs Reeve Petch Cornelius Address Jacobs St Rural St Canal St Peace Park Hope Crescent
JOIN
JOIN Property AND Con_Area ON ConArea# as Prop_Con
PROP_CON
Uprn# P.Name Address 1 3 4 5 Mayes Jacob's St Reeve Canal St Petch Peace Park CorneliusHope Cres. Value Con Area# 30000 1 28000 2 55000 1 25000 2 Date Dec 1970 1975 1970 1970 C.Name Town Centre St Georges Town Centre St Georges
INTERSECT
New_Property INTERSECT 2bed_Property as New_2bed_Property
DIFFERENCE
DIFFERENCE All_Property AND Council_Property as Private_Property
DIVIDE
Divides a table of 2 columns with a table of 1 column.
1. Cascade Delete 2. 3.
Deleting the parent row will delete all rows in other tables that refer to it. Restrict Delete Cannot delete the parent row, unless no row is referring to it from other tables. Set to Null Upon deleting the parent row, its primary key is removed from all referencing rows in other tables and replaced by Null.
CREATE TABLE
CREATE TABLE Property (Uprn# integer NOT NULL, Occupier char(20), Address char(30), Value decimal(10.2));
ALTER TABLE
ALTER TABLE ALTER TABLE Property ADD (ConArea# integer);
DROP TABLE
DROP TABLE DROP TABLE Property;
CREATE VIEW
CREATE VIEW ConProp (ConName, DateDec, Occupier, Address) AS SELECT Con_Area.Name, Con_Area.DateDec, Property.Name, Property.Address FROM Property, Con_Area WHERE Property.ConArea# = Con_Area.ConArea#;
DROP VIEW
DROP VIEW DROP VIEW ConProp;
CREATE INDEX
CREATE INDEX UNIQUE UprnIndex ON Property (Uprn# ASC);
DROP INDEX
DROP INDEX DROP INDEX UprnIndex;
UPDATE
UPDATE Property SET Name = Heywood Value = 50000 WHERE Uprn# = 3;
DELETE FROM
DELETE FROM Property WHERE Uprn# = 1;
SELECT
Selects all records in the Property table: SELECT * FROM Property; Selects all records in the Con_Area table: SELECT * FROM Con_Area;
SELECT
Selects all properties valued at more than 40000: SELECT * FROM Property WHERE Value > 40000;
SELECT
Selects the names of all properties valued more than the Heywoods property: SELECT Name FROM Property WHERE Value > (SELECT Value FROM Property WHERE Name = Heywood);
SELECT
Selects the id of all properties in the St. George conservation area that are valued less than 30000: SELECT Uprn# FROM Property, Con_Area WHERE Con_Area.Name = St. George AND Con_Area.ConArea# = Property.ConArea# AND Value < 30000;
SELECT
Using other keywords like:
GRANT
Grant the conservation officer the right to select, update, and alter the ConProp view: GRANT Select, Update, Alter ON ConProp TO ConOfficer;
REVOKE
Revoke the conservation officer the right to alter the ConProp view: REVOKE Alter ON ConProp FROM ConOfficer;
Logical Design
Entity-Attribute-Relationship (EAR)
EAR is used as a preliminary, broad brush technique, to develop an initial data model.
Normalization
Normalization can then be used to fine-tune the preliminary model into a conceptual data-model that is appropriate for use with the target relational database management system.
EAR Modeling
1. Identify entities
- nouns
4. Defining tables
Identifying Entities
Entities are objects or things, i.e.
anything that can be identified as having an independent existence and about which we needs to collect information.
Examples:
Student Course Subject
Identifying Relationships
One to One:
1 Husband is married to 1 Wife
One to Many:
1 Mother is parent of 0..m Children
Many to Many:
1 Student takes 1..m Courses 1 Course is taken by 1..m Students
Identifying Attributes
Student entity attributes:
Defining Tables
STUDENT (Student#, Name, ...) COURSE (Course#, Title, Credits, ...) STUDENT-COURSE (Student#, Course#)
We introduce this artificial link table to simplify a many-to-many relationship into two one-to-many relationships.
Normalization
1. 2. 3. 4. 5. 6.
List all attributes Identify initial tables Apply 1st Normalization Apply 2nd Normalization Apply 3rd Normalization Check Relationships (in case any broke)
Example:
FACTORY (FactId, Name, Address, DateEst, Area, AreaOfficer, (ProdCode, ProdDesc, Brand), )
Apply
st 1
Normalization
A table is in 2nd normal form if it is in 1st normal form and all its non-key attributes are dependent upon the FULL compound primary key.
Normalization Summary
ONE FACT IN ONE PLACE
(avoid unnecessary duplications)
Physical Design
What are the most frequent queries
in the system?
What is the expected response time? How big will the database be? Whats the network bandwidth?
Indexes
Indexes are applied on frequently used attributes to speed up access to the whole data in a record. An index creates a separate two-column table twowith attributes values sorted asc/desc and the primary key of their records. Subsequent access based on this attribute uses binary search to find the value and immediately follow the primary key into the main table.
Table Splitting
RDBMS process narrow tables more efficiently than wide tables.
consider splitting the table into two tables, separating the frequently used attributes from the rarely used ones. establish a one-to-one relationship between the two new tables.
Table Recombining
(De(De-normalization)
Recombining is de-normalization and may debegin to experience the update, insert and deletion anomalies which are designed out of databases in 3NF.
Query Optimization
Frequently used queries should be
optimized for an optimal response time.
In a WHERE clause, the order of AND-ed ANDconditions can greatly influence the performance of the query:
Selecting a small subset and then joining it with another medium/large subset is much faster than the other way round.
SQL-3 (SQL-99): Most significant revision for GIS was SQL- (SQL-
published in 1999. It accommodates ideas drawn from the Object Oriented database approach to provide a basis for an object-relational approach classes, objects, objectclasses, objects, complex data-types, inheritance, etc. data-types, inheritance,
SQLSQL-3 MM (Multi-Media) part, provides support for (Multimanipulating spatial data.
Spatial Capability
Oracle Spatial is built on SQL-3 MM SQL Network Data Model Topology Data Model Spatial Analytic Functions Geocoder (Universal coordinate system)
3rd party data for functions like international address standardization and point of interest matching. matching.
Ali Adams
Higher Colleges of Technology www.geocities.com/aliadams [email protected]