ch03(1).pdf - Chapter 3 The Relational Data Model Chapter 3...

  • No School
  • AA 1
  • 36

This preview shows page 1 - 6 out of 36 pages.

Chapter 3 The Relational Data Model
Image of page 1

Subscribe to view the full document.

Chapter 3. The Relational Data Model Tables Relational database is a collection of tables. table = relation = record type (file) row = tuple = record column = attribute = field (property) table: two-dimensional arrange of data Heading: table name and column names Body: rows, actual data Student StdNo StdFirstName StdLastName StdCity StdState StdZip StdMajor StdClass StdGPA 123-45-6789 HOMER WELLS SEATTLE WA 98121-1111 IS FR 3.00 124-56-7890 BOB NORBERT BOTHELL WA 98011-2121 FIN JR 2.70 234-56-7890 CANDY KENDALL TACOMA WA 99042-3321 ACCT JR 3.50 MIS 6320: Database Foundations 1
Image of page 2
Chapter 3. The Relational Data Model Student Table Example SQL Command to Create the Student Table CREATETABLEStudent (StdNo CHAR(11), StdLastName VARCHAR(50) NOTNULL, StdFirstName VARCHAR(50) NOTNULL, StdCity VARCHAR(50) NOTNULL, StdState VARCHAR(2) NOTNULL, StdZip VARCHAR(10) NOTNULL, StdMajor CHAR(6) NULL, StdClass CHAR(2) NULL, StdGPA DECIMAL(3,2) NULL, CONSTRAINTStudentPkPRIMARYKEY(StdNo)) MIS 6320: Database Foundations 2
Image of page 3

Subscribe to view the full document.

Chapter 3. The Relational Data Model Data Types Numeric Data DECIMAL(n,m) , NUMERIC(n,m) : n is the total number of digits; m the number of digits below the decimal point. NUMBER(n,m) : for Oracle Database only. INTEGER , SMALLINT : 32 and 16 bits, respectively REAL , DOUBLEPRECISION : normally 16 and 32 bits, respectively; normally 7 and 15 digit precision, respectively FLOAT(n) : 32 bits, n -digit precision Text Data Each column of a table is associated with a data type, which defines a set of permissible data values for the column. CHAR(n) : n characters VARCHAR(n) : n characters, occupying up to n character spaces ( VARCHAR2(n) for Oracle Database) Depending on specific DBMS software, DATE , TIME , DATETIME , BOOLEAN , BIT , MONEY and other data types are available. MIS 6320: Database Foundations 3
Image of page 4
Chapter 3. The Relational Data Model Keys Superkey: attribute(s) with unique values a unique identifier of a record (i.e., tuple) in a table Candidate key: minimal superkey A key is composite if it consists of two or more attributes, such as (BldgID, RoomNo) and (DrLcNo, DrLcState). A key is simple if it is a single-attribute key. a unique and minimal identifier of a record (i.e., tuple) in a table uniqueness : No two rows of a table have a same candidate key value. minimality (i.e., irreducibility ): If a candidate key is composite, then no subset of the composite candidate key is a unique identifier. (I.e. no component of the composite candidate key can be eliminated without destroying the uniqueness property.) Every table must have at least one candidate key. Primary key: a designated candidate key; cannot contain null values Null: a special value meaning “unknown” or “inapplicable” (e.g., Apt No.) Since a primary key is a candidate key, it must be unique and minimal.
Image of page 5

Subscribe to view the full document.

Image of page 6
  • Fall '19
  • Relational model, Candidate key

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes