chapter 3rd

Upload: ahmad-naeem

Post on 08-Apr-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/6/2019 Chapter 3rd

    1/20

    Naeem Aslam 1

    Chapter No.3

    The Relation Model

  • 8/6/2019 Chapter 3rd

    2/20

    Naeem Aslam 2

    Relational TerminologyRelation:

    A relation is a table with columns androws.

    An RDBMS requires only that the database beperceived by the user as tables. This perceptionapplies only to the logical structure of thedatabase (Conceptual and External level). Itdoes not apply to the physical structure of thedatabase.

  • 8/6/2019 Chapter 3rd

    3/20

    Naeem Aslam 3

    Relational Terminology-IAttribute:An attribute is a named column of a relation.In the relational model, relations are used to hold

    information about the object. A relation is represented astwo dimensional table in which the rows of the tablecorrespond to the individual records and table columnscorrespond to the attributes.

    Attributes can appear in any order and the relation will stillbe the same relation and therefore convey the samemeaning.

  • 8/6/2019 Chapter 3rd

    4/20

    Naeem Aslam 4

    Relational Terminology-II

    D omain:A domain is the set of allowable valuesfor one or more attributes.Attribute: branchNoD omain Name: Branch NumbersMeaning: The set of all possible branchnumbersD omain D efinition: character: Size 4, rangeB001-B999

  • 8/6/2019 Chapter 3rd

    5/20

    Naeem Aslam 5

    Relational Terminology-III

    T uple:A tuple is a row of a relation.

    Tuples can appear in any order and relationwill still be the same relation and thereforeconvey the same meaning.

    The tuples are called the extension or stateof a relation, which changes over time.

  • 8/6/2019 Chapter 3rd

    6/20

    Naeem Aslam 6

    Relational Terminology-IVD egree: T he degree of a relation is the number of attributes it contains.

    A relation with only one attribute would havedegree one and be called a unary relation or onetuple.

    A relation with two attributes would have degreetwo and be called a binary relation.The degree of a relation is a property of theintension of the relation.

  • 8/6/2019 Chapter 3rd

    7/20

    Naeem Aslam 7

    Relational Terminology-V

    C ardinality: T he cardinality of a relation is the number of tuples it contains.The number of tuples is called the cardinality of therelation and this changes as the tuple added or deleted.

    The cardinality is a property of extension of therelation and is determined from the particular instance of the relation at any given moment.

  • 8/6/2019 Chapter 3rd

    8/20

    Naeem Aslam 8

    Relational Terminology-VI

    Relational database:

    A relational database consists of relationsthat are appropriately structured. We refer tothis appropriateness as normalization.

  • 8/6/2019 Chapter 3rd

    9/20

    Naeem Aslam 9

    Alternative Terminology

    Alternative terminology for relational modelterms.

    Formal Terms Alternative1 Alternative2

    Relation Table FileTuple Row Record

    Attribute Column Field

  • 8/6/2019 Chapter 3rd

    10/20

    Naeem Aslam 10

    Properties of Relations

    The relation has a name that is distinct from allother relation names in the relational schemaEach cell of the relation contains exactly oneatomic or single valueEach attribute has a distinct nameThe values of an attribute are all from samedomain

    Each tuple is distinct there are no duplicate tuplesThe order of attribute has no significanceThe order of tuples has no significance

  • 8/6/2019 Chapter 3rd

    11/20

    Naeem Aslam 11

    Relational Keys

    P urpose:

    There are no duplicate tuples within arelation. Therefore we need to be able toidentify one or more attributes (calledrelational keys) that uniquely identifies eachtuple in a relation.

  • 8/6/2019 Chapter 3rd

    12/20

    Naeem Aslam 12

    Superkey

    An attribute or set of attributes that uniquely

    identifies a tuple within a relation.

  • 8/6/2019 Chapter 3rd

    13/20

    Naeem Aslam 13

    Candidate Key

    A superkey such that no proper subset is asuperkey with in the relation.

    There may be several candidate keys for arelation. When key consists of more thanone attribute we call it a composite key.

  • 8/6/2019 Chapter 3rd

    14/20

    Naeem Aslam 14

    Primary Key

    The candidate key that is selected to identifytuples uniquely within the relation.

    The candidate keys that are not selected tobe the primary key are called alternate keys.

  • 8/6/2019 Chapter 3rd

    15/20

    Naeem Aslam 15

    Foreign Key

    When an attribute appear in more than onerelation, its appearance usually represents arelationship between tuples of the tworelations.

  • 8/6/2019 Chapter 3rd

    16/20

    Naeem Aslam 16

    Relational Integrity

    A data model has two parts:Manipulative P art:

    Defining the types of operation that areallowed on the data.

    Set of Integrity Rules:Which ensure that the data is accurate.

  • 8/6/2019 Chapter 3rd

    17/20

    Naeem Aslam 17

    Relational Integrity-I

    Two important integrity rules which are constraintsor restrictions that apply to all instances of thedatabase.

    A Base Relation as a relation that corresponds toan entity in the conceptual schema.1)Entity Integrity

    In base relation no attribute of a primary key canbe null2) Referential Integrity

  • 8/6/2019 Chapter 3rd

    18/20

    Naeem Aslam 18

    Relational Integrity-II

    Enterprise Constraints:

    Additional rules specified by the users or database administrators of a database.

  • 8/6/2019 Chapter 3rd

    19/20

    Naeem Aslam 19

    View

    The dynamic result of one or more relationaloperations operating on the base relations toproduce another relation. A view is a virtualrelation that does not necessarily exist in thedatabase but can be produced upon requestby a particular user, at time of request.

  • 8/6/2019 Chapter 3rd

    20/20

    Naeem Aslam 20

    Purpose of Views

    A powerful and flexible security by hiding thepart of the database from certain users.

    It permits users to access data in a way thatis customized to their needs, so that thesame data can be seen by different users indifferent ways at the same time.It can simplify complex operations through

    joins.