Docsity

dbms conceptual modeling 2, Lecture notes of Database Management Systems (DBMS)

Partial preview of the text

Download dbms conceptual modeling 2 and more Lecture notes Database Management Systems (DBMS) in PDF only on Docsity!

Logical Design

of the

Database

THE RELATIONAL

MODEL

Requirement Gathering and Analysis Know what user want and what will be stored in the database Conceptual Design Visualize the conceptual design of the database using Entity Relationship Model Logical Design Logical Database representation using Relational Model Physical Design Physical database design using SQL and Implementation using a DBMS

Relational Model Terminology

Tables/Relations Relations are saved in the format of Tables. This format stores the relation among entities. Must have a distinct name Tuples/Rows A single row of a table, which contains a single record for that relation Attribute An attribute is a named column of a relation Must have a distinct name

Relational Model Terminology cont...

Domain

  • A domain is the set of allowable values for a attribute
  • The special value null is a member of every domain Relational Schema
  • A relation schema describes the relation name (table name), attributes, and their names.

Basic Structure

Example: ◦ name = { Jones, Smith, Paul, Lindsay , …} ◦ street = { Main, North, Park , …} ◦ city = { London, Southampton, Liverpool , …} Then Relation is = { ( Jones, Main, London ), ( Smith, North, Southampton ), ( Paul, North, Liverpool ),( Lindsay, Park, London ) } We can get this by a cartesian product of name x street x city

Properties of Attributes

Attribute values are (normally) required to be atomic ; that is, indivisible ◦ E.g. the value of an attribute can be an account number, but cannot be a set of account numbers Domain is said to be atomic if all its members are atomic NULL is used to represent the values of attributes that may be unknown or may not apply to a tuple

Properties of Relations

Each cell of the relation contains exactly one atomic (single) value The values of an attribute are all from the same domain Each tuple is distinct. There are no duplicate tuples The order of attributes has no significance The order of tuples has no significance, theoretically. (However, in practice, the order may affect the efficiency of accessing tuples.)

Order of Attributes and Tuples

Attrib1 Attrib2 Attrib X Y Z A B C Attrib2 Attrib1 Attrib Y X Z B A C Attrib3 Attrib1 Attrib Z X Y C A B Attrib1 Attrib2 Attrib A B C X Y Z Attrib2 Attrib1 Attrib B A C Y X Z Attrib3 Attrib1 Attrib C A B Z X Y

Key Constraints

  • Subsets of attributes of a relation R with the property that no two tuples in any relation state r of R should have the same combination of values for these attributes.
  • Every relation has at least one default superkey—the set of all its attributes. Superkey of R
  • It is a minimal superkey —that is, a superkey from which we cannot remove any attributes and still have the uniqueness constraint.
  • This property is not required by a superkey. Key of R

Key Constraints (continued)

Example: Consider the CAR relation schema: ◦ STUDENT(Index Number, Name, Birthday,NIC, Academic Year) ◦ STUDENT has two keys (minimal superkeys): ◦ Key1 = {Index Number} ◦ Key2 = {NIC} ◦ Both are also superkeys of STUDENT ◦ {Index Number, Birthday} is a superkey but not a key. In general: ◦ Any key is a superkey (but not vice versa) ◦ Any set of attributes that includes a key is a superkey ◦ A minimal superkey is also a key

COMPANY Database Schema

Entity Integrity

Entity Integrity: ◦ The primary key attributes PK of each relation schema R in S cannot have null values in any tuple. ◦ This is because primary key values are used to identify the individual tuples. ◦ t[PK]  null for any tuple t in r(R) ◦ If PK has several attributes, null is not allowed in any of these attributes ◦ Note: Other attributes of R may be constrained to disallow null values, even though they are not members of the primary key.

Displaying a relational database schema

and its constraints

Each relation schema can be displayed as a row of attribute names The name of the relation is written above the attribute names The primary key attribute (or attributes) will be underlined A foreign key (referential integrity) constraints is displayed as a directed arc (arrow) from the foreign key attributes to the referenced table’s Primary Key