logical design/ relational schema

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/16

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

17 Terms

1
New cards

relational model

  • structure

    • Tables

    • Keys

      • Primary or foreign

  • uses SQL for retrieving and modifying data

  • A way to implement business rules

    • which maintain the integrity of manipulated data

    • keeps data accurate and consistent from the point of creation to processing

2
New cards

relation

  • A 2 dimensional table of data

  • entity

  • Unique Name

  • Rows

    • Unique Records

      • Two rows cannot have the same information across all attributes

    • Order does not matter

  • Columns

    • Attributes or fields or alias

    • Need to have unique names

    • Atomic

      • Not multivalued or composite

    • Order does not matter

<ul><li><p>A 2 dimensional table of data</p></li><li><p><strong>entity</strong></p></li><li><p>Unique Name</p></li><li><p><strong>Rows</strong></p><ul><li><p><strong>Unique Records</strong></p><ul><li><p>Two rows cannot have the same information across all attributes</p></li></ul></li><li><p>Order does not matter</p></li></ul></li><li><p><strong>Columns</strong></p><ul><li><p><strong>Attributes or fields </strong>or alias</p></li><li><p>Need to have unique names</p></li><li><p><strong>Atomic</strong></p><ul><li><p><strong>Not multivalued or composite</strong></p></li></ul></li><li><p>Order does not matter</p></li></ul></li></ul><p></p>
3
New cards

logical design

  • database design that maps conceptual requirements

4
New cards

keys

  • Have different purposes

  • Primary

    • Unique identifiers

    • Guarantees that each row will be unique

    • Cannot be duplicated or empty

    • Can be simple or composite

      • One attribute or more than one attribute (for associate entities)

  • Foreign

    • Allows a dependent relationship to occur

    • An entity on the many side of a relationship is able to refer to its parent which is on the one side

  • Used as indexes to speed up the response to queries

    • For example

      • Yellow Pages

      • If you have the address then you can connect it to a name or an e-mail for example

5
New cards

constraints

  • Domain constraints

    • The allowable values for an attribute

    • Minimum and maximum values allowed

    • consists of:

      • size

      • domain name

      • data type

  • Entity integrity rule/constraints

    • Primary keys cannot be empty and they need to be unique

  • referential integrity constraints

    • Maintains consistency between the rows of two related tables

    • If you have a value for a foreign key, then the instance that it points to needs to exist

    • fk needs to match the corresponding pk

    • To ensure

      • Restrict

        • Don't delete the parent side

      • Cascade

        • Automatically delete the dependent site if the parents side is deleted

        • This is how you protect weak entities

      • Set to null

        • If you delete from the parents side then make sure that the foreign key on the dependent side is null

<ul><li><p><strong>Domain constraints</strong></p><ul><li><p>The allowable values for an attribute</p></li><li><p><strong>Minimum and maximum</strong> values allowed</p></li><li><p>consists of:</p><ul><li><p>size</p></li><li><p>domain name</p></li><li><p>data type</p></li></ul></li></ul></li><li><p><strong>Entity integrity rule/constraints</strong></p><ul><li><p><strong>Primary keys cannot be empty and they need to be unique</strong></p></li></ul></li><li><p><strong>referential integrity constraints</strong></p><ul><li><p>Maintains consistency between the rows of two related tables</p></li><li><p><strong>If you have a value for a foreign key, then the instance that it points to needs to exist</strong></p></li><li><p><strong>fk needs to match the corresponding pk</strong></p></li><li><p>To ensure</p><ul><li><p>Restrict</p><ul><li><p>Don't delete the parent side</p></li></ul></li><li><p>Cascade</p><ul><li><p>Automatically delete the dependent site if the parents side is deleted</p></li><li><p>This is how you protect weak entities</p></li></ul></li><li><p>Set to null</p><ul><li><p>If you delete from the parents side then make sure that the foreign key on the dependent side is null</p></li></ul></li></ul></li></ul></li></ul><p></p>
6
New cards
<p>how to transfer ERD into relational </p>

how to transfer ERD into relational

  • Simple attributes

    • can be mapped directly onto the relational database

  • Composite attributes

    • can only use their simple component attributes when mapped onto the relational database

  • Multivalued attributes need their own new entity

<ul><li><p><strong>Simple attributes </strong></p><ul><li><p>can be<strong> mapped directly onto the relational database</strong></p></li></ul></li><li><p><strong>Composite attributes </strong></p><ul><li><p>can <strong>only use their simple component attributes when mapped onto the relational database</strong></p></li></ul></li><li><p><strong>Multivalued attributes need their own new entity</strong></p></li></ul><p></p>
7
New cards
<p>mapping binary relationships</p>

mapping binary relationships

  • Where do the primary and foreign keys go?

  • to connect entities

    • You need to create a foreign key attribute based on the other entities primary key

  • One to many

    • One side = primary

    • Many side = foreign

  • one to one

    • It can go on either side unless if you are dealing with an optional mandatory relationship

      • Mandatory = primary

      • Optional = foreign

  • Many to many

    • You need to create a new entity (associative) with the primary keys of those two entities as its primary key

      • You need to add the relationships attribute to this new entity

    • If an identifier is assigned, use that as the primary key

      • The primary keys of the parent entities will become partial identifiers

      • Should be natural and familiar

      • The default identifier may not always be unique

<ul><li><p>Where do the primary and foreign keys go?</p></li><li><p>to connect entities</p><ul><li><p>You need to create a foreign key attribute based on the other entities primary key</p></li></ul></li><li><p><strong>One to many</strong></p><ul><li><p><strong>One side = primary</strong></p></li><li><p><strong>Many side = foreign</strong></p></li></ul></li><li><p><strong>one to one</strong></p><ul><li><p>It can go on <strong>either side</strong> <strong>unless </strong>if you are dealing with an optional mandatory relationship</p><ul><li><p><strong>Mandatory = primary</strong></p></li><li><p><strong>Optional = foreign</strong></p></li></ul></li></ul></li><li><p><strong>Many to many</strong></p><ul><li><p>You need to <strong>create a new entity (associative</strong>) with the <strong>primary keys of those two entities as its primary key</strong></p><ul><li><p>You need to <strong>add the relationships attribute to this new entity</strong></p></li></ul></li><li><p><strong>If an identifier is assigned, use that as the primary key</strong></p><ul><li><p>The <strong>primary keys of the parent entities will become partial identifier</strong>s</p></li><li><p>Should be natural and familiar</p></li><li><p>The default identifier may not always be unique</p></li></ul></li></ul></li><li><p></p></li></ul><p></p>
8
New cards

mapping unary relationships

  • One to many

    • A recursive foreign key in the same relation

  • Many to many

    • You will need 2 entities

      • One for the entity type

      • One for the associative entity

        • The primary key will be the primary key of the entity type as well as the associative entity

<ul><li><p><strong>One to many</strong></p><ul><li><p>A <strong>recursive foreign key in the same relation</strong></p></li></ul></li><li><p><strong>Many to many</strong></p><ul><li><p><strong>You will need 2 entities</strong></p><ul><li><p><strong>One for the entity type</strong></p></li><li><p><strong>One for the associative entity</strong></p><ul><li><p><strong>The primary key will be the primary key of the entity type as well as the associative entity</strong></p></li></ul></li></ul></li></ul></li></ul><p></p>
9
New cards

mapping weak entities

  • primary key has 2 parts:

    • Partial identifier + the primary key of the strong entity

<ul><li><p>primary key has <strong>2 parts:</strong></p><ul><li><p><strong>Partial identifier + the primary key of the strong entity</strong></p></li></ul></li><li><p></p></li></ul><p></p>
10
New cards

mapping ternary and n-ary relationships

  • The associative entity will have the primary key ef each entity in the relationship

<ul><li><p>The <strong>associative entity will have the primary key ef each entity in the relationship</strong></p></li></ul><p></p>
11
New cards
<p>mapping specialization relationships </p>

mapping specialization relationships

  • One to one relationship

    • Subtype will have the optional side and the foreign key

  • The foreign key will be the first letter of the subtype entity along with the full name of the primary key of the Super type

<ul><li><p>One to one relationship</p><ul><li><p><strong>Subtype will have the optional side and the foreign key</strong></p></li></ul></li><li><p>The <strong>foreign key will be the first letter of the subtype </strong>entity<strong> along with the full name of the primary key of the Super type</strong></p></li></ul><p></p>
12
New cards

functional dependency

  • The value of an attribute determines the value of another attribute

  • a constraint between 2 attributes

  • partial functional

    • non key attributes are functionally dependent on only part of the key

13
New cards

candidate key

  • candidate for the unique identifier

    • One of them is chosen to be the primary key

  • does not indicate a row’s position in the table

  • Every attribute that's not a key is functionally dependent on every candidate key

14
New cards

data normalization

  • A way to improve the logical design so that there's no unnecessary duplication of data

  • easier to maintain data

  • Decomposing entities with anomalies to produce smaller, well structured, entities

    • Minimal data redundancy

    • Users can insert, delete, update rows without causing any inconsistencies

  • Types of anomalies

    • Insertion anomaly

      • When a user adds new rows, they create duplicate data

    • Deletion anomaly

      • Deleting rows with data that will be needed for other future rows

    • Modification anomaly

      • Changing/editing data in one row forces the changing of data and other rows because of duplication

  • Removing redundancy without losing relationships

  • end goal: A table should not pertain to more than one entity type

  • Steps

    1. Remove multivalued attributes

      1. 1NF

      2. Every attribute will have its own line

    2. Remove partial dependencies

      1. 2NF

      2. AKA removing many to many relationships

      3. Many to many relationships makes the non key attribute defined by only part of the key

    3. Remove transitive dependencies

      1. 3NF

      2. AKA removing any one to many relationships

      3. to remove functional dependencies between 2 + non-key attributes

    4. Remove remaining anomalies due to there being multiple candidate keys

      1. Boyce-Codd normal form

    5. Remove multivalued dependencies

      1. 4NF

    6. Remove remaining anomalies

      1. 5NF

15
New cards

enterprise keys

  • If you have lots of entities, you want to create an object table that will provide a primary key for all of the entities

<ul><li><p>If you have lots of entities, you want to create an <strong>object table that will provide a primary key for all of the entities</strong></p></li></ul><p></p>
16
New cards

when to use sample data to create an instance

  • to improve user comms.

  • to check accuracy of design

  • for prototype generation

17
New cards

determinant

  • in a functional dependency, attribute on the left is the determinant

  • determines the value of of the attribute on the other side of the functional dependency