Docsity

Logical Database Design: ERD to Relations & Data Integrity in MS Access - Prof. Aban, Study notes of Information and Communications Technology (ICT)

Toggle sidebar
bg1
LESSON 1
Logical Database Design
Logical Database Design
- a process of transforming the
conceptual data model (E-R model) into
a logical data model that emphasizes
the relational data model
- logical view of the relational database is
facilitated by the creation of data
relationships based on the logical
design as a table
E.F. Codd
- first introduced relational data model
- followed by IBM
Relational Data Model
- based on mathematical theory and
therefore has a solid theoretical
foundation
Data Structure
- data are organized in form of tables with
rows and columns
Data Manipulation
- powerful operations are used to
manipulate data stored in the relations
Data Integrity
- data validation ensured that the data will
be used is valid and determines the
quality of the generated information
Relational Data Structure
Relation
- named a two-dimensional table of data
- each relation consists of a set of named
columns and an arbitrary number of
unnamed rows
each row of a relation contains data
values for a single entity
structure of a relationship can be
expressed by a shorthand notation in
this format:
TABLE_NAME (columnname_1,
columnname_2...., columnname_n)
Relational Keys
Primary Key
- consists of 1 or more columns whose
data contained within are used to
uniquely identify each row in the table
- designated by underlining the column(s)
- equivalent to the identifier in the ERD
- selection is critical as it must be ensured
that the selected key is unique
- designated to uniquely identifies each
record in the table
can either be a normal column that is
guaranteed to be unique such as
EmpNo
can be generated by the DBMS (unique
identifier or GUID in Microsoft SQL
Server)
Foreign Key
- a set of one or more columns in a table
that refers to the primary key in another
table
- designated by underlining the column
name with a dashed line ---
- used to create relationships and provide
a link between tables
Composite Key
- a primary key that consists of more than
one column
- can be used to uniquely identify each
row in the table
pf3
pf4
pf5

Partial preview of the text

Download Logical Database Design: ERD to Relations & Data Integrity in MS Access - Prof. Aban and more Study notes Information and Communications Technology (ICT) in PDF only on Docsity!

LESSON 1

Logical Database Design Logical Database Design

  • a process of transforming the conceptual data model (E-R model) into a logical data model that emphasizes the relational data model
  • logical view of the relational database is facilitated by the creation of data relationships based on the logical design as a table E.F. Codd
  • first introduced relational data model
  • followed by IBM Relational Data Model
  • based on mathematical theory and therefore has a solid theoretical foundation Data Structure
  • data are organized in form of tables with rows and columns Data Manipulation
  • powerful operations are used to manipulate data stored in the relations Data Integrity
  • data validation ensured that the data will be used is valid and determines the quality of the generated information Relational Data Structure Relation
  • named a two-dimensional table of data
  • each relation consists of a set of named columns and an arbitrary number of unnamed rows  each row of a relation contains data values for a single entity  structure of a relationship can be expressed by a shorthand notation in this format: TABLE_NAME (columnname_1, columnname_2...., columnname_n) Relational Keys Primary Key
  • consists of 1 or more columns whose data contained within are used to uniquely identify each row in the table
  • designated by underlining the column(s)
  • equivalent to the identifier in the ERD
  • selection is critical as it must be ensured that the selected key is unique
  • designated to uniquely identifies each record in the table  can either be a normal column that is guaranteed to be unique such as EmpNo  can be generated by the DBMS (unique identifier or GUID in Microsoft SQL Server) Foreign Key
  • a set of one or more columns in a table that refers to the primary key in another table
  • designated by underlining the column name with a dashed line ---
  • used to create relationships and provide a link between tables Composite Key
  • a primary key that consists of more than one column
  • can be used to uniquely identify each row in the table

LESSON 2

Integrity Constraints Integrity Constraints in DBMS

  • a set of rules that are applied on the table columns or relationships
  • to ensure that the overall accuracy, validity, integrity, and consistency (i.e. the quality) of the data present in the database table is maintained  every time a table is inserted, updated, deleted, or altered operation is performed, it is evaluated against the terms or rules mentioned in the integrity constraint Types of Integrity Constraints Domain Constraints Domain
  • set of values that should be associated with the column  need to be specific on what data values are and which format is suitable for a column Entity Integrity
  • all primary key values are unique, and no part of the primary key may be null
  • each row will have a unique identity, and the foreign key values can properly reference primary key values Referential Integrity
  • requires that a foreign key must have a matching primary key or it must be null
  • specified between two tables (parent and child)
  • maintains the correspondence between the rows in the tables
  • reference from a row in one table to another table must be valid Referential Integrity Rules
  1. A foreign key of the related table can’t enter a value that doesn't exist in the primary key of the primary table.
  2. A record cannot be deleted from a primary table if matching records exist in a related table.
  3. A primary key in the primary table cannot change the value if that record has related records.

the identifying owner + the partial identifier of the weak entity type Step 3: Map Binary Relationship

  • procedure depends on both the degree of relationships + the cardinalities of the relationships
  • binary relationships are those, which are established two entity types Binary One-to-Many Relationships (1:M)
  • create a relation for each of the two entity types participating in the relationship
  • use the procedure described in Step 1
  • incorporate the primary key column (or columns) of the entity on the one side of the relationship as a foreign key in the relationship that is on the many-side of the relationship Binary Many-to-Many Relationships (M:N)
  • viewed as a special case of a one-to- many relationship
  • requires two steps: first create a relation for each of the two entity types participating in the relationship
  • create a third relation
  • include as foreign key columns in the third relation the primary keys of the two participating relations (will also be considered its composite key columns)
  • all columns connected with the M:N relationship is considered columns of the third relation Binary One-to-One Relationships (1:1)
  • two relations are created
  • the primary key of one of the relations is included as a foreign key in the other relation

 In a 1:1 relationship, the association in one direction is nearly always optional, while the association in the other direction is a mandatory one

  • rule = include a foreign key on the optional side of the relationship the primary key of the mandatory participation in the 1:1 relationship
  • avoid the need for null values in the foreign key column
  • any columns associated with the relationship itself have also included the foreign key in the same relation Step 4: Map Associative Entities
  • many-to-many relationships may be chosen to be modeled as associative entities in the E-R diagram
  • same procedure in mapping an M:N relationship
  • create two relations one for each of the two participating entity types
  • create a third relation for the associative entity
  • second step depends on whether or not an identifier is assigned to the associative entity on the E-R diagram Identifier Not Assigned
  • steps are same as the steps followed in binary M:N relationship
  • default primary key for the associative relation consists of the two primary key columns from the other two relations
  • columns are the foreign keys that reference from the other two relations Identifier Assigned
  • if surrogate identifier is assigned to the associative entity type, still an associative relation is created
  • the primary key for this relation is the surrogate identifier and the primary keys of the two participating entity types are then included as its foreign keys  Reasons that may motivate this approach:
  1. The associative entity type has a single- column identifier that is familiar to end- users.
  2. The default identifier (consisting of the identifiers for each of the participating entity types) may uniquely identify instances of the associative entity.

Step 7: Map Supertype/Subtype Relationships Strategies to represent these in the relational model:

  1. Create a separate relation for the supertype and each of the subtypes.
  2. Assign to the relation to the columns that are common to all members of the supertype, including the primary key
  3. Assign to the relation for each subtype the primary key of the supertype, only those columns that are unique to that subtype.
  4. Supertype columns include the identifier and subtype discriminator go to in the supertype relation.