0% found this document useful (0 votes)
47 views18 pages

Relational Schema Examples and Diagrams

The document provides examples of relational schemas for different domains including a university database (DA-Acad), hostel database (HoR), and company database. It includes the entity sets and relationships for each schema along with foreign key constraints. Additionally, it simplifies the company schema and lists the entity sets and foreign key constraints.

Uploaded by

Patel Vaidik
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views18 pages

Relational Schema Examples and Diagrams

The document provides examples of relational schemas for different domains including a university database (DA-Acad), hostel database (HoR), and company database. It includes the entity sets and relationships for each schema along with foreign key constraints. Additionally, it simplifies the company schema and lists the entity sets and foreign key constraints.

Uploaded by

Patel Vaidik
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Schema Examples

pm_jat @ daiict
XIT Database – Relational Schema

8/5/2019 Relational Model - Concepts 2


XIT Database – Relation Instances
Student
StudentID Name ProgID CPI
101 Rahul BCS 7.5
102 Vikash BIT 8.6
103 Shally BEE 5.4
104 Alka BIT 6.8
105 Ravi BCS 6.5

Program
PID ProgName Intake DID
Department
BCS BTech(CS) 40 CS
DID DName
BIT BTech(IT) 30 CS
CS Computer Engineering
BEE BTech(EE) 40 EE
EE Electrical Engineering
BME BTech(ME) 40 ME
ME Mechanical Engineering

8/5/2019 Relational Model - Concepts 3


Company (Database) Schema

8/5/2019 Relational Model - Concepts 4


Employee

DLocation
Department

8/5/2019 Relational Model - Concepts 5


Department

Projects

8/5/2019 Relational Model - Concepts 6


Works_ON

8/5/2019 Relational Model - Concepts 7


Dependents

8/5/2019 Relational Model - Concepts 8


DA-Acad schema
Student(StudetID, StdName, ProgID, Batch)
Course(CourseNo, CourseName, Credit)
Faculty(FacultyID, FacultyName)
Offers(AcadYear, Semester, CourseNo, FacultyID)
Registers(StudetID, AcadYear, Semester, CourseNo, grade)
Result(StudetID, AcadYear, SemesterType, SPI, CPI)
Semester(AcadYear, SemesterType)
==> Observe Keys here?
==> What are Foreign Keys here?

8/5/2019 Relational Model - Concepts 9


Instructor

DA-ACad
CourseOffering

Course

8/5/2019 Relational Model - Concepts 10


CourseOffering

CourseRegistration

8/5/2019 Relational Model - Concepts 11


DA-Acad schema (FKs)
Offers: CourseNo refers to Course(CourseNo)
Offers: FacultyID refers to Faculty(FacultyID)
Registers: StudetID refers to Student(StudetID)
Registers: (AcadYear, Semester, CourseNo) refers to
Offers(AcadYear, Semester, CourseNo)
Result: StudetID refers to Student(StudetID)
Result(AcadYear, SemesterType)
refers to Semester(AcadYear, SemesterType)

8/5/2019 Relational Model - Concepts 12


Schema HoR #1

STUDENT(id, name, email, prog_code, batch, cpi)


//Batch is like 2009, 2010, or so; Progcode is like ‘01’ for BTech, or so
ROOM(rno, wing, floor)
//floors are like 0 (Ground), 1(First), and 2 (Second)

ALLOT(sid, rno)
//Record of all allotments is stored in this relation. Students (sid) not having
entry in this relation means-they are not residing in the HoR

HMC(sid, wing, Floor)


//Key SID and (Wing, Floor)

8/5/2019 Relational Model - Concepts 13


Schema HoR #2
STUDENT(id, name, email, prog_code, batch, cpi)
//Batch is like 2009, 2010, or so; Progcode is like ‘01’ for BTech, or so
CoursesTaken(stud_id, course_no, sem, acad_yr, grade)
Result(stud_id, sem, acad_yr, SPI, CPI)
ROOM(rno, wing, floor)
//floors are like 0 (Ground), 1(First), and 2 (Second)
ALLOT(sid, rno)
//Record of all allotments is stored in this relation. Students (sid) not
having entry in this relation means-they are not residing in the HoR
SBG(sid, Committee, Role)
//sid is student id of sbg member, and role can be like convener, or
member, committee is name of committee like CMC, or HMC, or so

8/5/2019 Relational Model - Concepts 14


Simplified Company schema
EMPLOYEE (ssn, ename, bdate, dno, gender, superssn)
Foreign Keys: dno REFERENCES department (dno),
Foreign Key: superssn REFERENCES employee (ssn)
DEPARTMENT (dno, dname, mgrssn, mgrstartdate )
Foreign Keys: mgrssn REFERENCES employee (essn)
DEP_LOCATIONS (dno, dlocation)
Foreign Keys: dno REFERENCES department (dno),
PROJECT (pno, pname, plocation, dno)
Foreign Keys: dno REFERENCES department (dno),
WORKS_ON (essn, pno, hours)
Foreign Keys: essn REFERENCES employee (essn)
Foreign Keys: pno REFERENCES project (pno)
DEPENDENT (essn, dep_name, gender, bdate date, relationship)
Foreign Keys: essn REFERENCES employee (essn)

5-Aug-19 Operations on Relations 15


8/5/2019 Relational Model - Concepts 16
8/5/2019 Relational Model - Concepts 17
8/5/2019 Relational Model - Concepts 18

Common questions

Powered by AI

Both DA-Acad and Simplified Company schemas utilize foreign keys to optimize efficiency by ensuring data consistency and integrity across related tables. DA-Acad connects 'StudetID' across various tables, such as 'Registers' and 'Result', ensuring students' records are consistent. Similarly, the Company schema links 'dno' in 'DEPARTMENT' to tables like 'PROJECT' and 'EMPLOYEE', assuring department information consistency. Such constraints avoid data redundancy, support referential integrity, and enable efficient queries through structured relational mappings .

Primary and foreign keys are crucial for data consistency in relational databases by uniquely identifying records and establishing controlled references between tables. In the XIT and Company schemas, primary keys like 'StudentID' and 'ssn' ensure unique identification of records, while foreign keys maintain relational integrity by enforcing valid linkage between dependent tables. They prevent anomalies and redundancies, supporting accurate data manipulation and retrieval, which are foundational for reliable database operations .

In both schemas, potential redundancy occurs when similar data is unnecessarily repeated across tables, such as department information in 'DEPARTMENT', 'PROJECT', and 'EMPLOYEE'. Normalization strategies like dividing data into related tables and using foreign keys to connect them can eliminate redundancies. For instance, ensuring department details reside solely in 'DEPARTMENT' and referenced via foreign keys reduces duplication while enforcing data consistency, exemplifying normalization practices like the Third Normal Form .

The 'Simplified Company Schema' enforces data integrity through a hierarchical structure of foreign keys, where the 'DEPARTMENT' table functions as a cornerstone, referenced by 'EMPLOYEE', 'DEP_LOCATIONS', 'PROJECT', and indirectly by 'DEPENDENT'. This structure ensures consistent department data across these tables. The 'EMPLOYEE' table is crucial for the 'WORKS_ON' and 'DEPENDENT' tables through foreign key constraints, maintaining employee-related data integrity across projects and dependent records. This hierarchy facilitates structured data flow conducive to maintaining data integrity in relational databases .

In the company schema, foreign keys help establish relationships by linking 'WORKS_ON' and 'DEPENDENT' tables to the 'EMPLOYEE' table. The 'WORKS_ON' table uses 'essn' as a foreign key referencing 'EMPLOYEE', linking employees to their respective projects. Similarly, 'DEPENDENT' uses 'essn' to associate dependents with employees, ensuring any change in employee data automatically reflects across related entries, thereby maintaining relationship integrity .

The DA-Acad schema employs keys to streamline data retrieval by employing foreign keys like 'StudetID' in the 'Result' table referring back to 'Student', creating a direct link for retrieving a student's academic results. Similarly, the composite key of 'AcadYear' and 'Semester' in 'Registers' references the 'Offers' to efficiently access course offerings corresponding to a specific academic period. These keyed relationships facilitate precise and efficient data retrieval, supporting academic evaluations .

Using multiple foreign keys adds complexity by requiring more comprehensive checks to maintain referential integrity, increasing the intricacy of data operations. In the 'Registers' table, foreign keys link student records to academic offerings, necessitating multi-level constraints management. Similarly, 'RESULT' uses keys linking to both 'Student' and 'Semester', complicating updates and deletions, as alterations may cascade across linked tables, illustrating heightened complexity in ensuring synchronized data states .

Referential integrity in the XIT Database is maintained through foreign keys. In the schema, the 'Registers' table ensures referential integrity by linking 'StudetID' to the 'Student' table as a foreign key, while 'CourseNo' in the 'Registers' table refers to 'CourseNo' in the 'Course' table. Additionally, 'AcadYear' and 'Semester' in 'Registers' reference 'Offers' as part of a compound foreign key, ensuring data consistency across related tables .

The 'ProgID' field in the XIT database schema acts as a pivotal link among Students, Programs, and Departments. It maps students to programs in the 'Student' table and connects to the 'Programs' table, which further relates to the 'Departments' table via 'DID'. This setup allows a streamlined reference across tables, ensuring data integrity and enabling a comprehensive view of a student's academic trajectory within the institutional hierarchy .

In the HoR schema, students are linked to rooms through the 'ALLOT' table and to social bodies via the 'SBG' table. This interrelation ensures students' accommodation data ('sid', 'rno') and their roles in committees are consistently managed. The schema design's implications include robust data management, ensuring students' residential and extracurricular information is accurately tracked and cross-referenced, enhancing data integrity and operational efficiency within housing and organizational contexts .

You might also like