Download presentation
Presentation is loading. Please wait.
1
The Database Approach u Emphasizes the integration of data across the organization
2
Components of Relational Model u Data structure: Represented in the form of tables with rows and columns u Data manipulation: Powerful operations (SQL) used to manipulate data stored in relations u Data integrity: Facilities are included to specify business rules that maintain the integrity of data when they are manipulated.
3
Relation u A named two-dimensional table of data. Each relation consists of a finite set of named columns and an arbitrary number of unnamed rows. Notation: RELATION NAME(Attribute1, Attribute2…) Example: EMPLOYEE(EmpID, Name, Dept, Salary)
4
Properties of Relations u Each relation (or table) has a unique name u Entries in columns are atomic (no repeating groups - single valued) u Entries in columns are from the same domain u Each row is unique (no duplicate rows) u The sequence of columns (left to right) is insignificant u The sequence of rows (top to bottom) is insignificant
5
Relational Keys u Allow storage and retrieval of a row of data based on stored values of that data u Primary Key: An attribute (or combination of attributes) that uniquely identify each row in a relation u Composite Key: A primary key that consists of more than one attribute
6
Foreign Key u An attribute in one table that is a primary key in another table. Purchase Order PO Date Vendor #Item # NameAddressBalance Vendor NameQOH Reord- Pt. Item PO # Vendor # Item # Foreign Keys
7
Integrity Constraints u Facilitate maintaining accurate data –Domain Constraints: the set of values that may be assigned to an attribute must be from the same domain »Domain name, meaning, data type, size/length, allowable values or ranges –Operational Constraints
8
Integrity Constraints –Entity Integrity: Every relation must have a primary key and the data values of that key are valid. »The primary key can never be null –Referential Integrity: Either each foreign key value must match a primary key value in the other relation or the foreign key value must be null
9
Referential Integrity Constraints Customer-ID Customer-Name Customer-Address Order-ID Order-Date Customer-ID Order-ID Product-ID Quantity Product-ID Product-Description Product-Finish Unit-Price On-Hand CUSTOMER ORDER ORDER LINE PRODUCT
10
Well Structured Relations u Minimum Redundancy u Users can insert, modify and delete row (instances) without errors or inconsistencies (Anomalies). –Anomalies: errors that may result when a user attempts to update a table that contains redundant data.
11
Anomalies u Insertion Anomaly u Deletion Anomaly u Modification or Update Anomaly
12
Sample Relation u Std_IDCrse_IDAddressCourse Grade 100 111First St.Psych B 200 111Second St.Psych A 300 222Third St.History C 400 333Fourth St.Physics A 500 222Fifth St.History B 100 333First St.Physics C 200 222Second St.History A
13
Insertion Anomaly Consider the relation on previous slide ENROLL(Std_ID, Crse_ID, Address, Grade) To add a new student you must supply both Std_ID and Crse_ID. This is an anomaly because the user should be able to insert a new student without supplying course data
14
Delete and Modification Anomalies u Deletion: If a particular student is deleted additional information about the courses taken are also lost u Modification: If the student’s address changes, the information must be entered in numerous rows
15
Another example of Anomalies Consider the relation SALES(Cust_ID,Name,Salesperson, Region) u Insertion: a new salesperson assigned to the north region cannot be entered until a customer is assigned u Deletion: if a customer is deleted so is info telling what region a salesperson is assigned u Modification: if a salesperson is reassigned to another region several rows need to be updated
16
What is the solution for these anomalies? Normalization Create Normalized Relations OR Create Well-Structured Relations
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.