Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Table design

Author  Topic 

nasim.sona
Starting Member

7 Posts

Posted - 2012-03-14 : 04:02:43
Hi All,

I am designing a new database for a small application for online-course portal. I designed a table called courses like.

create table courses
( course nvarchar(25) not null,
semister int not null,
subject1 int,
subject2 int,
subject3 int,
subject4 int,
subject5 int,
..
subject10 int,
primary key(course,semister))

and
create table subjects
(
subjectid int primary key,
sname nvarchar(20),
duration int,
path nvarchar(30));

I found it may result in complex query while retrieving data.
Is this normalized ? If not ,what design should I go for?
I appreciate your time and suggestion!!

-Nasim

nasim.sona
Starting Member

7 Posts

Posted - 2012-03-14 : 07:44:46
quote:
Originally posted by nasim.sona

Hi All,

I am designing a new database for a small application for online-course portal. I designed a table called courses like.

create table courses
( course nvarchar(25) not null,
semister int not null,
subject1 int,
subject2 int,
subject3 int,
subject4 int,
subject5 int,
..
subject10 int,
primary key(course,semister))

and
create table subjects
(
subjectid int primary key,
sname nvarchar(20),
duration int,
path nvarchar(30));

I found it may result in complex query while retrieving data.
Is this normalized ? If not ,what design should I go for?
I appreciate your time and suggestion!!

-Nasim



-Nasim
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2012-03-14 : 08:06:22
This is not normalized.
http://en.wikipedia.org/wiki/Database_normalization









How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

nasim.sona
Starting Member

7 Posts

Posted - 2012-03-14 : 09:14:56
HI Donatwork,

Thanks for your feedback.

It may appear basic question but if you can suggest a normalized form for this ,it would be really nice of you.

-Nasim
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2012-03-14 : 12:06:58
This doens't answer your question directly. But, since you are just starting out with databases, I'd suggest that you get a copy of a book called An Introduction to Database Systems.
Go to Top of Page

nasim.sona
Starting Member

7 Posts

Posted - 2012-03-15 : 10:27:36
Is this that tough to be answered ? Do I again need to go to school and study to get some help? Please help if any one could design the same in a better way.

-Nasim
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2012-03-15 : 11:56:31
It looks like your entities are: Courses, Semisters and Subjects. Are there any other entities? It appears that Subjects has the followint attributes: name, duration, path. Are there any other attributes for this and/or other entites? What are the definition of the entities (I.E. What is a course? How is that different froma subject?).

Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-03-15 : 12:35:58
Start with all the data you know about..worry about relationship later...create the entities based on what you know...then form the relationships

What does Course mean? If it means like a predefined set up subjects? Then I would have a course table and a subject table and a CourseSubject table that has the courseID and SubjectID..1 row for each one of your 10 subjects

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2012-03-15 : 12:36:17
yeah -- think in terms of entities and relationships.

(this is waaaay generalised)

entities become tables with columns on their atributes

relationships become tables which glue your entities together.

So a !simlified! example may be

Entity: Course - Properties ( CourseTitle, CourseCode, Points ) (CourseCode is a key uniquely identifying the course)
Entity: Student - Properties ( StudentName, StudentMatriculationNumber ) (StudentMatriculationNumber is a key uniquely identifying the student)

RelationShip: StudentCourses (SudentMatriculationNumber, CourseCode)

Leading to tables:

CREATE TABLE Course (
[CourseCode] CHAR(6) NOT NULL
, [CourseTitle] VARCHAR(255) NOT NULL
, [CoursePoints] TINYINT NOT NULL

, CONSTRAINT PK_Course_CourseCode
PRIMARY KEY CLUSTERED ([CourseCode])
)

CREATE TABLE Student (
[StudentMatriculationNumber] INT NOT NULL
, [StudentName] VARCHAR(255) NOT NULL

, CONSTRAINT PK_Student_StudentMatriculationNumber
PRIMARY KEY CLUSTERED ([StudentMatriculationNumber])
)

CREATE TABLE StudentCourse (
[StudentMatriculationNumber] INT NOT NULL
, [CourseCode] CHAR(6) NOT NULL

, CONSTRAINT PK_StudentCourse
PRIMARY KEY CLUSTERED ( [StudentMatriculationNumber], [CourseCode] )

, CONSTRAINT FK_StudentCourse_StudentMatriculationNumber
FOREIGN KEY ([StudentMatriculationNumber])
REFERENCES Student ( [StudentMatriculationNumber])

, CONSTRAINT FK_StudentCourse_CourseCode
FOREIGN KEY ([CourseCode])
REFERENCES Course ( [CourseCode] )
)


Hopefully that helps you out.

Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page
   

- Advertisement -