Page 239 - PYTHON-12
P. 239

12.4 RELATIONAL DATABASE


              A  relational  database is  a type of database  that stores and
              provides access to data points that are related to one another.
              Relational  databases  are based on the  relational  model, an
              intuitive, straightforward way of representing data in tables. In
              a relational database, each row in the table is a record with a
              unique ID called the key. The columns of the table hold attributes
              of the data and each record usually has a value for each attribute,
              making it easy to establish the relationships among data points.
                                                                                Fig. 12.10: Tuples and Attributes
              Often, data in a relational database is organized into tables.
              Basic Terminologies related to a Relational Database

              1.  Entity: An entity is something that exists and about which we can store some information. It is
                 an object which can be distinctly identified. For example, student entity, employee entity, item
                 entity, etc. Entity becomes the name of the table.
              2.  Attribute: In a relational table, an attribute is a set of values of a particular type. The term attribute
                 is also used to represent a column. A table consists of several records (row); each record can be
                 broken into several smaller entities known as fields or attributes or columns. A set of attributes
                 defines the characteristics or properties of an entity. In the given table, Student relation (Fig.
                 12.11) consists of four fields or attributes—Roll number, Name, Address and Gender.
              3.  Tuple: Each row in a table is known as tuple. It is also called a row/record. A single entry in a
                 table is called a record or row. A record in a table represents a set of related data. For example,
                 the Student table given below has 10 records.

              4.  Cardinality  of  Relation:  It  is  the  number  of  records  or  tuples  in  the  relation.  Thus,  the
                 cardinality of Student relation is 10.

              5.  Degree of Relation: Number of columns or attributes is known as degree of a relation. Thus,
                 the degree of Student relation is 4.
              6.  Domain of Relation: It defines the kind of data represented by the attribute. It is the set of all
                 possible values that an attribute may contain. For example, in the given table Student, domain
                 for the field Gender is two since it can have either ‘M’ or ‘F’ as the possible and available values
                 that it may contain.
              7.  Body of the Relation: It consists of an unordered set of 0 or more tuples.








                                                                                                                  Relational Database and SQL












                                          Fig. 12.11: Relational Model (Student Relation)
                                                                                                            12.9
   234   235   236   237   238   239   240   241   242   243   244