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.
| 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 |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
|
|
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 |
 |
|
|
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. |
 |
|
|
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 |
 |
|
|
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?). |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
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 atributesrelationships become tables which glue your entities together.So a !simlified! example may beEntity: 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 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
|
|
|
|
|