Topics for this week:
1. Good Design
2. Functional Dependencies 3. Normalization
Readings for this week:
1. E&N, Ch. 10.1-10.6; 12.2 2. Quickstart, Ch. 3
3. Complete the tutorial at http://sqlcourse2.com/
In-class Activity:
1. Review components of DBMS, with an eye to viewing the whole process as systematic activities:
conceptual, logical, and physical design.
2. Demonstrate by creating a small conceptual and logical model then translating this into part of the physical model - creating the database and tables using MySQL’s terminal window. is demonstrates, too, the DDL.
3. Demonstrate a few commands issued against the data (DML).
4. Review some of your ER questions.
Bridge from Entity Relationship modeling to creating SQL databases, tables, & relations No doubt, you’ve learned already some of the concepts & terminology of relational database modeling.
To get up to speed with what you’ve covered, here are some quick notes that may help us harmonize our perspectives.
Components of a DBMS:
Many roles and activities are involved; not all of which you may have encountered. Here’s a view of the components of a DBMS. Notice the different contributions of programmers, users, and the DBA - the database administrator. Note, too, the functions that constitute a DBMS (and where the DDL and DML fit in). Ultimately the commands and functions must be communicated to the computer system itself - via the file manager, various other access methods and buffers before reaching the actual data
stored in the relationship databases and tables.
Query Processor: transforms queries into a series of low-level instructions directed to the database manager.
Database Manager (DM): Interacts with the user- submitted application programs and queries. e DM accepts queries and examines the external and conceptual schema to determine what conceptual records are required to satisfy the request. e DN places a call to the File Manger to perform the request.
File Manager: manipulates the underlying storage files and manages the allocation of storage space on the disk. Actual physical manipulation of the data is passed to the appropriate access method.
DML preprocessor: converts DML statements
embedded in an application program into a
LIS458 - Database Management - Week 11 (4/6/09)
2 standard function call in the host language (e.g., MySQL).
DDL compiler: compiler converts DDL statements into a set of tables containing meta-data. ese tables are then stored in the catalog while control info is stored in the data files headers.
Catalog manager: [not the library kind!] - manages access to and maintains the system catalogue; the system catalog is accessed by most of the DBMS components.
ere are other important functions in SQL soware Terms:
Relation: a relation is a table with columns & rows Attribute: an attribute is a named column of a relation
Domain is the set of allowable values for one or more attributes.
e idea of domain is important because it allows the user to define in a central place the meaning and source of values that attributes can hold. [is leads to the data dictionary; example below.]
Tuple: a tuple is a row of a relation.
Degree: the degree of a relation is the number of attributes it contains.
Cardinality: the cardinality of a relation is the number of tuples (rows) it contains. As rows are added or deleted, cardinality changes.
Relational database is a collection or normalized relations.
Example of domains for some branches and staff relations:
Attribute Bno Street Area
Domain Name BRANCH_NO STREET_NAME AREA_NAME
Meaning
The set of all possible branch numbers
Set of all streets in Boston Set of all local area names
Domain definition
characters: size 3, range B1- B99
character: size 25 character: size 2
LIS458 - Database Management - Week 11 (4/6/09)
3
Alternative Names:
Relation Table File
Tuple Row Record
Attribute Column Field
Now consider the various mathematical combinations from your other readings. ese become important when we consider joins, unions, and other kinds of set operations.
Entity-Relationship Modeling
ree main items: entity types, relationship types, and attributes.
Entity type: an object or concept that is identified by the organization as having an independent existence.
Entity: an instance of an entity type that is uniquely identifiable.
Weak entity type: an entity type that is existence-dependent on some other entity type.
Strong entity type: an entity type that is not existence-dependent on some other entity type.
Example: e Staff and Branch items above are strong entities; if there were data about a staff member’s next-of-kin, that entity is weak: it exists only if a staff member has a next-of-kin.
Attributes are a property of an entity or a relationship type. e Attribute domain is a set of values that may be assigned to that attribute. E.g., Staff->Lname should include only the last names of employees.
Some attributes are simple, others composite. A single attribute is composed of a single component with an independent existence. E.g., cannot be further subdivided (e.g., sex, salary; aka “atomic attributes”).
Composite attributes consist of multiple components; e.g., e “Address attribute” could be divided into multiple attributes each with their own existence (e.g., street, city, state, zip).
Derived attributes are values that are derived from the value of a related attribute or set of attributes, not necessarily in the same entity. For example, paycheck could be derived from hourly_wage *
hours_worked.
Keys
Candidate keys are attributes or sets of attributes that uniquely identify individual occurrences of an entity type. For example, branch number (Bno) is a candidate key for the Branch entity type and has a distinct value for each branch entity. Must be unique for each occurrence (like unique IDs). Primary key is that candidate key selected because of its current and future uniqueness. Composite key is a key
consisting of two or more attributes.
Diagrammatic Representations
Here’s an example of Staff, Branch, and Next_of_Kin entities and attributes represented graphically followed by the composition of keys:
Staff entity composition:
Staff (Staff_No, FName, LName, Address, Tel_No, Sex, DOB, Position, Salary) Primary Key Staff_no
Alternate Key FName, LName, DOB
Composite Attribute Name (FName, LName) Derived Attribute Total_Staff
City Zip and so on...
CITY_NAMES ZIP_CODE
Names of all towns in Boston
Set of zips in Boston
character: size 20 character: size 12