I have a table: Schools,
and another table: Teachers
as one teacher may be assigned to more than one school I link these with a
third table: SchoolTeachers
I index (unique) this linking table on SchoolID and TeacherID to prevent
assigning a teacher to a school more than once.
So far, so good.
But School Administrators have difficulty with the idea that there might be
more than one "Lynda Jones", teacher, assigned to one school, and that the
database will keep track of these individuals with their unique TeacherID,
and timetables printed out for more than one Lynda Jones may confuse
students.
So I want to prevent any school from having more than one Lynda Jones, that
is require unique teacher names for any school.
How to do this?
My current solution -> an indexed view:
Sub CreateSQLObject ()
With CurrentProject. Connection
.Execute "CREATE VIEW dbo.SchoolsandT eachers WITH SCHEMABINDING AS
SELECT st.SchoolTeache rID, s.SchoolID, s.SchoolName, t.TeacherID,
t.TeacherName FROM dbo.Schools s JOIN dbo.SchoolTeach ers st ON s.SchoolID =
st.SchoolID JOIN dbo.Teachers t ON st.TeacherID = t.TeacherID"
.Execute "SET ARITHABORT ON"
.Execute "CREATE UNIQUE CLUSTERED INDEX ixSchoolsTeache rs ON
dbo.SchoolsandT eachers (SchoolTeacherI D)"
.Execute "CREATE UNIQUE INDEX ixSchoolsandTea chers ON
dbo.SchoolsandT eachers (SchoolID, TeacherName)"
End With
End Sub
Of course, this has not yet been tried in battle. But it seems promising.
These will not be huge tables so I am hoping the indexing overhead will be
minimal. Comments are welcome.
--
Lyle
(for e-mail refer to http://ffdba.com/) 13 1783
Lyle Fairfield <Mi************ @Invalid.Com> wrote in
news:Xn******** ***********@130 .133.1.4:
Anyone know how to spellcheck Subjects?
--
Lyle
(for e-mail refer to http://ffdba.com/)
No offence, Lyle, but is that a realistic limitation: to prevent a school
from having 2 teachers with the same name? We had two individuals with the
same name in a 12 person department (and their wives had the same names as
well!)
--
Doug Steele, Microsoft Access MVP http://I.Am/DougSteele
(no e-mails, please!)
"Lyle Fairfield" <Mi************ @Invalid.Com> wrote in message
news:Xn******** ***********@130 .133.1.4... I have a table: Schools, and another table: Teachers as one teacher may be assigned to more than one school I link these with a third table: SchoolTeachers
I index (unique) this linking table on SchoolID and TeacherID to prevent assigning a teacher to a school more than once.
So far, so good.
But School Administrators have difficulty with the idea that there might
be more than one "Lynda Jones", teacher, assigned to one school, and that the database will keep track of these individuals with their unique TeacherID, and timetables printed out for more than one Lynda Jones may confuse students.
So I want to prevent any school from having more than one Lynda Jones,
that is require unique teacher names for any school.
"Lyle Fairfield" <Mi************ @Invalid.Com> wrote in message
news:Xn******** ***********@130 .133.1.4... I have a table: Schools, and another table: Teachers as one teacher may be assigned to more than one school I link these with a third table: SchoolTeachers
I index (unique) this linking table on SchoolID and TeacherID to prevent assigning a teacher to a school more than once.
So far, so good.
But School Administrators have difficulty with the idea that there might
be more than one "Lynda Jones", teacher, assigned to one school, and that the database will keep track of these individuals with their unique TeacherID, and timetables printed out for more than one Lynda Jones may confuse students.
So I want to prevent any school from having more than one Lynda Jones,
that is require unique teacher names for any school.
How to do this?
My current solution -> an indexed view:
Sub CreateSQLObject ()
With CurrentProject. Connection
.Execute "CREATE VIEW dbo.SchoolsandT eachers WITH SCHEMABINDING AS SELECT st.SchoolTeache rID, s.SchoolID, s.SchoolName, t.TeacherID, t.TeacherName FROM dbo.Schools s JOIN dbo.SchoolTeach ers st ON s.SchoolID
= st.SchoolID JOIN dbo.Teachers t ON st.TeacherID = t.TeacherID"
.Execute "SET ARITHABORT ON"
.Execute "CREATE UNIQUE CLUSTERED INDEX ixSchoolsTeache rs ON dbo.SchoolsandT eachers (SchoolTeacherI D)"
.Execute "CREATE UNIQUE INDEX ixSchoolsandTea chers ON dbo.SchoolsandT eachers (SchoolID, TeacherName)"
End With
End Sub
Of course, this has not yet been tried in battle. But it seems promising. These will not be huge tables so I am hoping the indexing overhead will be minimal. Comments are welcome.
An alternative might be to create allow teachers with the same name and
create a view that would include the teachers ID if a school has two or more
teachers with the same:
CREATE VIEW dbo.SchoolsandT eachers WITH SCHEMABINDING AS
SELECT st.SchoolTeache rID, s.SchoolID,
CASE
WHEN
(
SELECT COUNT(*) FROM dbo.SchoolTeach ers st2
INNER JOIN dbo.Teachers t2 ON st2.TeacherID = t2.TeacherID
WHERE st2.SchoolID = st.SchoolID
AND t2.TeacherName = t.TeacherName
) > 1 THEN t.TeacherName + ' (' + CAST(t.TeacherI D AS VARCHAR(15)) +
')'
ELSE t.TeacherName
END AS TeacherName,
s.SchoolName, t.TeacherID,
t.TeacherName FROM dbo.Schools s
JOIN dbo.SchoolTeach ers st ON s.SchoolID = st.SchoolID
JOIN dbo.Teachers t ON st.TeacherID = t.TeacherID
I don't think the extra overhead would be too drastic, especially if
TeacherName is indexed. And, unless a school has a standing policy of not
hiring two teachers with the same name, (unlikely), this would more closely
model the real world. And it would give a nice looking output:
TeacherName
--------------
Jack Layton
Paul Martin (123)
Paul Martin (456)
Steven Harper
"John Winterbottom" <as******@hotma il.com> wrote in
news:2j******** *****@uni-berlin.de: "Lyle Fairfield" <Mi************ @Invalid.Com> wrote in message news:Xn******** ***********@130 .133.1.4... I have a table: Schools, and another table: Teachers as one teacher may be assigned to more than one school I link these with a third table: SchoolTeachers
I index (unique) this linking table on SchoolID and TeacherID to prevent assigning a teacher to a school more than once.
So far, so good.
But School Administrators have difficulty with the idea that there might be more than one "Lynda Jones", teacher, assigned to one school, and that the database will keep track of these individuals with their unique TeacherID, and timetables printed out for more than one Lynda Jones may confuse students.
So I want to prevent any school from having more than one Lynda Jones, that is require unique teacher names for any school.
How to do this?
My current solution -> an indexed view:
Sub CreateSQLObject ()
With CurrentProject. Connection
.Execute "CREATE VIEW dbo.SchoolsandT eachers WITH SCHEMABINDING AS SELECT st.SchoolTeache rID, s.SchoolID, s.SchoolName, t.TeacherID, t.TeacherName FROM dbo.Schools s JOIN dbo.SchoolTeach ers st ON s.SchoolID = st.SchoolID JOIN dbo.Teachers t ON st.TeacherID = t.TeacherID"
.Execute "SET ARITHABORT ON"
.Execute "CREATE UNIQUE CLUSTERED INDEX ixSchoolsTeache rs ON dbo.SchoolsandT eachers (SchoolTeacherI D)"
.Execute "CREATE UNIQUE INDEX ixSchoolsandTea chers ON dbo.SchoolsandT eachers (SchoolID, TeacherName)"
End With
End Sub
Of course, this has not yet been tried in battle. But it seems promising. These will not be huge tables so I am hoping the indexing overhead will be minimal. Comments are welcome.
An alternative might be to create allow teachers with the same name and create a view that would include the teachers ID if a school has two or more teachers with the same:
CREATE VIEW dbo.SchoolsandT eachers WITH SCHEMABINDING AS SELECT st.SchoolTeache rID, s.SchoolID, CASE WHEN ( SELECT COUNT(*) FROM dbo.SchoolTeach ers st2 INNER JOIN dbo.Teachers t2 ON st2.TeacherID = t2.TeacherID WHERE st2.SchoolID = st.SchoolID AND t2.TeacherName = t.TeacherName ) > 1 THEN t.TeacherName + ' (' + CAST(t.TeacherI D AS VARCHAR(15)) + ')' ELSE t.TeacherName END AS TeacherName, s.SchoolName, t.TeacherID, t.TeacherName FROM dbo.Schools s JOIN dbo.SchoolTeach ers st ON s.SchoolID = st.SchoolID JOIN dbo.Teachers t ON st.TeacherID = t.TeacherID
I don't think the extra overhead would be too drastic, especially if TeacherName is indexed. And, unless a school has a standing policy of not hiring two teachers with the same name, (unlikely), this would more closely model the real world. And it would give a nice looking output:
TeacherName -------------- Jack Layton Paul Martin (123) Paul Martin (456) Steven Harper (0)
Good idea John! Thanks.
hmmmm ... just think ... calling Steven Harper, "Mr. Zero", all the time.
Sounds good to me ....
--
Lyle
(for e-mail refer to http://ffdba.com/)
"Douglas J. Steele" <NOSPAM_djsteel e@NOSPAM_canada .com> wrote in
news:my******** ************@tw ister01.bloor.i s.net.cable.rog ers.com: We had two individuals with the same name in a 12 person department (and their wives had the same names as well!)
You have all the fun!!!
--
Lyle
(for e-mail refer to http://ffdba.com/)
"Lyle Fairfield" <Mi************ @Invalid.Com> wrote in message
news:Xn******** ***********@130 .133.1.4... Good idea John! Thanks.
hmmmm ... just think ... calling Steven Harper, "Mr. Zero", all the time. Sounds good to me ....
:) yes - more than one Steven Harper; that's a "real" nightmare
"Lyle Fairfield" <Mi************ @Invalid.Com> wrote in message
news:Xn******** ***********@130 .133.1.4... "John Winterbottom" <as******@hotma il.com> wrote in news:2j******** *****@uni-berlin.de:
"Lyle Fairfield" <Mi************ @Invalid.Com> wrote in message news:Xn******** ***********@130 .133.1.4... I have a table: Schools, and another table: Teachers as one teacher may be assigned to more than one school I link these with a third table: SchoolTeachers
I index (unique) this linking table on SchoolID and TeacherID to prevent assigning a teacher to a school more than once.
So far, so good.
But School Administrators have difficulty with the idea that there might be more than one "Lynda Jones", teacher, assigned to one school, and that the database will keep track of these individuals with their unique TeacherID, and timetables printed out for more than one Lynda Jones may confuse students.
So I want to prevent any school from having more than one Lynda Jones, that is require unique teacher names for any school.
How to do this?
My current solution -> an indexed view:
Sub CreateSQLObject ()
With CurrentProject. Connection
.Execute "CREATE VIEW dbo.SchoolsandT eachers WITH SCHEMABINDING AS SELECT st.SchoolTeache rID, s.SchoolID, s.SchoolName, t.TeacherID, t.TeacherName FROM dbo.Schools s JOIN dbo.SchoolTeach ers st ON s.SchoolID = st.SchoolID JOIN dbo.Teachers t ON st.TeacherID = t.TeacherID"
.Execute "SET ARITHABORT ON"
.Execute "CREATE UNIQUE CLUSTERED INDEX ixSchoolsTeache rs ON dbo.SchoolsandT eachers (SchoolTeacherI D)"
.Execute "CREATE UNIQUE INDEX ixSchoolsandTea chers ON dbo.SchoolsandT eachers (SchoolID, TeacherName)"
End With
End Sub
Of course, this has not yet been tried in battle. But it seems promising. These will not be huge tables so I am hoping the indexing overhead will be minimal. Comments are welcome.
An alternative might be to create allow teachers with the same name and create a view that would include the teachers ID if a school has two or more teachers with the same:
CREATE VIEW dbo.SchoolsandT eachers WITH SCHEMABINDING AS SELECT st.SchoolTeache rID, s.SchoolID, CASE WHEN ( SELECT COUNT(*) FROM dbo.SchoolTeach ers st2 INNER JOIN dbo.Teachers t2 ON st2.TeacherID = t2.TeacherID WHERE st2.SchoolID = st.SchoolID AND t2.TeacherName = t.TeacherName ) > 1 THEN t.TeacherName + ' (' + CAST(t.TeacherI D AS VARCHAR(15)) + ')' ELSE t.TeacherName END AS TeacherName, s.SchoolName, t.TeacherID, t.TeacherName FROM dbo.Schools s JOIN dbo.SchoolTeach ers st ON s.SchoolID = st.SchoolID JOIN dbo.Teachers t ON st.TeacherID = t.TeacherID
I don't think the extra overhead would be too drastic, especially if TeacherName is indexed. And, unless a school has a standing policy of not hiring two teachers with the same name, (unlikely), this would more closely model the real world. And it would give a nice looking output:
TeacherName -------------- Jack Layton Paul Martin (123) Paul Martin (456) Steven Harper (0)
Good idea John! Thanks.
hmmmm ... just think ... calling Steven Harper, "Mr. Zero", all the time. Sounds good to me ....
What biting sarcasm. Like a tine to the eyeball.
Lyle Fairfield <Mi************ @Invalid.Com> wrote: hmmmm ... just think ... calling Steven Harper, "Mr. Zero", all the time. Sounds good to me ....
Only if Martin is a -1 and Layton a -10.
Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at http://www.granite.ab.ca/accsmstr.htm
"Tony Toews" <tt****@teluspl anet.net> wrote in message
news:1b******** *************** *********@4ax.c om... Lyle Fairfield <Mi************ @Invalid.Com> wrote:
hmmmm ... just think ... calling Steven Harper, "Mr. Zero", all the time. Sounds good to me ....
Only if Martin is a -1 and Layton a -10.
This is the one that sume it up for me http://www.cbc.ca/canadavotes/thecam...artoon/26.html
Ah politics ... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: mj |
last post by:
Hello, thanks for the help.
I am running a WinXP Pro w/ SP2 (my home computer, with ZoneAlarm
firewall)
Apache 2.0.52
MySQL 4.1.7
PHP 5.1.0-dev
I have developed a PHP/MySQL web app that tracks jobs for me, and we
|
by: francisl |
last post by:
We have to build some script were I work to make a dynamic server inventory.
But, the project team, a windows crew, start it all in vbscript and on
mssql. Note, due to political reason, we can not use mysql or anyother
one that are not *authorize*, it's oracle or mssql. Now we have to make
it work also with our sun and HP unix server(plus one Linux).
So I propose to use python, and after they see my litle python/wxwindow
program, that...
|
by: Mike |
last post by:
Hello,
I have a few rather urgent questions that I hope someone can help with (I
need to figure this out prior to a meeting tomorrow.) First, a bit of
background: The company I work for is developing a web-based application,
one part of which involves allowing the user the ability to page through
transaction "history" information.
The _summary_ history table will have the following fields: ServiceName,
Date, User-Ref1, User-Ref2,...
|
by: Nanda |
last post by:
hi,
how to create database in mssql server using c#. We can
create msacess database using adox, similiarly how to
create sql server database using c#.
Regards,
Nanda.
|
by: Jeremy Cowles |
last post by:
Disclaimer: This could be considered an ADO question, but, it really is a
question of code maintenance.
I have created a utility app that synchronizes MSSQL tables & stored
procedures as Classes in .NET. So Given the following table structure:
Table Name: ITEM
item_id varchar(20)
description varchar(40)
| |
by: rod.weir |
last post by:
Fellow database developers,
I would like to draw on your experience with views. I have a database
that includes many views. Sometimes, views contains other views, and
those views in turn may contain views. In fact, I have some views in
my database that are a product of nested views of up to 6 levels deep!
The reason we did this was.
1. Object-oriented in nature. Makes it easy to work with them.
|
by: Olegus |
last post by:
Hello,
in order to perform backup/restore MSSQL database using SMO, one needs
to reference several namespaces in a backup class :
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;
Unfortunately, MSSQL 2005 and MSSQL Express keep them in different
place.
For MSSQL2005 they are located in C:\Program Files\Microsoft SQL Server
\90\SDK\Assemblies and for MSSQL Express you can find them in C:
|
by: bdkakde |
last post by:
How to run following mssql file using jdbc?
PRINT ''
PRINT '##################################################################'
PRINT 'Begin Script: DropTables ' + convert(varchar,current_timestamp)
PRINT ' DB server: ' + @@servername
PRINT ''
BEGIN
|
by: ThePhenix |
last post by:
Hi everybody,
I have recently been doing a conversion for my boss for a access 2000 database (both front and backend) to a MSSQL backend.
I finished the conversion today (as quite a lot of the code / queries ran slow due to access running the queries locally rather than on the server). And tested it on my and my boss's machine with no problems so he gave the go ahead to update everybody to our new mssql 2000 backend with the modified...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |