0% found this document useful (0 votes)
25 views2 pages

My Discussion Assignment Unit 4

Discussion Assignment Unit 4

Uploaded by

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

My Discussion Assignment Unit 4

Discussion Assignment Unit 4

Uploaded by

hamedhussam25
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

SQL Data Types for storing student information


When designing a database system for a university, it is important to choose the best
and appropriate data type to ensure data integrity, efficiency, and clarity.
Here are the types of SQL data that I will use to store student names, ages, and grades:
For student names "we can use VARCHAR data type this data type stores in the form
of variable-length character strings with a maximum of 255 characters"(SQL Data
Types: List, Integer, Character & More | StudySmarter, n.d.). It is ideal for student
names as they can vary in length and avoid wasted storage for short names.
For age, we use the INT type " signed integer that can store an integer (positive,
negative, or neutral). It is commonly used for identifiers, ages, and numbers."(SQL
Data Types: List, Integer, Character & More | StudySmarter, n.d.). This data type
stores integers. Since age is always an integer, INT is efficient for storage.
In terms of grades, decimal numbers are often used, and for this type of
data, DECIMAL(3,2) ensures precision and accuracy, allowing grades to be stored
with two decimal places and is suitable if the University uses a grading system with
percentages or decimals.
It is also possible to use CHAR this data type stores character strings of fixed length
with a maximum of 2 characters. This is a space-saving option if the University uses a
letter grading system with a limited number of grades (for example, A, B, C, D, F)
and because the grades are usually short strings.
These types of data provide an efficient way to store and manipulate both letters and
numeric grades, ensuring data accuracy and readability.
2. SQL query to retrieve the names and ages of students enrolled in Computer
Science 101
SELECT
students.name AS StudentName,
students.age AS StudentAge
This part of the query specifies the columns to be retrieved: the student names and
ages. The AS keyword is used to give more readable names (aliases) to the columns in
the result set.
FROM
students
This indicates the primary table from which the data is being selected. In this case, it
is the students' table.
JOIN
enrollments ON students.student_id = enrollments.student_id
This JOIN clause combines the students' table with the enrollments table based on the
matching student_id column. This ensures that we only get records for students who
are enrolled in courses.
JOIN
courses ON enrollments.course_id = courses.course_id
This further joins the enrollments table with the courses table based on the course_id
column, linking enrollment records to specific courses.
WHERE
courses.course_name = 'Computer Science 101';
The WHERE clause filters the result set to include only students enrolled in
'Computer Science 101'. This ensures that only the relevant records are retrieved.
Discussion Question:
Imagine the university wants to track additional information about students, such as
their major or contact details. How would you modify the table structure and queries
to accommodate this additional information?

Reference:
SQL Data Types: List, Integer, Character & More | StudySmarter. (n.d.).
StudySmarter
UK. https://www.studysmarter.co.uk/explanations/computer-science/databases/sql-
data-types/
Watt, A. (2014, October 24). Chapter 15 SQL Structured Query Language.
Opentextbc.ca; BCcampus. https://opentextbc.ca/dbdesign01/chapter/sql-structured-
query-language/

You might also like