Relational Database: Definitions Example Instance of Students Relation

Total Page:16

File Type:pdf, Size:1020Kb

Relational Database: Definitions Example Instance of Students Relation Why Study the Relational Model? The Relational Model ❖ Most widely used model. – Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. ❖ “Legacy systems” in older models – E.G., IBM’s IMS ❖ Recent competitor: object-oriented model – ObjectStore, Versant, Ontos, O2 – A synthesis emerging: object-relational model ◆ Informix Universal Server, UniSQL, Oracle, DB2 1 2 Relational Database: Definitions Example Instance of Students Relation ❖ Relational database: a set of relations sid name login age gpa ❖ Relation: made up of 2 parts: 53666 Jones jones@cs 18 3.4 – Instance : a table, with rows and columns. #Rows = cardinality, #fields = degree / arity. 53688 Smith smith@eecs 18 3.2 – Schema : specifies name of relation, plus name and 53650 Smith smith@math 19 3.8 type of each column. ◆ E.G. Students(sid: string, name: string, login: string, age: integer, gpa: real) ❖ Cardinality = 3, degree = 5, all rows distinct ❖ Can think of a relation as a set of rows or ❖ Do all columns in a relation instance have to tuples (i.e., all rows are distinct). be distinct? 3 4 Creating Relations in SQL Integrity Constraints (ICs) ❖ Creates the Students CREATE TABLE Students ❖ IC: condition that must be true for any instance relation. Observe that the (sid: CHAR(20), of the database; e.g., domain constraints. CHAR(20) type (domain) of each field name: , – ICs are specified when schema is defined. login: CHAR(10), is specified, and enforced by – ICs are checked when relations are modified. age: INTEGER, the DBMS whenever tuples gpa: REAL) ❖ A legal instance of a relation is one that satisfies are added or modified. all specified ICs. ❖ As another example, the – DBMS should not allow illegal instances. Enrolled table holds CREATE TABLE Enrolled (sid: CHAR(20), ❖ If the DBMS checks ICs, stored data is more information about courses cid: CHAR(20), faithful to real-world meaning. that students take. grade: CHAR(2)) – Avoids many data entry errors, too! 5 6 Primary Key Constraints Primary and Candidate Keys in SQL ❖ Possibly many candidate keys (specified using ❖ A set of fields is a superkey for a relation if: UNIQUE), one of which is chosen as the primary key. – No two distinct tuples have the same values in all CREATE TABLE Enrolled fields of the superkey ❖ “For a given student and course, there is a single grade.” vs. (sid CHAR(20) ❖ A superkey is a (candidate) key if : “Students can take only one cid CHAR(20), – No proper subset of it is a superkey course, and receive a single grade grade CHAR(2), PRIMARY KEY (sid,cid) ) ❖ If there’s >1 candidate key for a relation, one for that course; further, no two of the keys is chosen (by DBA) to be the students in a course receive the CREATE TABLE Enrolled same grade.” (sid CHAR(20) primary key. ❖ Used carelessly, an IC can prevent cid CHAR(20), ❖ E.g., sid is a key for Students. (What about the storage of database instances grade CHAR(2), name?) The set {sid, gpa} is a superkey. that arise in practice! PRIMARY KEY (sid), UNIQUE (cid, grade) ) 7 8 Foreign Keys, Referential Integrity Foreign Keys in SQL ❖ Only students listed in the Students relation should ❖ Foreign key : Set of fields in one relation that is used be allowed to enroll for courses. to `refer’ to a tuple in another (or the same) relation. (Must correspond to primary key of the CREATE TABLE Enrolled (sid CHAR(20), cid CHAR(20), grade CHAR(2), second relation.) Like a `logical pointer’. PRIMARY KEY (sid,cid), ❖ E.g. sid is a foreign key referring to Students: FOREIGN KEY (sid) REFERENCES Students ) – Enrolled(sid: string, cid: string, grade: string) Enrolled sid cid grade Students – If all foreign key constraints are enforced, referential 53666 Carnatic101 C sid name login age gpa integrity is achieved, i.e., no dangling references. 53666 Reggae203 B 53666 Jones jones@cs 18 3.4 – Can you name a data model w/o referential integrity? 53650 Topology112 A 53688 Smith smith@eecs 18 3.2 ◆ Links in HTML! 53666 History105 B 53650 Smith smith@math 19 3.8 9 10 Enforcing Referential Integrity Referential Integrity in SQL/92 ❖ Consider Students and Enrolled; sid in Enrolled is a foreign key that references Students. ❖ SQL/92 supports all 4 CREATE TABLE Enrolled ❖ options on deletes and (sid CHAR(20), What should be done if an Enrolled tuple with a non- updates. existent student id is inserted? (Reject it!) cid CHAR(20), – Default is NO ACTION grade CHAR(2), ❖ What should be done if a Students tuple is deleted? (delete/update is rejected) PRIMARY KEY (sid,cid), – Also delete all Enrolled tuples that refer to it. – CASCADE (also delete FOREIGN KEY (sid) – Disallow deletion of a Students tuple that is referred to. all tuples that refer to REFERENCES Students – Set sid in Enrolled tuples that refer to it to a default sid. deleted tuple) ON DELETE CASCADE – ON UPDATE SET DEFAULT ) (In SQL, also: Set sid in Enrolled tuples that refer to it to a – SET NULL / SET DEFAULT special placeholder null, meaning `unknown’ or `inapplicable’) (sets foreign key value ❖ Similar if primary key of Students tuple is updated. of referencing tuple) 11 12 Where do ICs Come From? Logical DB Design: ER to Relational ❖ ICs are based upon the semantics of the real- world enterprise that is being described in the ❖ Entity sets to tables. database relations. ❖ We can check a database instance to see if an IC is violated, but we can NEVER infer that name an IC is true by looking at an instance. ssn lot – An IC is a statement about all possible instances! Employees – From example, we know name is not a key, but the CREATE TABLE Employees assertion that sid is a key is given to us. (ssn CHAR(11), ❖ Key and foreign key ICs are the most name CHAR(20), common; more general ICs supported too. lot INTEGER, PRIMARY KEY (ssn)) 13 14 Relationship Sets to Tables Translating ER Diagrams with Key Constraints CREATE TABLE Works_In( CREATE TABLE Manages( ssn CHAR(1), ❖ Map relationship to a ❖ In translating a relationship ssn CHAR(11), did INTEGER, table: did INTEGER, set to a relation, attributes of since DATE, – Note that did is since DATE, the relation must include: PRIMARY KEY (did), the key now! PRIMARY KEY (ssn, did), FOREIGN KEY (ssn) REFERENCES Employees, – Keys for each FOREIGN KEY (ssn) – Separate tables for FOREIGN KEY (did) REFERENCES Departments) participating entity set REFERENCES Employees, Employees and (as foreign keys). Departments. FOREIGN KEY (did) CREATE TABLE Dept_Mgr( ◆ This set of attributes REFERENCES Departments) ❖ Since each did INTEGER, forms a superkey for department has a dname CHAR(20), budget REAL, the relation. unique manager, we could instead ssn CHAR(11), – All descriptive attributes. since DATE, combine Manages PRIMARY KEY (did), and Departments. FOREIGN KEY (ssn) REFERENCES Employees) 15 16 Participation Constraints in SQL Translating Weak Entity Sets ❖ We can capture participation constraints involving ❖ Weak entity set and identifying relationship one entity set in a binary relationship, but little else set are translated into a single table. (without resorting to CHECK constraints). – When the owner entity is deleted, all owned weak entities must also be deleted. CREATE TABLE Dept_Mgr( CREATE TABLE Dep_Policy ( did INTEGER, pname CHAR(20), dname CHAR(20), age INTEGER, budget REAL, cost REAL, ssn CHAR(11) NOT NULL, ssn CHAR(11) NOT NULL, since DATE, PRIMARY KEY (pname, ssn), PRIMARY KEY (did), FOREIGN KEY (ssn) REFERENCES Employees, FOREIGN KEY (ssn) REFERENCES Employees, ON DELETE CASCADE) ON DELETE NO ACTION) 17 18 Relational Query Languages The SQL Query Language ❖ A major strength of the relational model: ❖ Developed by IBM (system R) in the 1970s supports simple, powerful querying of data. ❖ Need for a standard since it is used by many ❖ Queries can be written intuitively, and the vendors DBMS is responsible for efficient evaluation. ❖ Standards: – The key: precise semantics for relational queries. – SQL-86 – Allows the optimizer to extensively re-order – SQL-89 (minor revision) operations, and still ensure that the answer does – SQL-92 (major revision, current standard) not change. – SQL-99 (major extensions) 19 20 The SQL Query Language Querying Multiple Relations ❖ What does the following query compute? ❖ To find all 18 year old students, we can write: SELECT S.name, E.cid FROM Students S, Enrolled E SELECT * sid name login age gpa WHERE S.sid=E.sid AND E.grade=“A” FROM Students 53666 Jones jones@cs 18 3.4 WHERE age=18 53688 Smith smith@ee 18 3.2 Given the following instance sid cid grade of Enrolled (is this possible if 53831 Carnatic101 C •To find just names and logins, replace the first line: the DBMS ensures referential 53831 Reggae203 B integrity?): 53650 Topology112 A SELECT name, login 53666 History105 B we get: S.name E.cid Smith Topology112 21 22 Adding and Deleting Tuples Destroying and Altering Relations ❖ Can insert a single tuple using: DROP TABLE Students INSERT INTO Students (sid, name, login, age, gpa) ❖ Destroys the relation Students. The schema VALUES (53688, ‘Smith’, ‘smith@ee’, 18, 3.2) information and the tuples are deleted. ❖ Can delete all tuples satisfying some condition (e.g., name = Smith): ALTER TABLE Students ADD COLUMN firstYear: integer DELETE FROM Students ❖ The schema of Students is altered by adding a WHERE name = ‘Smith’ new field; every tuple in the current instance ☛ Powerful variants of these commands are available; more later! is extended with a null in the new field. 23 24 Relational Model: Summary ❖ A tabular representation of data. ❖ Simple and intuitive, currently the most widely used. ❖ Integrity constraints can be specified by the DBA, based on application semantics. DBMS checks for violations.
Recommended publications
  • ACS-3902 Ron Mcfadyen Slides Are Based on Chapter 5 (7Th Edition)
    ACS-3902 Ron McFadyen Slides are based on chapter 5 (7th edition) (chapter 3 in 6th edition) ACS-3902 1 The Relational Data Model and Relational Database Constraints • Relational model – Ted Codd (IBM) 1970 – First commercial implementations available in early 1980s – Widely used ACS-3902 2 Relational Model Concepts • Database is a collection of relations • Implementation of relation: table comprising rows and columns • In practice a table/relation represents an entity type or relationship type (entity-relationship model … later) • At intersection of a row and column in a table there is a simple value • Row • Represents a collection of related data values • Formally called a tuple • Column names • Columns may be referred to as fields, or, formally as attributes • Values in a column are drawn from a domain of values associated with the column/field/attribute ACS-3902 3 Relational Model Concepts 7th edition Figure 5.1 ACS-3902 4 Domains • Domain – Atomic • A domain is a collection of values where each value is indivisible • Not meaningful to decompose further – Specifying a domain • Name, data type, rules – Examples • domain of department codes for UW is a list: {“ACS”, “MATH”, “ENGL”, “HIST”, etc} • domain of gender values for UW is the list (“male”, “female”) – Cardinality: number of values in a domain – Database implementation & support vary ACS-3902 5 Domain example - PostgreSQL CREATE DOMAIN posint AS integer CHECK (VALUE > 0); CREATE TABLE mytable (id posint); INSERT INTO mytable VALUES(1); -- works INSERT INTO mytable VALUES(-1); -- fails https://www.postgresql.org/docs/current/domains.html ACS-3902 6 Domain example - PostgreSQL CREATE DOMAIN domain_code_type AS character varying NOT NULL CONSTRAINT domain_code_type_check CHECK (VALUE IN ('ApprovedByAdmin', 'Unapproved', 'ApprovedByEmail')); CREATE TABLE codes__domain ( code_id integer NOT NULL, code_type domain_code_type NOT NULL, CONSTRAINT codes_domain_pk PRIMARY KEY (code_id) ) ACS-3902 7 Relation • Relation schema R – Name R and a list of attributes: • Denoted by R (A1, A2, ...,An) • E.g.
    [Show full text]
  • Relational Database Design Chapter 7
    Chapter 7: Relational Database Design Chapter 7: Relational Database Design First Normal Form Pitfalls in Relational Database Design Functional Dependencies Decomposition Boyce-Codd Normal Form Third Normal Form Multivalued Dependencies and Fourth Normal Form Overall Database Design Process Database System Concepts 7.2 ©Silberschatz, Korth and Sudarshan 1 First Normal Form Domain is atomic if its elements are considered to be indivisible units + Examples of non-atomic domains: Set of names, composite attributes Identification numbers like CS101 that can be broken up into parts A relational schema R is in first normal form if the domains of all attributes of R are atomic Non-atomic values complicate storage and encourage redundant (repeated) storage of data + E.g. Set of accounts stored with each customer, and set of owners stored with each account + We assume all relations are in first normal form (revisit this in Chapter 9 on Object Relational Databases) Database System Concepts 7.3 ©Silberschatz, Korth and Sudarshan First Normal Form (Contd.) Atomicity is actually a property of how the elements of the domain are used. + E.g. Strings would normally be considered indivisible + Suppose that students are given roll numbers which are strings of the form CS0012 or EE1127 + If the first two characters are extracted to find the department, the domain of roll numbers is not atomic. + Doing so is a bad idea: leads to encoding of information in application program rather than in the database. Database System Concepts 7.4 ©Silberschatz, Korth and Sudarshan 2 Pitfalls in Relational Database Design Relational database design requires that we find a “good” collection of relation schemas.
    [Show full text]
  • Relational Database Design: FD's & BCNF
    CS145 Lecture Notes #5 Relational Database Design: FD's & BCNF Motivation Automatic translation from E/R or ODL may not produce the best relational design possible Sometimes database designers like to start directly with a relational design, in which case the design could be really bad Notation , , ... denote relations denotes the set of all attributes in , , ... denote attributes , , ... denote sets of attributes Functional Dependencies A functional dependency (FD) has the form , where and are sets of attributes in a relation Formally, means that whenever two tuples in agree on all the attributes of , they must also agree on all the attributes of Example: FD's in Student(SID, SS#, name, CID, grade) Some FD's are more interesting than others: Trivial FD: where is a subset of Example: Nontrivial FD: where is not a subset of Example: Completely nontrivial FD: where and do not overlap Example: Jun Yang 1 CS145 Spring 1999 Once we declare that an FD holds for a relation , this FD becomes a part of the relation schema Every instance of must satisfy this FD This FD should better make sense in the real world! A particular instance of may coincidentally satisfy some FD But this FD may not hold for in general Example: name SID in Student? FD's are closely related to: Multiplicity of relationships Example: Queens, Overlords, Zerglings Keys Example: SID, CID is a key of Student Another de®nition of key: A set of attributes is a key for if (1) ; i.e., is a superkey (2) No proper subset of satis®es (1) Closures of Attribute Sets Given , a set of FD's
    [Show full text]
  • DBMS Keys Mahmoud El-Haj 13/01/2020 The
    DBMS Keys Mahmoud El-Haj 13/01/2020 The following is to help you understand the DBMS Keys mentioned in the 2nd lecture (2. Relational Model) Why do we need keys: • Keys are the essential elements of any relational database. • Keys are used to identify tuples in a relation R. • Keys are also used to establish the relationship among the tables in a schema. Type of keys discussed below: Superkey, Candidate Key, Primary Key (for Foreign Key please refer to the lecture slides (2. Relational Model). • Superkey (SK) of a relation R: o Is a set of attributes SK of R with the following condition: . No two tuples in any valid relation state r(R) will have the same value for SK • That is, for any distinct tuples t1 and t2 in r(R), t1[SK] ≠ t2[SK] o Every relation has at least one default superkey: the set of all its attributes o Basically superkey is nothing but a key. It is a super set of keys where all possible keys are included (see example below). o An attribute or a set of attributes that can be used to identify a tuple (row) of data in a Relation (table) is a Superkey. • Candidate Key of R (all superkeys that can be candidate keys): o A "minimal" superkey o That is, a (candidate) key is a superkey K such that removal of any attribute from K results in a set of attributes that IS NOT a superkey (does not possess the superkey uniqueness property) (see example below). o A Candidate Key is a Superkey but not necessarily vice versa o Candidate Key: Are keys which can be a primary key.
    [Show full text]
  • The Relational Model
    The Relational Model Watch video: https://youtu.be/gcYKGV-QKB0?t=5m15s Topics List • Relational Model Terminology • Properties of Relations • Relational Keys • Integrity Constraints • Views Relational Model Terminology • A relation is a table with columns and rows. • Only applies to logical structure of the database, not the physical structure. • Attribute is a named column of a relation. • Domain is the set of allowable values for one or more attributes. Relational Model Terminology • Tuple is a row of a relation. • Degree is the number of attributes in a relation. • Cardinality is the number of tuples in a relation. • Relational Database is a collection of normalised relations with distinct relation names. Instances of Branch and Staff Relations Examples of Attribute Domains Alternative Terminology for Relational Model Topics List • Relational Model Terminology • Properties of Relations • Relational Keys • Integrity Constraints • Views Properties of Relations • Relation name is distinct from all other relation names in relational schema. • Each cell of relation contains exactly one atomic (single) value. • Each attribute has a distinct name. • Values of an attribute are all from the same domain. Properties of Relations • Each tuple is distinct; there are no duplicate tuples. • Order of attributes has no significance. • Order of tuples has no significance, theoretically. Topics List • Relational Model Terminology • Properties of Relations • Relational Keys • Integrity Constraints • Views Relational Keys • Superkey • Super key stands for superset of a key. A Super Key is a set of one or more attributes that are taken collectively and can identify all other attributes uniquely. • An attribute, or set of attributes, that uniquely identifies a tuple within a relation.
    [Show full text]
  • Session 7 – Main Theme
    Database Systems Session 7 – Main Theme Functional Dependencies and Normalization Dr. Jean-Claude Franchitti New York University Computer Science Department Courant Institute of Mathematical Sciences Presentation material partially based on textbook slides Fundamentals of Database Systems (6th Edition) by Ramez Elmasri and Shamkant Navathe Slides copyright © 2011 and on slides produced by Zvi Kedem copyight © 2014 1 Agenda 1 Session Overview 2 Logical Database Design - Normalization 3 Normalization Process Detailed 4 Summary and Conclusion 2 Session Agenda . Logical Database Design - Normalization . Normalization Process Detailed . Summary & Conclusion 3 What is the class about? . Course description and syllabus: » http://www.nyu.edu/classes/jcf/CSCI-GA.2433-001 » http://cs.nyu.edu/courses/spring15/CSCI-GA.2433-001/ . Textbooks: » Fundamentals of Database Systems (6th Edition) Ramez Elmasri and Shamkant Navathe Addition Wesley ISBN-10: 0-1360-8620-9, ISBN-13: 978-0136086208 6th Edition (04/10) 4 Icons / Metaphors Information Common Realization Knowledge/Competency Pattern Governance Alignment Solution Approach 55 Agenda 1 Session Overview 2 Logical Database Design - Normalization 3 Normalization Process Detailed 4 Summary and Conclusion 6 Agenda . Informal guidelines for good design . Functional dependency . Basic tool for analyzing relational schemas . Informal Design Guidelines for Relation Schemas . Normalization: . 1NF, 2NF, 3NF, BCNF, 4NF, 5NF • Normal Forms Based on Primary Keys • General Definitions of Second and Third Normal Forms • Boyce-Codd Normal Form • Multivalued Dependency and Fourth Normal Form • Join Dependencies and Fifth Normal Form 7 Logical Database Design . We are given a set of tables specifying the database » The base tables, which probably are the community (conceptual) level . They may have come from some ER diagram or from somewhere else .
    [Show full text]
  • Database Final Exam Notes SQL Functional Dependencies And
    ⟨Ssn, Pnumber, Hours, Ename, Pname, Plocation⟩ Database Final Exam Notes Dependencies: Ssn ⟶ Ename Pnumber ⟶ Pname, Plocation SQL {Ssn, Pnumber} ⟶ Hours 1. create table employee2 ( 2. create table department2 ( fname varchar(15) not null, dname varchar(15) not null, lname varchar(15) not null, dnumber int not null, ssn char(9) not null, mgr_ssn char(9) not null, salary decimal(10,2), primary key (dnumber), super_ssn char(9), foreign key (mgr_ssn) references employee(ssn) dno int not null, ); primary key (ssn), foreign key (super_ssn) references employee(ssn), foreign key (dno) references department(dnumber) ); 3. insert into employee2 values (©peter©, ©dordal©, ©123456789©, 29000.01, ©012345678©, 55); 4. delete from employee2 where fname=©peter©; 5. update employee2 set salary = 1.10 * salary where salary >= 50000; 6. select e.lname from employee2 e where e.dno = 5; 7a. select e.lname from employee2 e, department2 d where e.dno = d.dnumber and d.dname="maintenance"; 7b. select e.lname from employee2 e join department2 d on e.dno = d.dnumber where d.dname="maintenance"; (same result as 7a) 8. select e.lname from employee2 e where e.salary in (select e.salary from employee2 e where e.dno = 5); 9. select e.dno, count(*) from employee e GROUP BY e.dno; 10. select e.dno, sum(e.salary) from employee e GROUP BY e.dno 11. Select sum(e.salary) from employee2 e, department2 d where d.dname=©Research© and d.dnumber=e.dno; 12. Select e.lname, e.salary, 1.035 * e.salary AS newsalary from employee2; Normal Forms and Normalization First Normal Form Functional Dependencies and Normalization First Normal Form (1NF) means that a relation has no composite attributes or multivalued attributes.
    [Show full text]
  • Relational Data Model a Brief History of Data Models Relational Model
    A Brief History of Data Models 1950s file systems, punched cards 1960s hierarchical Relational Data Model IMS 1970s network CODASYL, IDMS 1980s relational INGRES, ORACLE, DB2, Sybase Paradox, dBase 1990s object oriented and object relational O2, GemStone, Ontos Relational Model COURSE Sets Courseno Subject Lecturer Machine collections of items of the same type no order domain range CS250 Programming Lindsey Sun no duplicates 1:many CS260 Graphics Hubbold Sun Mappings many:1 CS270 Micros Woods PC CS290 Verification Barringer Sun 1:1 many:many Relational Model Notes Comparative Terms no duplicate tuples in a relation a relation is a set of tuples Formal Oracle no ordering of tuples in a relation Relation schema Table description a relation is a set Relation Table Tuple Row attributes of a relation have an implied Attribute Column ordering Domain Value set but used as functions and referenced by name, not position Notation every tuple must have attribute values drawn Course (courseno, subject, from all of the domains of the relation or the equipment) special value NULL Student(studno,name,hons) Enrol(studno,courseno,labmark) all a domain’s values and hence attribute’s values are atomic. 1 Keys Foreign Key SuperKey a set of attributes in a relation that exactly a set of attributes whose values together uniquely matches a (primary) key in another relation identify a tuple in a relation the names of the attributes don’t have to be the Candidate Key same but must be of the same domain a superkey for which no proper subset is a a foreign key in a relation A matching a primary superkey…a key that is minimal .
    [Show full text]
  • Relational Keys I. Superkey
    Chapter 4 The Relational Model Pearson Education © 2009 Overview I. This chapter covers the relational model, which provides a formal description of the structure of a database II. The next chapter covers the relational algebra and calculus, which provides a formal basis for the query language for the database 2 Instances of Branch and Staff Relations 3 Pearson Education © 2009 Relational Model Terminology I. A relation is a table with columns and rows. A. Only applies to logical structure of the database, not the physical structure. II. An attribute is a named column of a relation. III. A domain is the set of allowable values for one or more attributes. 4 Pearson Education © 2009 Relational Model Terminology IV. A tuple is a row of a relation. V. The degree is the number of attributes in a relation. VI. The cardinality is the number of tuples in a relation. VII. A Relational Database is a collection of normalized relations with distinct relation names. • Typically means that the only shared columns among relations are foreign keys (eliminates redundancy) 5 Pearson Education © 2009 Examples of Attribute Domains 6 Pearson Education © 2009 Alternative Terminology for Relational Model 7 Pearson Education © 2009 Mathematical Definition of Relation I. Consider two sets, D1 & D2, where D1 = {2, 4} and D2 = {1, 3, 5}. II. Cartesian product, D1 × D2, is set of all ordered pairs, where first element is member of D1 and second element is member of D2. D1 × D2 = {(2, 1), (2, 3), (2, 5), (4, 1), (4, 3), (4, 5)} A. Alternative way is to find all combinations of elements with first from D1 and second from D2.
    [Show full text]
  • Subject: Database Management Systems
    Structure 1.0 Objectives 1.1 Introduction 1.2 Data Processing Vs. Data Management Systems 1.3 File Oriented Approach 1.4 Database Oriented Approach to Data Management 1.5 Characteristics of Database 1.6 Advantages and Disadvantages of a DBMS 1.7 Instances and Schemas 1.8 Data Models 1.9 Database Languages 1.9 Data Dictionary 1.11 Database Administrators and Database Users 1.12 DBMS Architecture and Data Independence 1.13 Types of Database System 1.14 Summary 1.15 keywords 1.16 Self Assessment Questions (SAQ) 1.17 References/Suggested Readings 1.0 Objectives At the end of this chapter the reader will be able to: • Distinguish between data and information and Knowledge • Distinguish between file processing system and DBMS • Describe DBMS its advantages and disadvantages • Describe Database users including data base administrator • Describe data models, schemas and instances. • Describe DBMS Architecture & Data Independence • Describe Data Languages 1 1.1 Introduction A database-management system (DBMS) is a collection of interrelated data and a set of programs to access those data. This is a collection of related data with an implicit meaning and hence is a database. The collection of data, usually referred to as the database, contains information relevant to an enterprise. The primary goal of a DBMS is to provide a way to store and retrieve database information that is both convenient and efficient. By data, we mean known facts that can be recorded and that have implicit meaning. For example, consider the names, telephone numbers, and addresses of the people you know. You may have recorded this data in an indexed address book, or you may have stored it on a diskette, using a personal computer and software such as DBASE IV or V, Microsoft ACCESS, or EXCEL.
    [Show full text]
  • The Relational Data Model and Relational Database Constraints
    The Relational Data Model and Relational Database Constraints First introduced by Ted Codd from IBM Research in 1970, seminal paper, which introduced the Relational Model of Data representation. It is based on Predicate Logic and set theory. Predicate logic is used extensively in mathematics and provides a framework in which an assertion can be verified as either true or false. For example, a person with T number T00178477 is named Lila Ghemri. This assertion can easily be demonstrated as true or false. Set theory deals with sets and is used as a basis for data manipulation in the relational model. For example, assume that A= {16, 24, 77}, B= {44, 77, 90, 11}. Given this information, we can compute that A B= {77} Based on these concepts, the relational model has three well defined components: 1. A logical data structure represented by relations 2. A set of integrity rules to enforce that the data are and remain consistent over time 3. A set of operations that defines how data are manipulated. Relational Model Concepts: The relational model represents the database as a collection of relations. Informally, each relation resembles a table of values or a flat file of records. When a relation is thought of as a table of values, each row in the table represents a collection of related data values corresponding to a real world entity. The table name and column names are used to help interpret the meaning of the values in each row. For example the table below is called STUDENT because each row represents facts about a particular student entity.
    [Show full text]
  • Constraints and Updates
    CONSTRAINTS AND UPDATES CHAPTER 3 (6/E) CHAPTER 5 (5/E) 1 LECTURE OUTLINE . Constraints in Relational Databases . Update Operations . Brief History of Database Applications (from Section 1.7) 3 RELATIONAL MODEL CONSTRAINTS . Constraints • Restrictions on the permitted values in a database state • Derived from the rules in the miniworld that the database represents . Inherent model-based constraints or implicit constraints • Inherent in the data model • e.g., duplicate tuples are not allowed in a relation . Schema-based constraints or explicit constraints • Can be directly expressed in schemas of the data model • e.g., films have only one director . Application-based or semantic constraints • Also called business rules • Not directly expressed in schemas • Expressed and enforced by application program • e.g., this year’s salary increase can be no more than last year’s 4 DOMAIN CONSTRAINTS . Declared by specifying the data type for each attribute: • Numeric data types for integers and real numbers • Characters • Booleans • Fixed-length strings • Variable-length strings • Date, time, timestamp • Money • Other special data types 5 KEY CONSTRAINTS . Uniqueness constraints on tuples . SK {A1, A2, ..., An} is a superkey of R(A1, A2, ..., An) if • In any relation state r of R, no two distinct tuples can have the same values for SK • t1 [SK] = t2 [SK] t1 = t2 . K is a key of R if 1. K is a superkey of R 2. Removing any attribute from K leaves a set of attributes that is not a superkey of R any more • No proper subset of K is a superkey of R . If K is a key, it satisfies two properties 1.
    [Show full text]